diff options
author | Tharre <tharre3@gmail.com> | 2015-05-25 16:20:27 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2015-05-25 16:20:27 +0200 |
commit | c7712dfd7bf2734e339096d3274f5b0bef2b4335 (patch) | |
tree | 3b4ce149869e4b3273c1c53dd7194a2ad8b5760e | |
parent | 91e31ebf711d38830b0b53dc848aa90223f9be1d (diff) | |
download | redo-c7712dfd7bf2734e339096d3274f5b0bef2b4335.tar.gz redo-c7712dfd7bf2734e339096d3274f5b0bef2b4335.tar.xz redo-c7712dfd7bf2734e339096d3274f5b0bef2b4335.zip |
Replace current tests with a hole new test suite
This new test suite is based on just on do scripts, much like apenwarr's redo
implementation has done it. This makes tests both simpler and free from any
additional dependencies. The naming was also improved a lot.
There are also a lot of new tests, and many more to be implemeted later.
48 files changed, 192 insertions, 71 deletions
diff --git a/.travis.yml b/.travis.yml index 2f50da2..d4bf599 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,4 @@ language: c compiler: - gcc - clang -script: ./autogen.sh && ./configure && ./build.sh && bats test/ -before_install: - - sudo add-apt-repository ppa:duggan/bats --yes - - sudo apt-get update -qq - - sudo apt-get install -qq bats +script: ./autogen.sh && ./configure && ./build.sh && redo tests/all diff --git a/test/always.bats b/test/always.bats deleted file mode 100644 index b6dab37..0000000 --- a/test/always.bats +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test "check if do-files marked with always really do execute always" { - skip "Not yet implemented" - run redo always - [ $status -eq 0 ] && [ -e always_result ] -} diff --git a/test/always.do b/test/always.do deleted file mode 100644 index 12e16ba..0000000 --- a/test/always.do +++ /dev/null @@ -1,7 +0,0 @@ -redo-ifchange always_test - -rm always_result - -redo-ifchange always_test - -rm always_test # TODO: move this to test-helper.bash somehow diff --git a/test/always_test.do b/test/always_test.do deleted file mode 100644 index 425ab6d..0000000 --- a/test/always_test.do +++ /dev/null @@ -1,3 +0,0 @@ -redo-always -touch always_result -echo "Content" > $3 diff --git a/test/args.bats b/test/args.bats deleted file mode 100644 index 4115b66..0000000 --- a/test/args.bats +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test "check arguments supplied to .do files" { - run redo args_test.ext - [ $status -eq 0 ] -} diff --git a/test/args_test.ext.do b/test/args_test.ext.do deleted file mode 100644 index 588192a..0000000 --- a/test/args_test.ext.do +++ /dev/null @@ -1,3 +0,0 @@ -[ "$1" = "args_test.ext" ] && -[ "$2" = "args_test" ] && -[ "$3" != "args_test.ext" ] diff --git a/test/fail.bats b/test/fail.bats deleted file mode 100644 index 1a77ced..0000000 --- a/test/fail.bats +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test "invoke with target without do-file" { - run redo this-does-not-exist - [ $status -ne 0 ] -} - -@test "invoke with failing do-file" { - run redo fail - [ $status -ne 0 ] && [ ! -e fail_result ] -} diff --git a/test/fail.do b/test/fail.do deleted file mode 100644 index f87b607..0000000 --- a/test/fail.do +++ /dev/null @@ -1,2 +0,0 @@ -this-shall-fail -touch fail_result diff --git a/test/no-output.bats b/test/no-output.bats deleted file mode 100644 index c492e4f..0000000 --- a/test/no-output.bats +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test "produce empty result" { - run redo no-output_result - [ $status -eq 0 ] && [ ! -e no-output_result ] -} diff --git a/test/no-output_result.do b/test/no-output_result.do deleted file mode 100644 index b58ff30..0000000 --- a/test/no-output_result.do +++ /dev/null @@ -1 +0,0 @@ -touch $3 diff --git a/test/test_helper.bash b/test/test_helper.bash deleted file mode 100644 index 2c26399..0000000 --- a/test/test_helper.bash +++ /dev/null @@ -1,12 +0,0 @@ -teardown() { - rm -rf .redo/ - - # remove all helper files - for i in *.bats; do - rm -f "${i%%.*}_result" - done -} - -setup() { - cd "$BATS_TEST_DIRNAME" -} diff --git a/tests/a--b,a--c,b--c/a.do b/tests/a--b,a--c,b--c/a.do new file mode 100644 index 0000000..2a1b779 --- /dev/null +++ b/tests/a--b,a--c,b--c/a.do @@ -0,0 +1,3 @@ +redo-ifchange b c + +echo -n "a" | cat - b c > $3 diff --git a/tests/a--b,a--c,b--c/all.do b/tests/a--b,a--c,b--c/all.do new file mode 100644 index 0000000..dab5463 --- /dev/null +++ b/tests/a--b,a--c,b--c/all.do @@ -0,0 +1,9 @@ +. ../include.sh + +rm -rf a b c + +redo-ifchange a + +assert "a--b,a--c,b--c" << ! +[ "$(cat a)" = "abcc" ] +! diff --git a/tests/a--b,a--c,b--c/b.do b/tests/a--b,a--c,b--c/b.do new file mode 100644 index 0000000..fc555dd --- /dev/null +++ b/tests/a--b,a--c,b--c/b.do @@ -0,0 +1,3 @@ +redo-ifchange c + +echo -n "b" | cat - c > $3 diff --git a/tests/a--b,a--c,b--c/c.do b/tests/a--b,a--c,b--c/c.do new file mode 100644 index 0000000..6a816ac --- /dev/null +++ b/tests/a--b,a--c,b--c/c.do @@ -0,0 +1 @@ +echo -n "c" > $3 diff --git a/tests/a--b,a--c,b--d,c--d/a.do b/tests/a--b,a--c,b--d,c--d/a.do new file mode 100644 index 0000000..2a1b779 --- /dev/null +++ b/tests/a--b,a--c,b--d,c--d/a.do @@ -0,0 +1,3 @@ +redo-ifchange b c + +echo -n "a" | cat - b c > $3 diff --git a/tests/a--b,a--c,b--d,c--d/all.do b/tests/a--b,a--c,b--d,c--d/all.do new file mode 100644 index 0000000..db431a4 --- /dev/null +++ b/tests/a--b,a--c,b--d,c--d/all.do @@ -0,0 +1,9 @@ +. ../include.sh + +rm -rf a b c d + +redo-ifchange a + +assert "a--b,a--c,b--d,c--d" << ! +[ "$(cat a)" = "abdcd" ] +! diff --git a/tests/a--b,a--c,b--d,c--d/b.do b/tests/a--b,a--c,b--d,c--d/b.do new file mode 100644 index 0000000..9a2fbf4 --- /dev/null +++ b/tests/a--b,a--c,b--d,c--d/b.do @@ -0,0 +1,3 @@ +redo-ifchange d + +echo -n "b" | cat - d > $3 diff --git a/tests/a--b,a--c,b--d,c--d/c.do b/tests/a--b,a--c,b--d,c--d/c.do new file mode 100644 index 0000000..fdc64d8 --- /dev/null +++ b/tests/a--b,a--c,b--d,c--d/c.do @@ -0,0 +1,3 @@ +redo-ifchange d + +echo -n "c" | cat - d > $3 diff --git a/tests/a--b,a--c,b--d,c--d/d.do b/tests/a--b,a--c,b--d,c--d/d.do new file mode 100644 index 0000000..ab21832 --- /dev/null +++ b/tests/a--b,a--c,b--d,c--d/d.do @@ -0,0 +1 @@ +echo -n "d" > $3 diff --git a/tests/a--c,b--c,c--d/a.do b/tests/a--c,b--c,c--d/a.do new file mode 100644 index 0000000..34d0c7c --- /dev/null +++ b/tests/a--c,b--c,c--d/a.do @@ -0,0 +1,3 @@ +redo-ifchange c + +echo -n "a" | cat - c > $3 diff --git a/tests/a--c,b--c,c--d/all.do b/tests/a--c,b--c,c--d/all.do new file mode 100644 index 0000000..2c93c8a --- /dev/null +++ b/tests/a--c,b--c,c--d/all.do @@ -0,0 +1,10 @@ +. ../include.sh + +rm -rf a b c d + +redo-ifchange a b + +assert "a--c,b--c,c--d" << ! +[ "$(cat a)" = "acd" ] && +[ "$(cat b)" = "bcd" ] +! diff --git a/tests/a--c,b--c,c--d/b.do b/tests/a--c,b--c,c--d/b.do new file mode 100644 index 0000000..fc555dd --- /dev/null +++ b/tests/a--c,b--c,c--d/b.do @@ -0,0 +1,3 @@ +redo-ifchange c + +echo -n "b" | cat - c > $3 diff --git a/tests/a--c,b--c,c--d/c.do b/tests/a--c,b--c,c--d/c.do new file mode 100644 index 0000000..fdc64d8 --- /dev/null +++ b/tests/a--c,b--c,c--d/c.do @@ -0,0 +1,3 @@ +redo-ifchange d + +echo -n "c" | cat - d > $3 diff --git a/tests/a--c,b--c,c--d/d.do b/tests/a--c,b--c,c--d/d.do new file mode 100644 index 0000000..ab21832 --- /dev/null +++ b/tests/a--c,b--c,c--d/d.do @@ -0,0 +1 @@ +echo -n "d" > $3 diff --git a/tests/a--c,b--c/a.do b/tests/a--c,b--c/a.do new file mode 100644 index 0000000..34d0c7c --- /dev/null +++ b/tests/a--c,b--c/a.do @@ -0,0 +1,3 @@ +redo-ifchange c + +echo -n "a" | cat - c > $3 diff --git a/tests/a--c,b--c/all.do b/tests/a--c,b--c/all.do new file mode 100644 index 0000000..6724b38 --- /dev/null +++ b/tests/a--c,b--c/all.do @@ -0,0 +1,10 @@ +. ../include.sh + +rm -rf a b c + +redo-ifchange a b + +assert "a--c,b--c" << ! +[ "$(cat a)" = "ac" ] && +[ "$(cat b)" = "bc" ] +! diff --git a/tests/a--c,b--c/b.do b/tests/a--c,b--c/b.do new file mode 100644 index 0000000..fc555dd --- /dev/null +++ b/tests/a--c,b--c/b.do @@ -0,0 +1,3 @@ +redo-ifchange c + +echo -n "b" | cat - c > $3 diff --git a/tests/a--c,b--c/c.do b/tests/a--c,b--c/c.do new file mode 100644 index 0000000..6a816ac --- /dev/null +++ b/tests/a--c,b--c/c.do @@ -0,0 +1 @@ +echo -n "c" > $3 diff --git a/tests/a/a.do b/tests/a/a.do new file mode 100644 index 0000000..bdff4bb --- /dev/null +++ b/tests/a/a.do @@ -0,0 +1 @@ +echo "a" > $3 diff --git a/tests/a/all.do b/tests/a/all.do new file mode 100644 index 0000000..71e4a27 --- /dev/null +++ b/tests/a/all.do @@ -0,0 +1,9 @@ +. ../include.sh + +rm -rf a + +redo-ifchange a + +assert "a" << ! +[ "$(cat a)" = "a" ] +! diff --git a/tests/all.do b/tests/all.do new file mode 100644 index 0000000..e9644f9 --- /dev/null +++ b/tests/all.do @@ -0,0 +1,16 @@ +exec 1>/dev/null +redo fail/all +redo args/all +redo a/all +redo a--b,a--c,b--c/all +redo a--b,a--c,b--d,c--d/all +redo a--c,b--c/all +redo a--c,b--c,c--d/all +redo cwd/all +#redo default/all +#redo dodo/all +redo always/all +redo ifcreate/all +#redo parallel/all +#redo atomic/all +redo dependency-loop/all diff --git a/tests/always/a.do b/tests/always/a.do new file mode 100644 index 0000000..f412852 --- /dev/null +++ b/tests/always/a.do @@ -0,0 +1,3 @@ +redo-always + +date +%N > $3 diff --git a/tests/always/all.do b/tests/always/all.do new file mode 100644 index 0000000..de262ce --- /dev/null +++ b/tests/always/all.do @@ -0,0 +1,9 @@ +. ../include.sh + +rm -rf a + +redo a + +assert "always" << ! +[ "$(cat a)" = "??" ] +! diff --git a/tests/args/all.do b/tests/args/all.do new file mode 100644 index 0000000..d45bd96 --- /dev/null +++ b/tests/args/all.do @@ -0,0 +1,5 @@ +. ../include.sh + +assert "check arguments supplied to do-script" << ! +redo-ifchange d/a.ext +! diff --git a/tests/args/d/a.ext.do b/tests/args/d/a.ext.do new file mode 100644 index 0000000..fea7d74 --- /dev/null +++ b/tests/args/d/a.ext.do @@ -0,0 +1,3 @@ +[ "$1" = "a.ext" ] +[ "$2" = "a" ] +[ "$3" != "a.ext" ] diff --git a/tests/cwd/a.do b/tests/cwd/a.do new file mode 100644 index 0000000..e8455fe --- /dev/null +++ b/tests/cwd/a.do @@ -0,0 +1,3 @@ +redo-ifchange d/b + +echo -n "a" | cat - d/b > $3 diff --git a/tests/cwd/all.do b/tests/cwd/all.do new file mode 100644 index 0000000..866a9ca --- /dev/null +++ b/tests/cwd/all.do @@ -0,0 +1,9 @@ +. ../include.sh + +rm -rf a d/b d/d/c + +redo-ifchange a + +assert "cwd" << ! +[ "$(cat a)" == "abc" ] +! diff --git a/tests/cwd/d/b.do b/tests/cwd/d/b.do new file mode 100644 index 0000000..5a81363 --- /dev/null +++ b/tests/cwd/d/b.do @@ -0,0 +1,3 @@ +redo-ifchange d/c + +echo -n "b" | cat - d/c > $3 diff --git a/tests/cwd/d/d/c.do b/tests/cwd/d/d/c.do new file mode 100644 index 0000000..6a816ac --- /dev/null +++ b/tests/cwd/d/d/c.do @@ -0,0 +1 @@ +echo -n "c" > $3 diff --git a/tests/dependency-loop/a.do b/tests/dependency-loop/a.do new file mode 100644 index 0000000..180027f --- /dev/null +++ b/tests/dependency-loop/a.do @@ -0,0 +1,3 @@ +redo-ifchange b + +echo -n "a" | cat - b > $3 diff --git a/tests/dependency-loop/all.do b/tests/dependency-loop/all.do new file mode 100644 index 0000000..c5cb480 --- /dev/null +++ b/tests/dependency-loop/all.do @@ -0,0 +1,5 @@ +. ../include.sh + +assert "dependency-loop" << ! +timeout 1 redo-ifchange a >& /dev/null +! diff --git a/tests/dependency-loop/b.do b/tests/dependency-loop/b.do new file mode 100644 index 0000000..134228c --- /dev/null +++ b/tests/dependency-loop/b.do @@ -0,0 +1,3 @@ +redo-ifchange a + +echo -n "b" | cat - a > $3 diff --git a/tests/fail/all.do b/tests/fail/all.do new file mode 100644 index 0000000..9ad5ef8 --- /dev/null +++ b/tests/fail/all.do @@ -0,0 +1,9 @@ +. ../include.sh + +rm -rf fail + +redo-ifchange fail >& /dev/null || true + +assert "abort if do-script returns nonzero" << ! +[ ! -e fail ] +! diff --git a/tests/fail/fail.do b/tests/fail/fail.do new file mode 100644 index 0000000..2251510 --- /dev/null +++ b/tests/fail/fail.do @@ -0,0 +1,2 @@ +echo "fail" > $3 +exit 1 diff --git a/tests/ifcreate/a.do b/tests/ifcreate/a.do new file mode 100644 index 0000000..7f58ce4 --- /dev/null +++ b/tests/ifcreate/a.do @@ -0,0 +1,11 @@ + +if [ -e b ]; then + echo -n "b" | cat - a > $3 +else + redo-ifcreate b + if [ -e a ]; then + echo -n "a" | cat - a > $3 + else + echo "a" > $3 + fi +fi diff --git a/tests/ifcreate/all.do b/tests/ifcreate/all.do new file mode 100644 index 0000000..93fdaf9 --- /dev/null +++ b/tests/ifcreate/all.do @@ -0,0 +1,17 @@ +. ../include.sh + +rm -rf a b + +# we use redo here, as redo-ifchange is smart enough not to rebuild the same +# file twice in the same redo session + +redo a +redo a + +touch b + +redo a + +assert "ifcreate" << ! +[ "$(cat a)" = "baa" ] +! diff --git a/tests/include.sh b/tests/include.sh new file mode 100644 index 0000000..7052585 --- /dev/null +++ b/tests/include.sh @@ -0,0 +1,7 @@ +assert() { + if source /dev/stdin; then + echo "PASS: $1" >&2 + else + echo "FAIL: $1" >&2 + fi +} |