]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - tests/run.sh
lib.sh: Generalize sed_i() to cmd_i() for in-place changes.
[config/dotfiles.git] / tests / run.sh
1 #!/bin/sh
2
3 # Runs all tests in this directory.
4
5 # Copyright (C) 2009-2013  Simon Ruderich
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 # Get all test files.
22 for file in *.test; do
23     # Create temporary directory.
24     mkdir -p tmp
25
26     # Run the test file in sh and zsh and get its output.
27     sh $file  > $file.out.sh  2>&1
28     zsh $file > $file.out.zsh 2>&1
29
30     # Check if the output matches the expected one. If not abort with exit
31     # code 1.
32     diff -u $file.out $file.out.sh  || exit 1
33     diff -u $file.out $file.out.zsh || exit 1
34
35     # Remove temporary directory.
36     rm -rf tmp
37 done
38
39 # Remove all temporary files.
40 rm *.out.sh
41 rm *.out.zsh