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 /tests | |
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.
Diffstat (limited to 'tests')
37 files changed, 191 insertions, 0 deletions
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 +} |