From: Sergey Matveev Date: Tue, 15 Dec 2020 11:10:09 +0000 (+0300) Subject: Import tests from apenwarr/redo and redo.sh X-Git-Tag: v0.6.0^0 X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=commitdiff_plain;h=a6510ac6225a3a93df9d27dc316a3c1c0fcde426 Import tests from apenwarr/redo and redo.sh --- diff --git a/README b/README index 0cb969a..7aaf437 100644 --- a/README +++ b/README @@ -9,6 +9,9 @@ apenwarr/redo (https://redo.readthedocs.io/en/latest/) were also implemented. Why yet another implementation? It is feature full and has better performance comparing to shell and Python implementation. +It passes tests from dieweltistgarnichtso.net's redo-sh.tests and +implementation-neutral from apenwarr/redo. + goredo is free software: see the file COPYING for copying conditions. Home page: http://www.goredo.cypherpunks.ru/ @@ -25,7 +28,7 @@ problems with the authenticity on your side, then build it manually: > $ git clone git://git.cypherpunks.ru/goredo.git $ cd goredo - $ git tag -v v0.5.0 + $ git tag -v v0.6.0 $ git clone git://git.cypherpunks.ru/gorecfile.git $ ( cd gorecfile ; git tag -v v0.3.0 ) $ echo "replace go.cypherpunks.ru/recfile => `pwd`/gorecfile" >> go.mod @@ -46,7 +49,10 @@ NOTES *goredo-notes* $REDO_TOP_DIR environment variable, or by having .redo/top file in it * target's completion messages are written after they finish * executable .do is run as is, non-executable is run with /bin/sh -e[x] -* tracing (-x) can be done only for non-executable .do +* tracing (-x) can be obviously done only for non-executable .do +* parallizable build is done only during redo-ifchange for human + convenience: you can globally enable REDO_JOBS, but still do for + example: redo htmls infos index upload FEATURES *goredo-features* diff --git a/t/.gitignore b/t/.gitignore deleted file mode 100644 index 141f812..0000000 --- a/t/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/*.t diff --git a/t/apenwarr-000-set-minus-e.t b/t/apenwarr-000-set-minus-e.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-000-set-minus-e.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-010-jobserver.t b/t/apenwarr-010-jobserver.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-010-jobserver.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-100-args.t b/t/apenwarr-100-args.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-100-args.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-101-atime.t b/t/apenwarr-101-atime.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-101-atime.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-102-empty.t b/t/apenwarr-102-empty.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-102-empty.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-103-unicode.t b/t/apenwarr-103-unicode.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-103-unicode.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-104-space.t b/t/apenwarr-104-space.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-104-space.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-105-sympath.t b/t/apenwarr-105-sympath.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-105-sympath.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-110-compile.t b/t/apenwarr-110-compile.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-110-compile.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-111-example.t b/t/apenwarr-111-example.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-111-example.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-120-defaults-flat.t b/t/apenwarr-120-defaults-flat.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-120-defaults-flat.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-121-defaults-nested.t b/t/apenwarr-121-defaults-nested.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-121-defaults-nested.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-122-defaults-parent.t b/t/apenwarr-122-defaults-parent.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-122-defaults-parent.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr-130-mode.t b/t/apenwarr-130-mode.t new file mode 120000 index 0000000..5f1044b --- /dev/null +++ b/t/apenwarr-130-mode.t @@ -0,0 +1 @@ +apenwarr/wrapper.rc \ No newline at end of file diff --git a/t/apenwarr/000-set-minus-e/.gitignore b/t/apenwarr/000-set-minus-e/.gitignore new file mode 100644 index 0000000..6bfe6b1 --- /dev/null +++ b/t/apenwarr/000-set-minus-e/.gitignore @@ -0,0 +1 @@ +log diff --git a/t/apenwarr/000-set-minus-e/all.do b/t/apenwarr/000-set-minus-e/all.do new file mode 100644 index 0000000..fb4b182 --- /dev/null +++ b/t/apenwarr/000-set-minus-e/all.do @@ -0,0 +1,4 @@ +rm -f log +redo fatal >/dev/null 2>&1 || true + +[ "$(cat log)" = "ok" ] || exit 5 diff --git a/t/apenwarr/000-set-minus-e/clean.do b/t/apenwarr/000-set-minus-e/clean.do new file mode 100644 index 0000000..4676c2d --- /dev/null +++ b/t/apenwarr/000-set-minus-e/clean.do @@ -0,0 +1 @@ +rm -f log *~ .*~ diff --git a/t/apenwarr/000-set-minus-e/fatal.do b/t/apenwarr/000-set-minus-e/fatal.do new file mode 100644 index 0000000..b4037c7 --- /dev/null +++ b/t/apenwarr/000-set-minus-e/fatal.do @@ -0,0 +1,4 @@ +rm -f log +echo ok >>log +this-should-cause-a-fatal-error +echo fail >>log # this line should never run diff --git a/t/apenwarr/010-jobserver/.gitignore b/t/apenwarr/010-jobserver/.gitignore new file mode 100644 index 0000000..7430e1d --- /dev/null +++ b/t/apenwarr/010-jobserver/.gitignore @@ -0,0 +1,6 @@ +*.end +*.start +*.sub +*.spin +*.log +*.x diff --git a/t/apenwarr/010-jobserver/all.do b/t/apenwarr/010-jobserver/all.do new file mode 100644 index 0000000..aae44d4 --- /dev/null +++ b/t/apenwarr/010-jobserver/all.do @@ -0,0 +1,5 @@ +# We put the -j options at this toplevel to detect an earlier bug +# where the sub-jobserver wasn't inherited by sub-sub-processes, which +# accidentally reverted to the parent jobserver instead. + +redo -j 1 serialtest diff --git a/t/apenwarr/010-jobserver/clean.do b/t/apenwarr/010-jobserver/clean.do new file mode 100644 index 0000000..80aa8ab --- /dev/null +++ b/t/apenwarr/010-jobserver/clean.do @@ -0,0 +1,2 @@ +rm -f *~ .*~ *.log *.sub *.spin *.x *.start *.end \ + first second parallel parallel2 diff --git a/t/apenwarr/010-jobserver/default.spin.do b/t/apenwarr/010-jobserver/default.spin.do new file mode 100644 index 0000000..293f924 --- /dev/null +++ b/t/apenwarr/010-jobserver/default.spin.do @@ -0,0 +1,4 @@ +for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do + redo $2.$d.x +done +echo hello diff --git a/t/apenwarr/010-jobserver/default.x.do b/t/apenwarr/010-jobserver/default.x.do new file mode 100644 index 0000000..4662694 --- /dev/null +++ b/t/apenwarr/010-jobserver/default.x.do @@ -0,0 +1 @@ +echo world diff --git a/t/apenwarr/010-jobserver/first.do b/t/apenwarr/010-jobserver/first.do new file mode 100644 index 0000000..2835c19 --- /dev/null +++ b/t/apenwarr/010-jobserver/first.do @@ -0,0 +1,24 @@ +# in case we're (erroneously) running in parallel, give second.do some +# time to start but not finish. +echo 'first sleep' >&2 +sleep 1 + +# Because of --shuffle, we can't be sure if first or second ran first, but +# because all.do uses -j1, we *should* expect that if second ran first, it +# at least ran to completion before we ran at all. +if [ -e second.start ]; then + echo 'first: second already started before we did...' >&2 + [ -e second.end ] || exit 21 + echo 'first: ...and it finished as it should.' >&2 + # no sense continuing the test; can't test anything if second already + # ran. + exit 0 +fi +echo 'first: second has not started yet, good.' >&2 + +echo 'first spin' >&2 +redo 1.a.spin +[ -e 1.a.spin ] || exit 11 +echo 'first spin complete' >&2 + +! [ -e second.start ] || exit 22 diff --git a/t/apenwarr/010-jobserver/second.do b/t/apenwarr/010-jobserver/second.do new file mode 100644 index 0000000..de732b4 --- /dev/null +++ b/t/apenwarr/010-jobserver/second.do @@ -0,0 +1,8 @@ +rm -f $1.start $1.end +echo 'second start' >&2 +: >$1.start +redo 2.x +echo 'second sleep' >&2 +redo-ifchange first # wait until 'first' finishes, if it's running +echo 'second end' >&2 +: >$1.end diff --git a/t/apenwarr/010-jobserver/serialtest.do b/t/apenwarr/010-jobserver/serialtest.do new file mode 100644 index 0000000..b0cb5cf --- /dev/null +++ b/t/apenwarr/010-jobserver/serialtest.do @@ -0,0 +1,3 @@ +# Test that -j1 really serializes all sub-redo processes. +rm -f *.sub *.spin *.x first second *.start *.end +redo first second diff --git a/t/apenwarr/100-args/.gitignore b/t/apenwarr/100-args/.gitignore new file mode 100644 index 0000000..020cf06 --- /dev/null +++ b/t/apenwarr/100-args/.gitignore @@ -0,0 +1 @@ +passfail diff --git a/t/apenwarr/100-args/all.do b/t/apenwarr/100-args/all.do new file mode 100644 index 0000000..800400d --- /dev/null +++ b/t/apenwarr/100-args/all.do @@ -0,0 +1 @@ +redo test.args test2.args passfailtest noargs/run diff --git a/t/apenwarr/100-args/clean.do b/t/apenwarr/100-args/clean.do new file mode 100644 index 0000000..c9914e6 --- /dev/null +++ b/t/apenwarr/100-args/clean.do @@ -0,0 +1 @@ +rm -f passfail *~ .*~ */*~ */.*~ noargs/all diff --git a/t/apenwarr/100-args/default.args.do b/t/apenwarr/100-args/default.args.do new file mode 100644 index 0000000..a79a7da --- /dev/null +++ b/t/apenwarr/100-args/default.args.do @@ -0,0 +1,3 @@ +[ "$1" = "test.args" ] +[ "$2" = "test" ] +[ "$3" != "test.args" ] diff --git a/t/apenwarr/100-args/noargs/all.do b/t/apenwarr/100-args/noargs/all.do new file mode 100644 index 0000000..fa6c74c --- /dev/null +++ b/t/apenwarr/100-args/noargs/all.do @@ -0,0 +1 @@ +echo RAN >$3 diff --git a/t/apenwarr/100-args/noargs/run.do b/t/apenwarr/100-args/noargs/run.do new file mode 100644 index 0000000..f365ebf --- /dev/null +++ b/t/apenwarr/100-args/noargs/run.do @@ -0,0 +1,3 @@ +rm -f all +redo-ifchange # should not default to 'all' since not running from top level +[ ! -e all ] || exit 11 diff --git a/t/apenwarr/100-args/passfail.do b/t/apenwarr/100-args/passfail.do new file mode 100644 index 0000000..4042930 --- /dev/null +++ b/t/apenwarr/100-args/passfail.do @@ -0,0 +1,6 @@ +echo $$ +if [ -e pleasefail ]; then + exit 1 +else + exit 0 +fi diff --git a/t/apenwarr/100-args/passfailtest.do b/t/apenwarr/100-args/passfailtest.do new file mode 100644 index 0000000..52bb0e9 --- /dev/null +++ b/t/apenwarr/100-args/passfailtest.do @@ -0,0 +1,13 @@ +rm -f pleasefail +redo passfail +[ -e passfail ] || exit 42 +PF1=$(cat passfail) +touch pleasefail +redo passfail 2>/dev/null && exit 43 +[ -e passfail ] || exit 44 +PF2=$(cat passfail) +[ "$PF1" = "$PF2" ] || exit 45 +rm -f pleasefail +redo passfail || exit 46 +PF3=$(cat passfail) +[ "$PF1" != "$PF3" ] || exit 47 diff --git a/t/apenwarr/100-args/test2.args.do b/t/apenwarr/100-args/test2.args.do new file mode 100644 index 0000000..1f136fb --- /dev/null +++ b/t/apenwarr/100-args/test2.args.do @@ -0,0 +1,3 @@ +[ "$1" = "test2.args" ] +[ "$2" = "test2.args" ] +[ "$3" != "test2.args" ] diff --git a/t/apenwarr/101-atime/.gitignore b/t/apenwarr/101-atime/.gitignore new file mode 100644 index 0000000..ec08e49 --- /dev/null +++ b/t/apenwarr/101-atime/.gitignore @@ -0,0 +1 @@ +atime2 diff --git a/t/apenwarr/101-atime/all.do b/t/apenwarr/101-atime/all.do new file mode 100644 index 0000000..082ab7a --- /dev/null +++ b/t/apenwarr/101-atime/all.do @@ -0,0 +1 @@ +redo atime diff --git a/t/apenwarr/101-atime/atime.do b/t/apenwarr/101-atime/atime.do new file mode 100644 index 0000000..3543ae1 --- /dev/null +++ b/t/apenwarr/101-atime/atime.do @@ -0,0 +1 @@ +redo atime2 diff --git a/t/apenwarr/101-atime/atime2.do b/t/apenwarr/101-atime/atime2.do new file mode 100644 index 0000000..f77931e --- /dev/null +++ b/t/apenwarr/101-atime/atime2.do @@ -0,0 +1,6 @@ +# make sure redo doesn't think merely *reading* the old file counts as +# modifying it in-place. +cat $1 >/dev/null 2>/dev/null || true +${PYTHON:-python} tick.py +cat $1 >/dev/null 2>/dev/null || true +echo hello diff --git a/t/apenwarr/101-atime/clean.do b/t/apenwarr/101-atime/clean.do new file mode 100644 index 0000000..0e3ea5a --- /dev/null +++ b/t/apenwarr/101-atime/clean.do @@ -0,0 +1 @@ +rm -f atime2 *~ .*~ diff --git a/t/apenwarr/101-atime/tick.py b/t/apenwarr/101-atime/tick.py new file mode 100644 index 0000000..04a0b04 --- /dev/null +++ b/t/apenwarr/101-atime/tick.py @@ -0,0 +1,6 @@ +import time +t2 = int(time.time()) + 1.0 +while 1: + t = time.time() + if t >= t2: break + time.sleep(t2 - t + 0.01) diff --git a/t/apenwarr/102-empty/.gitignore b/t/apenwarr/102-empty/.gitignore new file mode 100644 index 0000000..4cc290b --- /dev/null +++ b/t/apenwarr/102-empty/.gitignore @@ -0,0 +1,3 @@ +touch1 +silence +silence.do diff --git a/t/apenwarr/102-empty/all.do b/t/apenwarr/102-empty/all.do new file mode 100644 index 0000000..6404c98 --- /dev/null +++ b/t/apenwarr/102-empty/all.do @@ -0,0 +1 @@ +redo silencetest touchtest blank diff --git a/t/apenwarr/102-empty/blank.do b/t/apenwarr/102-empty/blank.do new file mode 100644 index 0000000..d4c3b3f --- /dev/null +++ b/t/apenwarr/102-empty/blank.do @@ -0,0 +1,3 @@ +redo-ifchange +redo-ifcreate +redo diff --git a/t/apenwarr/102-empty/clean.do b/t/apenwarr/102-empty/clean.do new file mode 100644 index 0000000..ec65690 --- /dev/null +++ b/t/apenwarr/102-empty/clean.do @@ -0,0 +1 @@ +rm -f touch1 touch1-ran *~ .*~ silence.do diff --git a/t/apenwarr/102-empty/silencetest.do b/t/apenwarr/102-empty/silencetest.do new file mode 100644 index 0000000..78bdc0a --- /dev/null +++ b/t/apenwarr/102-empty/silencetest.do @@ -0,0 +1,11 @@ +# This may have been leftover from a previous run, when switching +# between "real" redo and minimal/do, so clean it up. +rm -f silence + +echo 'echo hello' >silence.do +redo silence +[ -e silence ] || exit 55 +echo 'true' >silence.do +redo silence +[ ! -e silence ] || exit 66 +rm -f silence.do diff --git a/t/apenwarr/102-empty/touchtest.do b/t/apenwarr/102-empty/touchtest.do new file mode 100644 index 0000000..2f3d5ca --- /dev/null +++ b/t/apenwarr/102-empty/touchtest.do @@ -0,0 +1,41 @@ +# This may have been leftover from a previous run, when switching +# between "real" redo and minimal/do, so clean it up. +rm -f touch1 + +# simply create touch1 +echo 'echo hello' >touch1.do +redo touch1 +[ -e touch1 ] || exit 55 +[ "$(cat touch1)" = "hello" ] || exit 56 + +# ensure that 'redo touch1' always re-runs touch1.do even if we have +# already built touch1 in this session, and even if touch1 already exists. +echo 'echo hello2' >touch1.do +redo touch1 +[ "$(cat touch1)" = "hello2" ] || exit 57 + +# ensure that touch1 is rebuilt even if it got deleted after the last redo +# inside the same session. Also ensure that we can produce a zero-byte +# output file explicitly. +rm -f touch1 +echo 'touch $3' >touch1.do +redo touch1 +[ -e touch1 ] || exit 66 +[ -z "$(cat touch1)" ] || exit 67 + +# Also test that zero bytes of output does not create the file at all, as +# opposed to creating a zero-byte file. +rm -f touch1 +echo 'touch touch1-ran' >touch1.do +redo touch1 +[ -e touch1 ] && exit 75 +[ -e touch1-ran ] || exit 76 +rm -f touch1-ran + +# Make sure that redo-ifchange *won't* rebuild touch1 if we have already +# built it, even if building it did not produce an output file. +redo-ifchange touch1 +[ -e touch1 ] && exit 77 +[ -e touch1-ran ] && exit 78 + +rm -f touch1.do diff --git a/t/apenwarr/103-unicode/all.do b/t/apenwarr/103-unicode/all.do new file mode 100644 index 0000000..e76c907 --- /dev/null +++ b/t/apenwarr/103-unicode/all.do @@ -0,0 +1 @@ +redo unicode diff --git a/t/apenwarr/103-unicode/clean.do b/t/apenwarr/103-unicode/clean.do new file mode 100644 index 0000000..25762fa --- /dev/null +++ b/t/apenwarr/103-unicode/clean.do @@ -0,0 +1 @@ +rm -rf *.tmp diff --git a/t/apenwarr/103-unicode/unicode.do b/t/apenwarr/103-unicode/unicode.do new file mode 100644 index 0000000..9297114 --- /dev/null +++ b/t/apenwarr/103-unicode/unicode.do @@ -0,0 +1,16 @@ +# Test that redo can handle a script whose path contains non-ASCII characters. +# Note: the test directory is intentionally *not* a normalized unicode +# string, ie. filesystems like macOS will convert it to a different string +# at creation time. This tests weird normalization edge cases. +# +# Unfortunately, on macOS with APFS, it may helpfully normalize the path at +# *create* time, but not on future *open* attempts. Thus, we let the shell +# figure out what directory name actually got created, then pass that to redo. +# Hence the weird wildcard expansion loop. +rm -rf test-uni*.tmp +mkdir "test-uniçøðë.tmp" +for p in test-uni*.tmp; do + : >$p/test1.do + redo "$p/test1" +done + diff --git a/t/apenwarr/104-space/all.do b/t/apenwarr/104-space/all.do new file mode 100644 index 0000000..c5c576a --- /dev/null +++ b/t/apenwarr/104-space/all.do @@ -0,0 +1 @@ +redo "space dir/test" diff --git a/t/apenwarr/104-space/clean.do b/t/apenwarr/104-space/clean.do new file mode 100644 index 0000000..b5cfeff --- /dev/null +++ b/t/apenwarr/104-space/clean.do @@ -0,0 +1 @@ +redo "space dir/clean" diff --git a/t/apenwarr/104-space/space dir/.gitignore b/t/apenwarr/104-space/space dir/.gitignore new file mode 100644 index 0000000..342e2be --- /dev/null +++ b/t/apenwarr/104-space/space dir/.gitignore @@ -0,0 +1,2 @@ +/space file +/space 2 diff --git a/t/apenwarr/104-space/space dir/clean.do b/t/apenwarr/104-space/space dir/clean.do new file mode 100644 index 0000000..0cab67d --- /dev/null +++ b/t/apenwarr/104-space/space dir/clean.do @@ -0,0 +1 @@ +rm -f *~ .*~ "space 2" diff --git a/t/apenwarr/104-space/space dir/space 2.do b/t/apenwarr/104-space/space dir/space 2.do new file mode 100644 index 0000000..5c73747 --- /dev/null +++ b/t/apenwarr/104-space/space dir/space 2.do @@ -0,0 +1 @@ +echo $$ diff --git a/t/apenwarr/104-space/space dir/space file.do b/t/apenwarr/104-space/space dir/space file.do new file mode 100644 index 0000000..b683e8a --- /dev/null +++ b/t/apenwarr/104-space/space dir/space file.do @@ -0,0 +1 @@ +redo-ifchange "space 2" diff --git a/t/apenwarr/104-space/space dir/test.do b/t/apenwarr/104-space/space dir/test.do new file mode 100644 index 0000000..923444e --- /dev/null +++ b/t/apenwarr/104-space/space dir/test.do @@ -0,0 +1,6 @@ +redo "space file" +F1="$(cat "space 2")" +redo "../space dir/space file" +F2="$(cat "space 2")" +[ "$F1" = "$F2" ] || exit 2 +[ -n "$F1" ] || exit 3 diff --git a/t/apenwarr/105-sympath/.gitignore b/t/apenwarr/105-sympath/.gitignore new file mode 100644 index 0000000..ad4ad3e --- /dev/null +++ b/t/apenwarr/105-sympath/.gitignore @@ -0,0 +1,5 @@ +/*.dyn +/src +/x +/y + diff --git a/t/apenwarr/105-sympath/all.do b/t/apenwarr/105-sympath/all.do new file mode 100644 index 0000000..7def58d --- /dev/null +++ b/t/apenwarr/105-sympath/all.do @@ -0,0 +1,26 @@ +rm -f src +: >src + +for iter in 10 20; do + rm -rf y + rm -f x *.dyn static + mkdir y + : >y/static + ln -s . y/x + + ( + cd y/x/x/x/x/x + IFS=$(printf '\n') + redo-ifchange static x/x/x/static $PWD/static \ + $(/bin/pwd)/static /etc/passwd + # goredo: that symlink path is not resolving even at OS level + # redo-ifchange $PWD/../static 2>/dev/null && exit 35 + redo-ifchange 1.dyn x/x/x/2.dyn $PWD/3.dyn \ + $PWD/../4.dyn $(/bin/pwd)/5.dyn + ) + [ -e y/1.dyn ] || exit $((iter + 1)) + [ -e y/2.dyn ] || exit $((iter + 2)) + [ -e y/3.dyn ] || exit $((iter + 3)) + # [ -e 4.dyn ] || exit $((iter + 4)) + [ -e y/5.dyn ] || exit $((iter + 5)) +done diff --git a/t/apenwarr/105-sympath/clean.do b/t/apenwarr/105-sympath/clean.do new file mode 100644 index 0000000..6b5d773 --- /dev/null +++ b/t/apenwarr/105-sympath/clean.do @@ -0,0 +1,2 @@ +rm -rf y +rm -f src x *.dyn *~ .*~ diff --git a/t/apenwarr/105-sympath/default.dyn.do b/t/apenwarr/105-sympath/default.dyn.do new file mode 100644 index 0000000..0afe756 --- /dev/null +++ b/t/apenwarr/105-sympath/default.dyn.do @@ -0,0 +1,2 @@ +redo-ifchange src +echo dynamic >$3 diff --git a/t/apenwarr/110-compile/.gitignore b/t/apenwarr/110-compile/.gitignore new file mode 100644 index 0000000..84e64ab --- /dev/null +++ b/t/apenwarr/110-compile/.gitignore @@ -0,0 +1,5 @@ +CC +LD +[yb]ellow +hello +*.o diff --git a/t/apenwarr/110-compile/CC.do b/t/apenwarr/110-compile/CC.do new file mode 100644 index 0000000..1f40b2e --- /dev/null +++ b/t/apenwarr/110-compile/CC.do @@ -0,0 +1,5 @@ +exec >$3 +cat <<-EOF + cc -Wall -o /dev/fd/1 -c "\$1" +EOF +chmod a+x $3 diff --git a/t/apenwarr/110-compile/LD.do b/t/apenwarr/110-compile/LD.do new file mode 100644 index 0000000..2dac2e9 --- /dev/null +++ b/t/apenwarr/110-compile/LD.do @@ -0,0 +1,7 @@ +exec >$3 +cat <<-EOF + OUT="\$1" + shift + cc -Wall -o "\$OUT" "\$@" +EOF +chmod a+x $3 diff --git a/t/apenwarr/110-compile/all.do b/t/apenwarr/110-compile/all.do new file mode 100644 index 0000000..1b1954a --- /dev/null +++ b/t/apenwarr/110-compile/all.do @@ -0,0 +1,6 @@ +if type cc >/dev/null 2>&1; then + redo-ifchange hello yellow bellow +else + echo "$0: No C compiler installed; skipping this test." >&2 + redo-ifcreate /usr/bin/cc +fi diff --git a/t/apenwarr/110-compile/bellow.do b/t/apenwarr/110-compile/bellow.do new file mode 100644 index 0000000..2d8ac7d --- /dev/null +++ b/t/apenwarr/110-compile/bellow.do @@ -0,0 +1,3 @@ +redo-ifchange LD yellow.o +./LD "$3" yellow.o +../sleep 2 diff --git a/t/apenwarr/110-compile/clean.do b/t/apenwarr/110-compile/clean.do new file mode 100644 index 0000000..13e374b --- /dev/null +++ b/t/apenwarr/110-compile/clean.do @@ -0,0 +1,3 @@ +rm -f hello [by]ellow *.o CC LD *~ .*~ + + diff --git a/t/apenwarr/110-compile/hello.c b/t/apenwarr/110-compile/hello.c new file mode 100644 index 0000000..76bb8fa --- /dev/null +++ b/t/apenwarr/110-compile/hello.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + printf("hello, world!\n"); + return 0; +} diff --git a/t/apenwarr/110-compile/hello.do b/t/apenwarr/110-compile/hello.do new file mode 100644 index 0000000..b5ef466 --- /dev/null +++ b/t/apenwarr/110-compile/hello.do @@ -0,0 +1,3 @@ +redo-ifchange LD hello.o +../sleep 1 +./LD "$3" hello.o diff --git a/t/apenwarr/110-compile/hello.o.do b/t/apenwarr/110-compile/hello.o.do new file mode 100644 index 0000000..7ab28a0 --- /dev/null +++ b/t/apenwarr/110-compile/hello.o.do @@ -0,0 +1,11 @@ +# This test is meant to confirm some basic redo functionality +# related to static files not in the build tree. But if your +# system doesn't happen to have stdio.h in the usual location, +# let's not explode just for that. +stdio=/usr/include/stdio.h +[ -e "$stdio" ] || stdio= + +redo-ifchange CC hello.c $stdio +redo-ifcreate stdio.h +../sleep 3 +./CC hello.c diff --git a/t/apenwarr/110-compile/yellow.do b/t/apenwarr/110-compile/yellow.do new file mode 100644 index 0000000..36609ff --- /dev/null +++ b/t/apenwarr/110-compile/yellow.do @@ -0,0 +1,3 @@ +redo-ifchange LD yellow.o +../sleep 1.5 +./LD "$3" yellow.o diff --git a/t/apenwarr/110-compile/yellow.o.do b/t/apenwarr/110-compile/yellow.o.do new file mode 100644 index 0000000..9b317b7 --- /dev/null +++ b/t/apenwarr/110-compile/yellow.o.do @@ -0,0 +1,3 @@ +redo-ifchange CC hello.c +../sleep 2 +cc -o $3 -c hello.c diff --git a/t/apenwarr/111-example/.gitignore b/t/apenwarr/111-example/.gitignore new file mode 100644 index 0000000..0d93ead --- /dev/null +++ b/t/apenwarr/111-example/.gitignore @@ -0,0 +1,3 @@ +*.o +CC +hello diff --git a/t/apenwarr/111-example/CC.do b/t/apenwarr/111-example/CC.do new file mode 100644 index 0000000..177fe41 --- /dev/null +++ b/t/apenwarr/111-example/CC.do @@ -0,0 +1,11 @@ +redo-ifchange config.sh +. ./config.sh +exec >$3 +cat <<-EOF + redo-ifchange \$2.c + cc $CFLAGS -MD -MF \$3.deps -o \$3 -c \$2.c + read DEPS <\$3.deps + rm -f \$3.deps + redo-ifchange \${DEPS#*:} +EOF +chmod +x $3 diff --git a/t/apenwarr/111-example/Makefile b/t/apenwarr/111-example/Makefile new file mode 100644 index 0000000..cf36535 --- /dev/null +++ b/t/apenwarr/111-example/Makefile @@ -0,0 +1,6 @@ +all: + +%: FORCE + +redo $@ + +.PHONY: FORCE diff --git a/t/apenwarr/111-example/all.do b/t/apenwarr/111-example/all.do new file mode 100644 index 0000000..14108cf --- /dev/null +++ b/t/apenwarr/111-example/all.do @@ -0,0 +1,6 @@ +if type cc >/dev/null 2>&1; then + redo-ifchange hello +else + echo "$0: No C compiler installed; skipping this test." >&2 + redo-ifcreate /usr/bin/cc +fi diff --git a/t/apenwarr/111-example/clean.do b/t/apenwarr/111-example/clean.do new file mode 100644 index 0000000..420393f --- /dev/null +++ b/t/apenwarr/111-example/clean.do @@ -0,0 +1 @@ +rm -f *.tmp *~ *.o hello CC diff --git a/t/apenwarr/111-example/config.sh b/t/apenwarr/111-example/config.sh new file mode 100644 index 0000000..f37d93a --- /dev/null +++ b/t/apenwarr/111-example/config.sh @@ -0,0 +1 @@ +CFLAGS="-Wall" diff --git a/t/apenwarr/111-example/default.o.do b/t/apenwarr/111-example/default.o.do new file mode 100644 index 0000000..d48bdd1 --- /dev/null +++ b/t/apenwarr/111-example/default.o.do @@ -0,0 +1,2 @@ +redo-ifchange CC +. ./CC "$@" diff --git a/t/apenwarr/111-example/hello.do b/t/apenwarr/111-example/hello.do new file mode 100644 index 0000000..db35184 --- /dev/null +++ b/t/apenwarr/111-example/hello.do @@ -0,0 +1,4 @@ +DEPS="main.o +mystr.o" +redo-ifchange $DEPS +cc -o $3 $DEPS diff --git a/t/apenwarr/111-example/main.c b/t/apenwarr/111-example/main.c new file mode 100644 index 0000000..35e746b --- /dev/null +++ b/t/apenwarr/111-example/main.c @@ -0,0 +1,8 @@ +#include +#include "mystr.h" + +int main() +{ + printf("%s\n", mystr); + return 0; +} diff --git a/t/apenwarr/111-example/mystr.c b/t/apenwarr/111-example/mystr.c new file mode 100644 index 0000000..b64b7a5 --- /dev/null +++ b/t/apenwarr/111-example/mystr.c @@ -0,0 +1,4 @@ + +#include "mystr.h" + +char *mystr = "Hello, world!"; diff --git a/t/apenwarr/111-example/mystr.h b/t/apenwarr/111-example/mystr.h new file mode 100644 index 0000000..1bf584e --- /dev/null +++ b/t/apenwarr/111-example/mystr.h @@ -0,0 +1,6 @@ +#ifndef __MYSTR_H +#define __MYSTR_H + +extern char *mystr; + +#endif diff --git a/t/apenwarr/120-defaults-flat/.gitignore b/t/apenwarr/120-defaults-flat/.gitignore new file mode 100644 index 0000000..580e8c9 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/.gitignore @@ -0,0 +1,6 @@ +c +c.c +c.c.c +c.c.c.b +c.c.c.b.b +d diff --git a/t/apenwarr/120-defaults-flat/all.do b/t/apenwarr/120-defaults-flat/all.do new file mode 100644 index 0000000..f5753c3 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/all.do @@ -0,0 +1 @@ +redo-ifchange c d diff --git a/t/apenwarr/120-defaults-flat/c.c.c.b.b.a b/t/apenwarr/120-defaults-flat/c.c.c.b.b.a new file mode 100644 index 0000000..4768c08 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/c.c.c.b.b.a @@ -0,0 +1 @@ +chicken diff --git a/t/apenwarr/120-defaults-flat/c.do b/t/apenwarr/120-defaults-flat/c.do new file mode 100644 index 0000000..3d6bd11 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/c.do @@ -0,0 +1,3 @@ +redo-ifchange $1.c +echo c.do +cat $1.c diff --git a/t/apenwarr/120-defaults-flat/clean.do b/t/apenwarr/120-defaults-flat/clean.do new file mode 100644 index 0000000..37c32b0 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/clean.do @@ -0,0 +1,2 @@ +rm -f c c.c c.c.c c.c.c.b c.c.c.b.b d \ + *~ .*~ diff --git a/t/apenwarr/120-defaults-flat/default.b.do b/t/apenwarr/120-defaults-flat/default.b.do new file mode 100644 index 0000000..b8c9b1e --- /dev/null +++ b/t/apenwarr/120-defaults-flat/default.b.do @@ -0,0 +1,10 @@ +if [ -e "$1.a" -o -e "default${1#$2}.a" ]; then + redo-ifchange "$1.a" + echo a-to-b + cat "$1.a" +else + redo-ifchange "$1.b" + echo b-to-b + cat "$1.b" +fi +../sleep 1.1 diff --git a/t/apenwarr/120-defaults-flat/default.c.c.do b/t/apenwarr/120-defaults-flat/default.c.c.do new file mode 100644 index 0000000..12798b4 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/default.c.c.do @@ -0,0 +1,4 @@ +redo-ifchange $1.b +echo b-to-cc +cat $1.b +../sleep 1.2 diff --git a/t/apenwarr/120-defaults-flat/default.c.do b/t/apenwarr/120-defaults-flat/default.c.do new file mode 100644 index 0000000..9fc8bd7 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/default.c.do @@ -0,0 +1,4 @@ +redo-ifchange $1.c +echo c-to-c +cat $1.c +../sleep 1.3 diff --git a/t/apenwarr/120-defaults-flat/default.do b/t/apenwarr/120-defaults-flat/default.do new file mode 100644 index 0000000..44aecf7 --- /dev/null +++ b/t/apenwarr/120-defaults-flat/default.do @@ -0,0 +1,4 @@ +redo-ifchange c +echo default-rule +cat c +../sleep 1.4 diff --git a/t/apenwarr/121-defaults-nested/.gitignore b/t/apenwarr/121-defaults-nested/.gitignore new file mode 100644 index 0000000..b656a9f --- /dev/null +++ b/t/apenwarr/121-defaults-nested/.gitignore @@ -0,0 +1,15 @@ +/a/b/file +/a/b/file.x.y.z +/a/b/file.y.z +/a/b/file.z +/a/d/file +/a/d/file.x.y.z +/a/d/file.y.z +/a/d/file.z +/a/file +/a/file.x.y.z +/a/file.y.z +/a/file.z +/file.x.y.z +/file.z +/file diff --git a/t/apenwarr/121-defaults-nested/a/b/default.y.z.do b/t/apenwarr/121-defaults-nested/a/b/default.y.z.do new file mode 100644 index 0000000..089cc26 --- /dev/null +++ b/t/apenwarr/121-defaults-nested/a/b/default.y.z.do @@ -0,0 +1 @@ +echo default.y.z $2 ${1#$2} diff --git a/t/apenwarr/121-defaults-nested/a/b/file.x.y.z.do b/t/apenwarr/121-defaults-nested/a/b/file.x.y.z.do new file mode 100644 index 0000000..88c5d06 --- /dev/null +++ b/t/apenwarr/121-defaults-nested/a/b/file.x.y.z.do @@ -0,0 +1 @@ +echo file $2 ${1#$2} diff --git a/t/apenwarr/121-defaults-nested/a/d/default.do b/t/apenwarr/121-defaults-nested/a/d/default.do new file mode 100644 index 0000000..4c10de0 --- /dev/null +++ b/t/apenwarr/121-defaults-nested/a/d/default.do @@ -0,0 +1 @@ +echo default $2 ${1#$2} diff --git a/t/apenwarr/121-defaults-nested/a/default.x.y.z.do b/t/apenwarr/121-defaults-nested/a/default.x.y.z.do new file mode 100644 index 0000000..d23f78e --- /dev/null +++ b/t/apenwarr/121-defaults-nested/a/default.x.y.z.do @@ -0,0 +1,2 @@ +echo default.x.y.z $2 ${1#$2} + diff --git a/t/apenwarr/121-defaults-nested/a/default.z.do b/t/apenwarr/121-defaults-nested/a/default.z.do new file mode 100644 index 0000000..2e01a30 --- /dev/null +++ b/t/apenwarr/121-defaults-nested/a/default.z.do @@ -0,0 +1 @@ +echo default.z $2 ${1#$2} diff --git a/t/apenwarr/121-defaults-nested/all.do b/t/apenwarr/121-defaults-nested/all.do new file mode 100644 index 0000000..7b789e5 --- /dev/null +++ b/t/apenwarr/121-defaults-nested/all.do @@ -0,0 +1 @@ +redo test diff --git a/t/apenwarr/121-defaults-nested/clean.do b/t/apenwarr/121-defaults-nested/clean.do new file mode 100644 index 0000000..e05aefb --- /dev/null +++ b/t/apenwarr/121-defaults-nested/clean.do @@ -0,0 +1,6 @@ +exec >&2 +find . -name '*~' -exec rm -f {} \; +rm -f a/b/file a/b/file.x.y.z a/b/file.y.z a/b/file.z \ + a/d/file a/d/file.x.y.z a/d/file.y.z a/d/file.z \ + a/file a/file.x.y.z a/file.y.z a/file.z \ + file.x.y.z file.z file diff --git a/t/apenwarr/121-defaults-nested/default.do b/t/apenwarr/121-defaults-nested/default.do new file mode 100644 index 0000000..dd206f9 --- /dev/null +++ b/t/apenwarr/121-defaults-nested/default.do @@ -0,0 +1 @@ +echo root $2 ${1#$2} "$(dirname $3)" diff --git a/t/apenwarr/121-defaults-nested/test.do b/t/apenwarr/121-defaults-nested/test.do new file mode 100644 index 0000000..7af2031 --- /dev/null +++ b/t/apenwarr/121-defaults-nested/test.do @@ -0,0 +1,36 @@ +exec >&2 +redo-ifchange \ + file.x.y.z file.z file \ + a/b/file.x.y.z a/b/file.y.z a/b/file.z a/b/file \ + a/d/file.x.y.z a/d/file.y.z a/d/file.z a/d/file + +(cd a/b && redo-ifchange ../file.x.y.z ../file.y.z ../file.z ../file) + +check() +{ + if [ "$(cat $1)" != "$2" ]; then + echo "$1 should contain '$2'" + echo " ...got '$(cat $1)'" + exit 44 + fi +} + +check file.x.y.z "root file.x.y.z ." +check file.z "root file.z ." +check file "root file ." + +check a/file.x.y.z "default.x.y.z file .x.y.z" +check a/file.y.z "default.z file.y .z" +check a/file.z "default.z file .z" +check a/file "root a/file a" + +check a/b/file.x.y.z "file file.x.y.z" +check a/b/file.y.z "default.y.z file .y.z" +check a/b/file.z "default.z b/file .z" +check a/b/file "root a/b/file a/b" + +check a/d/file.x.y.z "default file.x.y.z" +check a/d/file.y.z "default file.y.z" +check a/d/file.z "default file.z" +check a/d/file "default file" + diff --git a/t/apenwarr/122-defaults-parent/.gitignore b/t/apenwarr/122-defaults-parent/.gitignore new file mode 100644 index 0000000..50e1322 --- /dev/null +++ b/t/apenwarr/122-defaults-parent/.gitignore @@ -0,0 +1 @@ +/*.log diff --git a/t/apenwarr/122-defaults-parent/all.do b/t/apenwarr/122-defaults-parent/all.do new file mode 100644 index 0000000..917d634 --- /dev/null +++ b/t/apenwarr/122-defaults-parent/all.do @@ -0,0 +1,32 @@ +rm -f x/shouldfail + +log=$PWD/$1.log + +expect_fail() { + local rv=$1 + shift + if ("$@") >>$log 2>&1; then + cat "$log" >&2 + echo "unexpected success:" "$@" >&2 + return $rv + else + return 0 + fi +} + +# These should all fail because there is no matching .do file. +# In previous versions of redo, it would accidentally try to use +# $PWD/default.do even for ../path/file, which is incorrect. That +# could cause it to return success accidentally. + +rm -f "$log" +cd inner +expect_fail 11 redo ../x/shouldfail +expect_fail 12 redo-ifchange ../x/shouldfail + +rm -f "$log" +cd ../inner2 +expect_fail 21 redo ../x/shouldfail2 +expect_fail 22 redo-ifchange ../x/shouldfail2 + +exit 0 diff --git a/t/apenwarr/122-defaults-parent/clean.do b/t/apenwarr/122-defaults-parent/clean.do new file mode 100644 index 0000000..b877c59 --- /dev/null +++ b/t/apenwarr/122-defaults-parent/clean.do @@ -0,0 +1,2 @@ +rm -f *~ .*~ */*~ */.*~ *.tmp */*.tmp x/shouldfail *.log */*.log + diff --git a/t/apenwarr/122-defaults-parent/inner/default.do b/t/apenwarr/122-defaults-parent/inner/default.do new file mode 100644 index 0000000..f8283d1 --- /dev/null +++ b/t/apenwarr/122-defaults-parent/inner/default.do @@ -0,0 +1,2 @@ +echo "inner/default.do: PWD=$PWD '$1' '$2' '$3'" >&2 +echo SUSPICIOUS diff --git a/t/apenwarr/122-defaults-parent/inner2/default.do b/t/apenwarr/122-defaults-parent/inner2/default.do new file mode 100644 index 0000000..ee989e6 --- /dev/null +++ b/t/apenwarr/122-defaults-parent/inner2/default.do @@ -0,0 +1,2 @@ +echo "inner/default.do: PWD=$PWD '$1' '$2' '$3'" >&2 +# output file is left empty diff --git a/t/apenwarr/122-defaults-parent/x/file b/t/apenwarr/122-defaults-parent/x/file new file mode 100644 index 0000000..e69de29 diff --git a/t/apenwarr/130-mode/.gitignore b/t/apenwarr/130-mode/.gitignore new file mode 100644 index 0000000..64c1571 --- /dev/null +++ b/t/apenwarr/130-mode/.gitignore @@ -0,0 +1 @@ +mode1 \ No newline at end of file diff --git a/t/apenwarr/130-mode/all.do b/t/apenwarr/130-mode/all.do new file mode 100644 index 0000000..5e0fbe9 --- /dev/null +++ b/t/apenwarr/130-mode/all.do @@ -0,0 +1,5 @@ +umask 0022 +redo mode1 +MODE=$(${PYTHON:-python} -c \ + 'import os; print(oct(os.stat("mode1").st_mode & 0o7777))') +[ "$MODE" = "0644" -o "$MODE" = "0o644" ] || exit 78 diff --git a/t/apenwarr/130-mode/clean.do b/t/apenwarr/130-mode/clean.do new file mode 100644 index 0000000..defa28c --- /dev/null +++ b/t/apenwarr/130-mode/clean.do @@ -0,0 +1 @@ +rm -f mode1 *~ .*~ diff --git a/t/apenwarr/130-mode/mode1.do b/t/apenwarr/130-mode/mode1.do new file mode 100644 index 0000000..2f08be9 --- /dev/null +++ b/t/apenwarr/130-mode/mode1.do @@ -0,0 +1 @@ +echo hello diff --git a/t/apenwarr/README b/t/apenwarr/README new file mode 100644 index 0000000..ae5e7e0 --- /dev/null +++ b/t/apenwarr/README @@ -0,0 +1,13 @@ +Those tests are taken from https://github.com/apenwarr/redo. + +* Only basic ([01]*) tests taken, because other ones are too apenwarr + implementation specific. +* 140-shuffle and 141-keep-going removed, because apenwarr specific +* flush-cache removed, as it works directly with apenwarr's database +* redo/sh and redo/py targets replaced with /bin/sh and ${PYTHON} +* skip-if-minimal-do.sh removed +* 010-jobserver/parallel* removed, because goredo intentionally does not + parallelize targets building through plain redo invocation for human + convenience +* one of 105-sympath tests commented out, because its symlink path can + not be resolved even at OS level diff --git a/t/apenwarr/all.do b/t/apenwarr/all.do new file mode 100644 index 0000000..362d319 --- /dev/null +++ b/t/apenwarr/all.do @@ -0,0 +1,9 @@ +rm -f 000-set-minus-e/log +redo 000-set-minus-e/all +if [ "$(cat 000-set-minus-e/log)" != "ok" ]; then + echo "FATAL! .do file not run with 'set -e' in effect!" >&2 + exit 5 +fi + +/bin/ls 1[0-9][0-9]*/all.do | sed 's/\.do$//' | xargs redo +110-compile/hello >&2 diff --git a/t/apenwarr/clean.do b/t/apenwarr/clean.do new file mode 100644 index 0000000..ee6ed2b --- /dev/null +++ b/t/apenwarr/clean.do @@ -0,0 +1,3 @@ +/bin/ls [0-9s][0-9][0-9]*/clean.do | +sed 's/\.do$//' | +xargs redo diff --git a/t/apenwarr/sleep b/t/apenwarr/sleep new file mode 100755 index 0000000..7322c5a --- /dev/null +++ b/t/apenwarr/sleep @@ -0,0 +1,4 @@ +PATH=/bin:/usr/bin +if [ -n "$SLEEP" ]; then + exec sleep "$@" +fi diff --git a/t/apenwarr/wrapper.rc b/t/apenwarr/wrapper.rc new file mode 100755 index 0000000..724dc67 --- /dev/null +++ b/t/apenwarr/wrapper.rc @@ -0,0 +1,13 @@ +#!/bin/sh + +testname=`basename "$0"` +testname=${testname#apenwarr-} +testname=${testname%.t} +testdir=`dirname $0`/apenwarr/$testname +cd $testdir +testdir=`pwd` +test_description="none" +. $SHARNESS_TEST_SRCDIR/sharness.sh +cd $testdir +test_expect_success itself redo +test_done diff --git a/t/clean.do b/t/clean.do index 530bbbe..80f432d 100644 --- a/t/clean.do +++ b/t/clean.do @@ -1,5 +1,2 @@ -rm -f *.t -[ -e redo-sh.tests ] || exit 0 -cd redo-sh.tests/ -redo-cleanup full >&2 -find . -type f ! -name test -delete +redo apenwarr/clean redo-sh.tests/clean +for d in apenwarr redo-sh.tests ; do ( cd $d ; redo-cleanup full >/dev/null ) ; done diff --git a/t/prepare.do b/t/prepare.do deleted file mode 100644 index 1b94b48..0000000 --- a/t/prepare.do +++ /dev/null @@ -1,17 +0,0 @@ -tests=redo-sh.tests -[ -e $tests ] || { - cat >&2 <&2 -rm parallel_2.t diff --git a/t/redo-sh.tests/README b/t/redo-sh.tests/README new file mode 100644 index 0000000..08b4ae8 --- /dev/null +++ b/t/redo-sh.tests/README @@ -0,0 +1,3 @@ +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. diff --git a/t/redo-sh.tests/clean.do b/t/redo-sh.tests/clean.do new file mode 100644 index 0000000..dec6f7b --- /dev/null +++ b/t/redo-sh.tests/clean.do @@ -0,0 +1,4 @@ +for f in * ; do + [ -d $f ] || continue + find $f ! -name test -delete +done 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 index 0000000..f89d2f4 --- /dev/null +++ b/t/redo-sh.tests/dependency_ne_dofile_1/test @@ -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 <"${dofile}" cat <&2 printf 'a.b.c was built with %s, should have been built with %s\n' \ + "${text}" "${dofile}" + exit 1 + fi +done diff --git a/t/redo-sh.tests/dependency_ne_dofile_2/test b/t/redo-sh.tests/dependency_ne_dofile_2/test new file mode 100755 index 0000000..c55e1e9 --- /dev/null +++ b/t/redo-sh.tests/dependency_ne_dofile_2/test @@ -0,0 +1,42 @@ +#!/bin/sh -eu +# A target built with a default dofile in the parent directory must be rebuilt if a more specific dofile appears. + +[ -e dir ] \ + || mkdir dir + +[ -e default.do ] \ + && rm default.do + +[ -e dir/default.do ] \ + && rm dir/default.do + +[ -e dir/a.do ] \ + && rm dir/a.do + +>default.do cat <dir/default.do cat <dir/a.do cat <all.do printf 'redo-ifchange a\n' +>a.do printf 'test -e b || redo-ifcreate b\ndate +%s\n' + +redo +all.do printf 'redo-ifchange a\n' +>a.do printf 'test -e b || redo-ifcreate b\ndate +%s\n' + +redo +b : +sleep 1 + +redo +all.do printf 'redo-ifchange a\n' +>a.do printf 'redo-ifchange b\ndate +%s\n' +>b printf '1' + +redo +b printf '1' + +redo +all.do printf 'redo-ifchange a\n' +>a.do printf 'redo-ifchange b\ndate +%s\n' +>b.do printf 'redo-ifchange c\ndate +%s\n' +>c printf '1' + +redo +c printf '1' + +redo +all.do printf 'redo-ifchange a\n' +>a.do printf 'redo-ifchange b\ndate +%s\n' +>b.do printf 'redo-ifchange c\ndate +%s\n' +>c.do printf 'redo-ifchange d\ndate +%s\n' +>d printf '1' + +redo +d printf '1' + +redo +all.do printf 'redo-ifchange a\n' +>a.do printf 'redo-ifchange b\ndate +%s\n' +>b printf '1' + +redo +b printf '2' + +redo +all.do printf 'redo-ifchange a\n' +>a.do printf 'redo-ifchange b\ndate +%s\n' +>b.do printf 'redo-ifchange c\ndate +%s\n' +>c printf '1' + +redo +c printf '2' + +redo +all.do printf 'redo-ifchange a\n' +>a.do printf 'redo-ifchange b\ndate +%s\n' +>b.do printf 'redo-ifchange c\ndate +%s\n' +>c.do printf 'redo-ifchange d\ndate +%s\n' +>d printf '1' + +redo +d printf '2' + +redo +a.do.do cat <a.do.do.do cat <all.do cat <default.do cat <"${dofile}" cat <&2 printf 'redo-whichdo prints %s as nonexistent dofile, but it exists.\n' \ + "${whichdo_dofile_nonexistent}" + exit 1 + fi + done + + whichdo_dofile_existent=$( + printf '%s\n' "${whichdo_dofiles}" \ + |tail -n1 + ) + if ! test -e "${whichdo_dofile_existent}"; then + >&2 printf 'redo-whichdo prints %s as existent dofile, but it does not exist.\n' \ + "${whichdo_dofile_existent}" + exit 1 + fi + +done diff --git a/t/redo-sh.tests/whichdo_absolute_2/test b/t/redo-sh.tests/whichdo_absolute_2/test new file mode 100755 index 0000000..2d240b2 --- /dev/null +++ b/t/redo-sh.tests/whichdo_absolute_2/test @@ -0,0 +1,50 @@ +#!/bin/sh -eu +# When invoked with an absolute path name as an argument, redo-whichdo +# must output non-existent dofiles in the parent directory and the +# same directory until it outputs one that exists. + +if ! test -d a; then + mkdir a +fi + +dofiles="default.do default.c.do default.b.c.do a/default.do a/default.c.do a/default.b.c.do a/a.b.c.do" + +for dofile in ${dofiles}; do + if test -e "${dofile}"; then + rm -- "${dofile}" + fi +done + +for dofile in ${dofiles}; do + >"${dofile}" cat <&2 printf 'redo-whichdo prints %s as nonexistent dofile, but it exists.\n' \ + "${whichdo_dofile_nonexistent}" + exit 1 + fi + done + + whichdo_dofile_existent=$( + printf '%s\n' "${whichdo_dofiles}" \ + |tail -n1 + ) + if ! test -e "${whichdo_dofile_existent}"; then + >&2 printf 'redo-whichdo prints %s as existent dofile, but it does not exist.\n' \ + "${whichdo_dofile_existent}" + exit 1 + fi + +done diff --git a/t/redo-sh.tests/whichdo_absolute_default_1/test b/t/redo-sh.tests/whichdo_absolute_default_1/test new file mode 100755 index 0000000..ed34483 --- /dev/null +++ b/t/redo-sh.tests/whichdo_absolute_default_1/test @@ -0,0 +1,22 @@ +#!/bin/sh -eu +# When invoked with an absolute path name with the prefix “default” as +# an argument, redo-whichdo must not output any dofile filename twice. + +default_files="default default.a default.a.b default.do default.a.do default.a.b.do" + +for default_file in ${default_files}; do + whichdo_dofiles_duplicates=$( + redo-whichdo "${PWD}/${default_file}" \ + |tr '\0' '\n' \ + |sort \ + |uniq -d + ) + case "${whichdo_dofiles_duplicates}" in + '') + ;; + *) + >&2 printf 'redo-whichdo duplicate output: %s \n' ${whichdo_dofiles_duplicates} + exit 1 + ;; + esac +done diff --git a/t/redo-sh.tests/whichdo_absolute_default_2/test b/t/redo-sh.tests/whichdo_absolute_default_2/test new file mode 100755 index 0000000..9b4024f --- /dev/null +++ b/t/redo-sh.tests/whichdo_absolute_default_2/test @@ -0,0 +1,21 @@ +#!/bin/sh -eu +# When invoked with an absolute filename for the file “default.do” as +# an argument, redo-whichdo must not output that filename as possible +# dofile. + +default_dofile="${PWD}/default.do" + +whichdo_dofiles=$( + redo-whichdo "${default_dofile}" \ + |tr '\0' '\n' +) + +for whichdo_dofile in ${whichdo_dofiles}; do + case "${whichdo_dofile}" in + "${default_dofile}") + >&2 printf 'redo-whichdo outputs that this file is its own dofile: %s\n' \ + "${whichdo_dofile}" + exit 1 + ;; + esac +done diff --git a/t/redo-sh.tests/whichdo_relative_1/test b/t/redo-sh.tests/whichdo_relative_1/test new file mode 100755 index 0000000..b47924b --- /dev/null +++ b/t/redo-sh.tests/whichdo_relative_1/test @@ -0,0 +1,46 @@ +#!/bin/sh -eu +# When invoked with a relative path name as an argument, redo-whichdo +# must output non-existent dofiles in the same directory until it +# outputs one that exists. + +dofiles="default.do default.c.do default.b.c.do a.b.c.do" + +for dofile in ${dofiles}; do + if test -e "${dofile}"; then + rm -- "${dofile}" + fi +done + +for dofile in ${dofiles}; do + >"${dofile}" cat <&2 printf 'redo-whichdo prints %s as nonexistent dofile, but it exists.\n' \ + "${whichdo_dofile_nonexistent}" + exit 1 + fi + done + + whichdo_dofile_existent=$( + printf '%s\n' "${whichdo_dofiles}" \ + |tail -n1 + ) + if ! test -e "${whichdo_dofile_existent}"; then + >&2 printf 'redo-whichdo prints %s as existent dofile, but it does not exist.\n' \ + "${whichdo_dofile_existent}" + exit 1 + fi + +done diff --git a/t/redo-sh.tests/whichdo_relative_2/test b/t/redo-sh.tests/whichdo_relative_2/test new file mode 100755 index 0000000..424da5d --- /dev/null +++ b/t/redo-sh.tests/whichdo_relative_2/test @@ -0,0 +1,50 @@ +#!/bin/sh -eu +# When invoked with a relative path name as an argument, redo-whichdo +# must output non-existent dofiles in the parent directory and the +# same directory until it outputs one that exists. + +if ! test -d a; then + mkdir a +fi + +dofiles="default.do default.c.do default.b.c.do a/default.do a/default.c.do a/default.b.c.do a/a.b.c.do" + +for dofile in ${dofiles}; do + if test -e "${dofile}"; then + rm -- "${dofile}" + fi +done + +for dofile in ${dofiles}; do + >"${dofile}" cat <&2 printf 'redo-whichdo prints %s as nonexistent dofile, but it exists.\n' \ + "${whichdo_dofile_nonexistent}" + exit 1 + fi + done + + whichdo_dofile_existent=$( + printf '%s\n' "${whichdo_dofiles}" \ + |tail -n1 + ) + if ! test -e "${whichdo_dofile_existent}"; then + >&2 printf 'redo-whichdo prints %s as existent dofile, but it does not exist.\n' \ + "${whichdo_dofile_existent}" + exit 1 + fi + +done diff --git a/t/redo-sh.tests/whichdo_relative_default_1/test b/t/redo-sh.tests/whichdo_relative_default_1/test new file mode 100755 index 0000000..9ef5597 --- /dev/null +++ b/t/redo-sh.tests/whichdo_relative_default_1/test @@ -0,0 +1,22 @@ +#!/bin/sh -eu +# When invoked with a relative path name with the prefix “default” as +# an argument, redo-whichdo must not output any dofile filename twice. + +default_files="default default.a default.a.b default.do default.a.do default.a.b.do" + +for default_file in ${default_files}; do + whichdo_dofiles_duplicates=$( + redo-whichdo "${default_file}" \ + |tr '\0' '\n' \ + |sort \ + |uniq -d + ) + case "${whichdo_dofiles_duplicates}" in + '') + ;; + *) + >&2 printf 'redo-whichdo duplicate output: %s \n' ${whichdo_dofiles_duplicates} + exit 1 + ;; + esac +done 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 index 0000000..385cf5f --- /dev/null +++ b/t/redo-sh.tests/whichdo_relative_default_2/test @@ -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 diff --git a/t/runner.rc b/t/redo-sh.tests/wrapper.rc similarity index 60% rename from t/runner.rc rename to t/redo-sh.tests/wrapper.rc index b51d15d..092d588 100755 --- a/t/runner.rc +++ b/t/redo-sh.tests/wrapper.rc @@ -1,6 +1,9 @@ #!/bin/sh -testdir=`dirname $0`/redo-sh.tests/`basename "${0%.t}"` +testname=`basename "$0"` +testname=${testname#redosh-} +testname=${testname%.t} +testdir=`dirname $0`/redo-sh.tests/$testname cd $testdir testdir=`pwd` test_description="`sed -n '2,/^$/p' test | sed 's/# //'`" diff --git a/t/redosh-dependency_ne_dofile_1.t b/t/redosh-dependency_ne_dofile_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_ne_dofile_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_ne_dofile_2.t b/t/redosh-dependency_ne_dofile_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_ne_dofile_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_ne_nobuild_1.t b/t/redosh-dependency_ne_nobuild_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_ne_nobuild_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_ne_rebuild_1.t b/t/redosh-dependency_ne_rebuild_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_ne_rebuild_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_nobuild_1.t b/t/redosh-dependency_nobuild_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_nobuild_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_nobuild_2.t b/t/redosh-dependency_nobuild_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_nobuild_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_nobuild_3.t b/t/redosh-dependency_nobuild_3.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_nobuild_3.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_rebuild_1.t b/t/redosh-dependency_rebuild_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_rebuild_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_rebuild_2.t b/t/redosh-dependency_rebuild_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_rebuild_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dependency_rebuild_3.t b/t/redosh-dependency_rebuild_3.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dependency_rebuild_3.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dofile_generated_1.t b/t/redosh-dofile_generated_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dofile_generated_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-dofile_generated_2.t b/t/redosh-dofile_generated_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-dofile_generated_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-parallel_1.t b/t/redosh-parallel_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-parallel_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_absolute_1.t b/t/redosh-whichdo_absolute_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_absolute_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_absolute_2.t b/t/redosh-whichdo_absolute_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_absolute_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_absolute_default_1.t b/t/redosh-whichdo_absolute_default_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_absolute_default_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_absolute_default_2.t b/t/redosh-whichdo_absolute_default_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_absolute_default_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_relative_1.t b/t/redosh-whichdo_relative_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_relative_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_relative_2.t b/t/redosh-whichdo_relative_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_relative_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_relative_default_1.t b/t/redosh-whichdo_relative_default_1.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_relative_default_1.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/t/redosh-whichdo_relative_default_2.t b/t/redosh-whichdo_relative_default_2.t new file mode 120000 index 0000000..3f2c214 --- /dev/null +++ b/t/redosh-whichdo_relative_default_2.t @@ -0,0 +1 @@ +redo-sh.tests/wrapper.rc \ No newline at end of file diff --git a/usage.go b/usage.go index 48fee28..f9b8616 100644 --- a/usage.go +++ b/usage.go @@ -26,7 +26,7 @@ import ( ) const ( - Version = "0.5.0" + Version = "0.6.0" Warranty = `This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. @@ -58,7 +58,7 @@ be linked to goredo executable. It determines the command by its own name. You can create them by running: goredo -symlinks. * redo [options] [target ...] - forcefully and sequentially build specified targets + forcefully and *sequentially* build specified targets * redo-always always build current target. Unusable outside .do * redo-cleanup {full,log,tmp} [...]