]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - tests/lib.sh.test
lib.sh: Generalize sed_i() to cmd_i() for in-place changes.
[config/dotfiles.git] / tests / lib.sh.test
1 # Tests for lib.sh.
2
3 # Copyright (C) 2009-2013  Simon Ruderich
4 #
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.
9 #
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.
14 #
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/>.
17
18
19 . ../lib.sh
20
21
22 # Tests for generate().
23 echo "Simple test file for generate() using m4.
24 include(../lib.m4)dnl
25 IF(TEST,m4)
26     m4
27 FI
28 IF(TEST,n4)
29     n4
30 FI" > tmp/test.m4
31 generate m4 tmp/test -DTEST=m4
32 # Remove the line with the current date as it changes every time.
33 cat tmp/test | grep -v "It was generated from tmp/test.m4"
34
35 # Test multiple arguments to generate().
36 echo "Test with multiple arguments passed to generate().
37 first: FIRST
38 second: SECOND
39 " > tmp/test-multiple.m4
40 generate m4 tmp/test-multiple -DFIRST=first -DSECOND=second
41 # Remove the line with the current date as it changes every time.
42 cat tmp/test-multiple | grep -v "It was generated from tmp/test-multiple.m4"
43
44 # Test multiple arguments with spaces to generate().
45 echo "Test with multiple arguments with spaces passed to generate().
46 first: FIRST
47 second: SECOND
48 " > tmp/test-multiple-spaces.m4
49 generate m4 tmp/test-multiple-spaces -DFIRST="first with spaces" \
50                                      -DSECOND="second with spaces"
51 # Remove the line with the current date as it changes every time.
52 cat tmp/test-multiple-spaces \
53     | grep -v "It was generated from tmp/test-multiple-spaces.m4"
54
55 # Test generate() using awk.
56 echo "Simple test fiel for generate() using awk.
57 first second
58 " > tmp/test-awk.in
59 generate awk tmp/test-awk '{ print $1 }'
60 # Remove the line with the current date as it changes every time.
61 cat tmp/test-awk | grep -v "It was generated from tmp/test-awk.in"
62
63 # Test generate() using perl.
64 echo "Simple test fiel for generate() using perl.
65 first second
66 " > tmp/test-perl.in
67 generate perl tmp/test-perl -p -e 's/first/best/'
68 # Remove the line with the current date as it changes every time.
69 cat tmp/test-perl | grep -v "It was generated from tmp/test-perl.in"
70
71 # Test generate() using cat.
72 echo "Simple test fiel for generate() using cat (simple copy).
73
74 ...
75 " > tmp/test-cat.real
76 generate cat tmp/test-cat .real
77 # Remove the line with the current date as it changes every time.
78 cat tmp/test-cat | grep -v "It was generated from tmp/test-cat.real"
79
80 # vim: ft=sh