From: Simon Ruderich Date: Sun, 1 Mar 2009 15:31:37 +0000 (+0100) Subject: tests: Add tests for m4() in lib.sh. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=ec22bd63fe3e0d9b36918023bfe5b90a25bef3db;p=config%2Fdotfiles.git tests: Add tests for m4() in lib.sh. --- diff --git a/tests/lib.sh.test b/tests/lib.sh.test index d3dc2e0..3140c23 100644 --- a/tests/lib.sh.test +++ b/tests/lib.sh.test @@ -20,4 +20,16 @@ function which() { installed ls && echo ls installed installed doesnt-exist && echo doesnt-exist installed +# Tests for m4(). +echo "Simple test file for m4. +IF(TEST,m4) + m4 +FI +IF(TEST,n4) + n4 +FI" > tmp/test.m4 +m4 tmp/test -DTEST=m4 +# Remove the line with the current date as it changes every time. +cat tmp/test | grep -v "It was generated from tmp/test.m4" + # vim: ft=sh diff --git a/tests/lib.sh.test.out b/tests/lib.sh.test.out index 8d39aab..0bd50a9 100644 --- a/tests/lib.sh.test.out +++ b/tests/lib.sh.test.out @@ -2,3 +2,11 @@ ls installed Mac OS X which for ls ls installed Mac OS X which for doesnt-exist +m4(): generating 'tmp/test' from 'tmp/test.m4' with options '-DTEST=m4' +################################### +# WARNING! DO NOT EDIT THIS FILE! # +################################### + + +Simple test file for m4. + m4 diff --git a/tests/run.sh b/tests/run.sh index 805b450..89b84f2 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -5,6 +5,9 @@ # Get all test files. for file in *.test; do + # Create temporary directory. + mkdir -p tmp + # Run the test file in sh and zsh and get its output. sh $file > $file.out.sh 2>&1 zsh $file > $file.out.zsh 2>&1 @@ -13,9 +16,11 @@ for file in *.test; do # code 1. diff -u -N $file.out $file.out.sh || exit 1 diff -u -N $file.out $file.out.zsh || exit 1 + + # Remove temporary directory. + rm -rf tmp done # Remove all temporary files. -rm -rf tmp rm *.out.sh rm *.out.zsh