3 # Copyright (C) 2009-2013 Simon Ruderich
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # which with proper exit codes and output to stdout.
26 echo no doesnt-exist in /usr/bin /bin /usr/sbin /sbin
31 installed ls && echo ls installed
32 installed doesnt-exist && echo doesnt-exist installed
34 # which with proper exit codes and output to stderr in case of an error.
39 echo no doesnt-exist in /usr/bin /bin /usr/sbin /sbin >&2
44 installed ls && echo ls installed
45 installed doesnt-exist && echo doesnt-exist installed
47 # which with no proper exit codes and output to stdout in case of an error.
52 echo no doesnt-exist in /usr/bin /bin /usr/sbin /sbin
56 installed ls && echo ls installed
57 installed doesnt-exist && echo doesnt-exist installed
59 # which with proper exit codes and no output in case of an error.
68 installed ls && echo ls installed
69 installed doesnt-exist && echo doesnt-exist installed
72 # Tests for generate().
73 echo "Simple test file for generate() using m4.
81 generate m4 tmp/test -DTEST=m4
82 # Remove the line with the current date as it changes every time.
83 cat tmp/test | grep -v "It was generated from tmp/test.m4"
85 # Test multiple arguments to generate().
86 echo "Test with multiple arguments passed to generate().
89 " > tmp/test-multiple.m4
90 generate m4 tmp/test-multiple -DFIRST=first -DSECOND=second
91 # Remove the line with the current date as it changes every time.
92 cat tmp/test-multiple | grep -v "It was generated from tmp/test-multiple.m4"
94 # Test multiple arguments with spaces to generate().
95 echo "Test with multiple arguments with spaces passed to generate().
98 " > tmp/test-multiple-spaces.m4
99 generate m4 tmp/test-multiple-spaces -DFIRST="first with spaces" \
100 -DSECOND="second with spaces"
101 # Remove the line with the current date as it changes every time.
102 cat tmp/test-multiple-spaces \
103 | grep -v "It was generated from tmp/test-multiple-spaces.m4"
105 # Test generate() using awk.
106 echo "Simple test fiel for generate() using awk.
109 generate awk tmp/test-awk '{ print $1 }'
110 # Remove the line with the current date as it changes every time.
111 cat tmp/test-awk | grep -v "It was generated from tmp/test-awk.in"
113 # Test generate() using perl.
114 echo "Simple test fiel for generate() using perl.
117 generate perl tmp/test-perl -p -e 's/first/best/'
118 # Remove the line with the current date as it changes every time.
119 cat tmp/test-perl | grep -v "It was generated from tmp/test-perl.in"
121 # Test generate() using cat.
122 echo "Simple test fiel for generate() using cat (simple copy).
125 " > tmp/test-cat.real
126 generate cat tmp/test-cat .real
127 # Remove the line with the current date as it changes every time.
128 cat tmp/test-cat | grep -v "It was generated from tmp/test-cat.real"