]> Cypherpunks.ru repositories - goredo.git/blobdiff - t/redo-sh.tests/ood_3/test
Add redo-ood related redo.sh-tests/ood_* unittests
[goredo.git] / t / redo-sh.tests / ood_3 / test
diff --git a/t/redo-sh.tests/ood_3/test b/t/redo-sh.tests/ood_3/test
new file mode 100755 (executable)
index 0000000..347d53b
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh -eu
+# When invoked, redo-ood must output targets for which a dependency
+# changed and targets for which a dependency of a dependency changed
+# and targets for which a dependency of a dependency of a dependency
+# changed.
+
+>all.do printf 'redo-ifchange a
+'
+
+>a.do cat <<EOF
+redo-ifchange b
+printf '0
+'
+EOF
+
+>b.do cat <<EOF
+redo-ifchange c
+printf '1
+'
+EOF
+
+>c.do cat <<EOF
+redo-ifchange d
+printf '2
+'
+EOF
+
+>d printf '3
+'
+
+redo
+<a read -r a1
+<b read -r b1
+<c read -r c1
+<d read -r d1
+
+ood1=$(redo-ood)
+
+>d printf '4\n'
+<d read -r d2
+
+ood2=$(redo-ood)
+
+test 0 -eq "${a1}"
+test 1 -eq "${b1}"
+test 2 -eq "${c1}"
+test 3 -eq "${d1}"
+test 4 -eq "${d2}"
+
+test -z "${ood1}"
+test -n "${ood2}"
+
+. ../stat_inode.rc
+
+inode_a=$(stat_inode a)
+inode_b=$(stat_inode b)
+inode_c=$(stat_inode c)
+inodes_ood=$(stat_inode ${ood2})
+
+case "${inodes_ood}" in
+ *"${inode_a}"*)
+ ;;
+ *)
+  exit 1
+ ;;
+esac
+
+case "${inodes_ood}" in
+ *"${inode_b}"*)
+ ;;
+ *)
+  exit 1
+ ;;
+esac
+
+case "${inodes_ood}" in
+ *"${inode_c}"*)
+ ;;
+ *)
+  exit 1
+ ;;
+esac