Skip to content
Browse files

Merge branch 'master' into simple

* master:
  minimal/do: some shells return error in "read x <file" for empty files.
  minimal/do: fix a really scary bugs in "set -e" behaviour.
  Add a test for install.do.
  Add a test for --keep-going option.
  Add a test for --shuffle option.
  Rename 111-compile to 111-compile2.
  t/100-args: add a test for --old-args feature.
  t/350-deps: 'redo clean' was crashing.
  t/201-fail: add a simple test for non-existent source files.
  • Loading branch information...
2 parents 7ef2290 + 33dadbf commit 4f7abac4c6e47c221f322cc7b817958b3087f1bd @apenwarr committed
View
12 minimal/do
@@ -94,7 +94,7 @@ _run_dofile()
export REDO_TARGET=$PWD/$target
local line1
set -e
- read line1 <"$PWD/$dofile"
+ read line1 <"$PWD/$dofile" || true
cmd=${line1#"#!/"}
if [ "$cmd" != "$line1" ]; then
/$cmd "$PWD/$dofile" "$@" >"$tmp.tmp2"
@@ -153,19 +153,21 @@ _dir_shovel()
}
-redo()
+_redo()
{
+ set +e
for i in "$@"; do
_dirsplit "$i"
_dir_shovel "$dir" "$base"
dir=$xdir base=$xbase basetmp=$xbasetmp
- ( cd "$dir" && _do "$dir" "$base" "$basetmp" ) || return 1
+ ( cd "$dir" && _do "$dir" "$base" "$basetmp" )
+ [ "$?" = 0 ] || return 1
done
}
-set -e
-redo "$@"
+_redo "$@"
+[ "$?" = 0 ] || exit 1
if [ -n "$DO_TOP" ]; then
echo "Removing stamp files..." >&2
View
1 t/000-set-minus-e/.gitignore
@@ -0,0 +1 @@
+log
View
4 t/000-set-minus-e/all.do
@@ -0,0 +1,4 @@
+rm -f log
+redo fatal >&/dev/null || true
+
+[ "$(cat log)" = "ok" ] || exit 5
View
1 t/000-set-minus-e/clean.do
@@ -0,0 +1 @@
+rm -f log *~ .*~
View
4 t/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
View
2 t/100-args/all.do
@@ -1 +1,3 @@
redo test.args test2.args passfailtest
+. ../skip-if-minimal-do.sh
+redo --old-args test.oldargs
View
5 t/100-args/default.oldargs.do
@@ -0,0 +1,5 @@
+# Note: this test expects to be run with 'redo --old-args' or it will fail.
+. ../skip-if-minimal-do.sh
+[ "$1" = "test" ]
+[ "$2" = ".oldargs" ]
+[ "$3" != "test.oldargs" ]
View
0 t/111-compile/.gitignore → t/111-compile2/.gitignore
File renamed without changes.
View
0 t/111-compile/CC.do → t/111-compile2/CC.do
File renamed without changes.
View
0 t/111-compile/Makefile → t/111-compile2/Makefile
File renamed without changes.
View
0 t/111-compile/all.do → t/111-compile2/all.do
File renamed without changes.
View
0 t/111-compile/clean.do → t/111-compile2/clean.do
File renamed without changes.
View
0 t/111-compile/config.sh → t/111-compile2/config.sh
File renamed without changes.
View
0 t/111-compile/default.o.do → t/111-compile2/default.o.do
File renamed without changes.
View
0 t/111-compile/hello.do → t/111-compile2/hello.do
File renamed without changes.
View
0 t/111-compile/main.c → t/111-compile2/main.c
File renamed without changes.
View
0 t/111-compile/mystr.c → t/111-compile2/mystr.c
File renamed without changes.
View
0 t/111-compile/mystr.h → t/111-compile2/mystr.h
File renamed without changes.
View
1 t/140-shuffle/.gitignore
@@ -0,0 +1 @@
+*.log
View
19 t/140-shuffle/all.do
@@ -0,0 +1,19 @@
+exec >&2
+. ../skip-if-minimal-do.sh
+
+# Need to repeat this several times, on the off chance that shuffling the
+# input happens to give us the same output (probability 1/factorial(9))
+x=0
+while [ "$x" -lt 10 ]; do
+ x=$(($x + 1))
+ rm -f out.log
+ redo --shuffle 1.x 2.x 3.x 4.x 5.x 6.x 7.x 8.x 9.x
+ sort out.log >sort.log
+ if ! diff -q out.log sort.log >/dev/null; then
+ exit 0
+ fi
+ echo "retry: #$x"
+done
+
+# still not shuffled?
+exit 22
View
1 t/140-shuffle/clean.do
@@ -0,0 +1 @@
+rm -f *.log *~ .*~
View
1 t/140-shuffle/default.x.do
@@ -0,0 +1 @@
+echo $1 >>out.log
View
1 t/141-keep-going/.gitignore
@@ -0,0 +1 @@
+*.log
View
17 t/141-keep-going/all.do
@@ -0,0 +1,17 @@
+exec >&2
+. ../skip-if-minimal-do.sh
+
+rm -f out.log sort.log err.log
+redo --keep-going 1.ok 2.fail 3.fail 4.ok 5.ok 6.fail 7.ok >&err.log &&
+ exit 11 # expect it to return nonzero due to failures
+sort out.log >sort.log
+
+expect="1
+2 fail
+3 fail
+4
+5
+6 fail
+7"
+
+[ "$(cat sort.log)" = "$expect" ] || exit 22
View
1 t/141-keep-going/clean.do
@@ -0,0 +1 @@
+rm -f *.log *~ .*~
View
2 t/141-keep-going/default.fail.do
@@ -0,0 +1,2 @@
+echo $2 fail >>out.log
+exit 1
View
1 t/141-keep-going/default.ok.do
@@ -0,0 +1 @@
+echo $2 >>out.log
View
8 t/201-fail/all.do
@@ -1,5 +1,13 @@
+rm -f this-doesnt-exist
+! redo this-doesnt-exist >&/dev/null || exit 32 # expected to fail
+! redo-ifchange this-doesnt-exist >&/dev/null || exit 33 # expected to fail
+redo-ifcreate this-doesnt-exist >&/dev/null || exit 34 # expected to pass
+
+
+
rm -f fail
! redo-ifchange fail >&/dev/null || exit 44 # expected to fail
+
touch fail
../flush-cache
redo-ifchange fail >&/dev/null || exit 55 # expected to pass
View
2 t/350-deps/clean.do
@@ -1,3 +1,3 @@
-redo basic/clean dirtest/clean
+redo basic/clean
rm -f *~ .*~ *.count t1a overwrite overwrite[123] \
genfile2 genfile.log static.log
View
2 t/999-installer/.gitignore
@@ -0,0 +1,2 @@
+install.log
+test.tmp
View
2 t/999-installer/all.do
@@ -0,0 +1,2 @@
+rm -rf test.tmp
+DESTDIR=$PWD/test.tmp redo ../../install >&install.log
View
1 t/999-installer/clean.do
@@ -0,0 +1 @@
+rm -rf test.tmp install.log *~ .*~
View
8 t/all.do
@@ -1,3 +1,11 @@
+# tests that "set -e" works (.do scripts always run with -e set by default)
+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
+
# builds 1xx*/all
/bin/ls 1[0-9][0-9]*/all.do |
sed 's/\.do$//' |

0 comments on commit 4f7abac

Please sign in to comment.
Something went wrong with that request. Please try again.