]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - tests/lib.sh.test
4557698653c06717aa2ae51361fb36a642662b4d
[config/dotfiles.git] / tests / lib.sh.test
1 # Tests for lib.sh.
2
3
4 . ../lib.sh
5
6 # Tests for installed() with hopefully proper exit codes (1 if the program was
7 # not found).
8 installed ls && echo ls installed
9 installed doesnt-exist && echo doesnt-exist installed
10 # Simulate BSD `which` like on Mac OS X which doesn't use exit codes.
11 function which() {
12     echo Mac OS X which for $1 >&2
13     if [ $1 = ls ]; then
14         echo /bin/ls
15     else
16         echo no doesnt-exist in /usr/bin /bin /usr/sbin /sbin
17     fi
18 }
19 # Tests for installed() without exit codes.
20 installed ls && echo ls installed
21 installed doesnt-exist && echo doesnt-exist installed
22
23 # Tests for m4().
24 echo "Simple test file for m4.
25 IF(TEST,m4)
26     m4
27 FI
28 IF(TEST,n4)
29     n4
30 FI" > tmp/test.m4
31 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 # Test multiple arguments to m4().
35 echo "Test with multiple arguments passed to m4.
36 first: FIRST
37 second: SECOND
38 " > tmp/test-multiple.m4
39 m4 tmp/test-multiple -DFIRST=first -DSECOND=second
40 # Remove the line with the current date as it changes every time.
41 cat tmp/test-multiple | grep -v "It was generated from tmp/test-multiple.m4"
42
43 # vim: ft=sh