]> Cypherpunks.ru repositories - goredo.git/commitdiff
Add redo-ood related redo.sh-tests/ood_* unittests
authorSergey Matveev <stargrave@stargrave.org>
Mon, 21 Jun 2021 12:33:06 +0000 (15:33 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 21 Jun 2021 12:56:47 +0000 (15:56 +0300)
t/redo-sh.tests/README
t/redo-sh.tests/ood_1/test [new file with mode: 0755]
t/redo-sh.tests/ood_2/test [new file with mode: 0755]
t/redo-sh.tests/ood_3/test [new file with mode: 0755]
t/redo-sh.tests/stat_inode.rc [new file with mode: 0644]
t/redosh-ood_1.t [new symlink]
t/redosh-ood_2.t [new symlink]
t/redosh-ood_3.t [new symlink]

index 08b4ae86fc80442cb90110f8481fd197561623b4..336d2a11e3d1e8a097499f48d1126edb4b4cbff4 100644 (file)
@@ -1,3 +1,4 @@
 Those tests are taken from http://news.dieweltistgarnichtso.net/bin.git.
 Test parallel_2 removed, because goredo has no --jobs.
 Test always_rebuild_1 removed, because always-target is rebuilt once per run.
+stat call is replaced with portable perl script invocation in ood_*.
diff --git a/t/redo-sh.tests/ood_1/test b/t/redo-sh.tests/ood_1/test
new file mode 100755 (executable)
index 0000000..15a14dc
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh -eu
+# When invoked, redo-ood must output targets for which a dependency
+# changed.
+
+>all.do printf 'redo-ifchange a
+'
+
+>a.do cat <<EOF
+redo-ifchange b
+printf '0
+'
+EOF
+
+>b printf '1
+'
+
+redo
+<a read -r a1
+<b read -r b1
+
+ood1=$(redo-ood)
+
+>b printf '2
+'
+<b read -r b2
+
+ood2=$(redo-ood)
+
+test 0 -eq "${a1}"
+test 1 -eq "${b1}"
+test 2 -eq "${b2}"
+
+test -z "${ood1}"
+test -n "${ood2}"
+
+. ../stat_inode.rc
+
+inode_a=$(stat_inode a)
+inodes_ood=$(stat_inode "${ood2}")
+
+test "${inode_a}" = "${inodes_ood}"
diff --git a/t/redo-sh.tests/ood_2/test b/t/redo-sh.tests/ood_2/test
new file mode 100755 (executable)
index 0000000..5b5b135
--- /dev/null
@@ -0,0 +1,64 @@
+#!/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.
+
+>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 printf '2
+'
+
+redo
+<a read -r a1
+<b read -r b1
+<c read -r c1
+
+ood1=$(redo-ood)
+
+>c printf '3
+'
+<c read -r c2
+
+ood2=$(redo-ood)
+
+test 0 -eq "${a1}"
+test 1 -eq "${b1}"
+test 2 -eq "${c1}"
+test 3 -eq "${c2}"
+
+test -z "${ood1}"
+test -n "${ood2}"
+
+. ../stat_inode.rc
+
+inode_a=$(stat_inode a)
+inode_b=$(stat_inode b)
+inodes_ood=$(stat_inode ${ood2})
+
+case "${inodes_ood}" in
+ *"${inode_a}"*)
+ ;;
+ *)
+  exit 1
+ ;;
+esac
+
+case "${inodes_ood}" in
+ *"${inode_b}"*)
+ ;;
+ *)
+  exit 1
+ ;;
+esac
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
diff --git a/t/redo-sh.tests/stat_inode.rc b/t/redo-sh.tests/stat_inode.rc
new file mode 100644 (file)
index 0000000..780aaf2
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+stat_inode() {
+    perl -le 'foreach (@ARGV) { @s=stat($_); print $s[1] }'
+}
diff --git a/t/redosh-ood_1.t b/t/redosh-ood_1.t
new file mode 120000 (symlink)
index 0000000..3f2c214
--- /dev/null
@@ -0,0 +1 @@
+redo-sh.tests/wrapper.rc
\ No newline at end of file
diff --git a/t/redosh-ood_2.t b/t/redosh-ood_2.t
new file mode 120000 (symlink)
index 0000000..3f2c214
--- /dev/null
@@ -0,0 +1 @@
+redo-sh.tests/wrapper.rc
\ No newline at end of file
diff --git a/t/redosh-ood_3.t b/t/redosh-ood_3.t
new file mode 120000 (symlink)
index 0000000..3f2c214
--- /dev/null
@@ -0,0 +1 @@
+redo-sh.tests/wrapper.rc
\ No newline at end of file