Skip to content

Commit

Permalink
Merge branch 'master' into simple
Browse files Browse the repository at this point in the history
* 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 4f7abac
Show file tree
Hide file tree
Showing 33 changed files with 90 additions and 6 deletions.
12 changes: 7 additions & 5 deletions minimal/do
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions t/000-set-minus-e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
log
4 changes: 4 additions & 0 deletions t/000-set-minus-e/all.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rm -f log
redo fatal >&/dev/null || true

[ "$(cat log)" = "ok" ] || exit 5
1 change: 1 addition & 0 deletions t/000-set-minus-e/clean.do
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -f log *~ .*~
4 changes: 4 additions & 0 deletions t/000-set-minus-e/fatal.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rm -f log
echo ok >>log
this-should-cause-a-fatal-error
echo fail >>log # this line should never run
2 changes: 2 additions & 0 deletions t/100-args/all.do
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
redo test.args test2.args passfailtest
. ../skip-if-minimal-do.sh
redo --old-args test.oldargs
5 changes: 5 additions & 0 deletions t/100-args/default.oldargs.do
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions t/140-shuffle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.log
19 changes: 19 additions & 0 deletions t/140-shuffle/all.do
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions t/140-shuffle/clean.do
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -f *.log *~ .*~
1 change: 1 addition & 0 deletions t/140-shuffle/default.x.do
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo $1 >>out.log
1 change: 1 addition & 0 deletions t/141-keep-going/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.log
17 changes: 17 additions & 0 deletions t/141-keep-going/all.do
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions t/141-keep-going/clean.do
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -f *.log *~ .*~
2 changes: 2 additions & 0 deletions t/141-keep-going/default.fail.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo $2 fail >>out.log
exit 1
1 change: 1 addition & 0 deletions t/141-keep-going/default.ok.do
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo $2 >>out.log
8 changes: 8 additions & 0 deletions t/201-fail/all.do
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion t/350-deps/clean.do
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
redo basic/clean dirtest/clean
redo basic/clean
rm -f *~ .*~ *.count t1a overwrite overwrite[123] \
genfile2 genfile.log static.log
2 changes: 2 additions & 0 deletions t/999-installer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
install.log
test.tmp
2 changes: 2 additions & 0 deletions t/999-installer/all.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rm -rf test.tmp
DESTDIR=$PWD/test.tmp redo ../../install >&install.log
1 change: 1 addition & 0 deletions t/999-installer/clean.do
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -rf test.tmp install.log *~ .*~
8 changes: 8 additions & 0 deletions t/all.do
Original file line number Diff line number Diff line change
@@ -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$//' |
Expand Down

0 comments on commit 4f7abac

Please sign in to comment.