]> Cypherpunks.ru repositories - goredo.git/blobdiff - t/redo-sh.tests/whichdo_relative_default_2/test
Import tests from apenwarr/redo and redo.sh
[goredo.git] / t / redo-sh.tests / whichdo_relative_default_2 / test
diff --git a/t/redo-sh.tests/whichdo_relative_default_2/test b/t/redo-sh.tests/whichdo_relative_default_2/test
new file mode 100755 (executable)
index 0000000..385cf5f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh -eu
+# When invoked with a relative filename for the file “default.do” as
+# an argument, redo-whichdo must not output that filename as possible
+# dofile.
+
+default_dofile="default.do"
+
+whichdo_dofiles=$(
+ redo-whichdo "${default_dofile}" \
+   |tr '\0' '\n'
+)
+
+for whichdo_dofile in ${whichdo_dofiles}; do
+ case "${whichdo_dofile}" in
+  "${PWD}/${default_dofile}")
+   >&2 printf 'redo-whichdo outputs that this file is its own dofile: %s\n' \
+    "${whichdo_dofile}"
+   exit 1
+  ;;
+ esac
+done