]> Cypherpunks.ru repositories - goredo.git/blobdiff - t/redo-sh.tests/dependency_ne_dofile_1/test
Import tests from apenwarr/redo and redo.sh
[goredo.git] / t / redo-sh.tests / dependency_ne_dofile_1 / test
diff --git a/t/redo-sh.tests/dependency_ne_dofile_1/test b/t/redo-sh.tests/dependency_ne_dofile_1/test
new file mode 100755 (executable)
index 0000000..f89d2f4
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh -eu
+# A target built with a default dofile in the same directory must be rebuilt if a more specific dofile appears.
+
+test -e a.b.c && \
+ rm -- a.b.c
+
+>all.do cat <<EOF
+redo-ifchange a.b.c
+EOF
+
+dofiles="default.do default.c.do default.b.c.do a.b.c.do"
+
+for dofile in ${dofiles}; do
+ [ -e "${dofile}" ] && \
+  rm -- "${dofile}" || :
+done
+
+for dofile in ${dofiles}; do
+ >"${dofile}" cat <<EOF
+printf '${dofile}\n'
+EOF
+
+ redo
+ <a.b.c read -r text
+ if ! [ "${text}" = "${dofile}" ]; then
+  >&2 printf 'a.b.c was built with %s, should have been built with %s\n' \
+   "${text}" "${dofile}"
+  exit 1
+ fi
+done