Permalink
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...
apenwarr committed Feb 9, 2012
2 parents 7ef2290 + 33dadbf commit 4f7abac4c6e47c221f322cc7b817958b3087f1bd
View
@@ -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
@@ -0,0 +1 @@
+log
View
@@ -0,0 +1,4 @@
+rm -f log
+redo fatal >&/dev/null || true
+
+[ "$(cat log)" = "ok" ] || exit 5
@@ -0,0 +1 @@
+rm -f log *~ .*~
@@ -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
@@ -1 +1,3 @@
redo test.args test2.args passfailtest
+. ../skip-if-minimal-do.sh
+redo --old-args test.oldargs
@@ -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" ]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1 @@
+*.log
View
@@ -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
@@ -0,0 +1 @@
+rm -f *.log *~ .*~
@@ -0,0 +1 @@
+echo $1 >>out.log
@@ -0,0 +1 @@
+*.log
View
@@ -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
@@ -0,0 +1 @@
+rm -f *.log *~ .*~
@@ -0,0 +1,2 @@
+echo $2 fail >>out.log
+exit 1
@@ -0,0 +1 @@
+echo $2 >>out.log
View
@@ -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
@@ -1,3 +1,3 @@
-redo basic/clean dirtest/clean
+redo basic/clean
rm -f *~ .*~ *.count t1a overwrite overwrite[123] \
genfile2 genfile.log static.log
@@ -0,0 +1,2 @@
+install.log
+test.tmp
View
@@ -0,0 +1,2 @@
+rm -rf test.tmp
+DESTDIR=$PWD/test.tmp redo ../../install >&install.log
View
@@ -0,0 +1 @@
+rm -rf test.tmp install.log *~ .*~
View
@@ -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.