aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml6
-rw-r--r--test/always.bats9
-rw-r--r--test/always.do7
-rw-r--r--test/always_test.do3
-rw-r--r--test/args.bats8
-rw-r--r--test/args_test.ext.do3
-rw-r--r--test/fail.bats13
-rw-r--r--test/fail.do2
-rw-r--r--test/no-output.bats8
-rw-r--r--test/no-output_result.do1
-rw-r--r--test/test_helper.bash12
-rw-r--r--tests/a--b,a--c,b--c/a.do3
-rw-r--r--tests/a--b,a--c,b--c/all.do9
-rw-r--r--tests/a--b,a--c,b--c/b.do3
-rw-r--r--tests/a--b,a--c,b--c/c.do1
-rw-r--r--tests/a--b,a--c,b--d,c--d/a.do3
-rw-r--r--tests/a--b,a--c,b--d,c--d/all.do9
-rw-r--r--tests/a--b,a--c,b--d,c--d/b.do3
-rw-r--r--tests/a--b,a--c,b--d,c--d/c.do3
-rw-r--r--tests/a--b,a--c,b--d,c--d/d.do1
-rw-r--r--tests/a--c,b--c,c--d/a.do3
-rw-r--r--tests/a--c,b--c,c--d/all.do10
-rw-r--r--tests/a--c,b--c,c--d/b.do3
-rw-r--r--tests/a--c,b--c,c--d/c.do3
-rw-r--r--tests/a--c,b--c,c--d/d.do1
-rw-r--r--tests/a--c,b--c/a.do3
-rw-r--r--tests/a--c,b--c/all.do10
-rw-r--r--tests/a--c,b--c/b.do3
-rw-r--r--tests/a--c,b--c/c.do1
-rw-r--r--tests/a/a.do1
-rw-r--r--tests/a/all.do9
-rw-r--r--tests/all.do16
-rw-r--r--tests/always/a.do3
-rw-r--r--tests/always/all.do9
-rw-r--r--tests/args/all.do5
-rw-r--r--tests/args/d/a.ext.do3
-rw-r--r--tests/cwd/a.do3
-rw-r--r--tests/cwd/all.do9
-rw-r--r--tests/cwd/d/b.do3
-rw-r--r--tests/cwd/d/d/c.do1
-rw-r--r--tests/dependency-loop/a.do3
-rw-r--r--tests/dependency-loop/all.do5
-rw-r--r--tests/dependency-loop/b.do3
-rw-r--r--tests/fail/all.do9
-rw-r--r--tests/fail/fail.do2
-rw-r--r--tests/ifcreate/a.do11
-rw-r--r--tests/ifcreate/all.do17
-rw-r--r--tests/include.sh7
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
+}