Skip to content

Commit de62198

Browse files
committed
Updated test run scripts; working on improving the lock handling.
- Legacy-Id: 796
1 parent d29ca07 commit de62198

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

test/run

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
program=${0##*/}
44
progdir=${0%/*}
55

6+
. $progdir/shell-utils
7+
68
cd $progdir/.. # now at trunk/
79

8-
test/test-setup # create a patched django for test purposes, and more
10+
pidfile=$(test/test-setup) # create a patched django for test purposes, and more
11+
[ "$pidfile" ] || die "Didn't get a pidfile name"
912

1013
test/run-pyflakes ietf
1114

1215
# Trap keyboard interrupt to ensure the test/teardown is run if we interrupt the tests
1316
trap 'echo "$program($LINENO): Caught Interrupt"' INT
1417

1518
# run tests with our patched django
16-
PYTHONPATH=test:test/lib URLPREFIX="$*" python ietf/manage.py test
19+
PYTHONPATH=test:test/lib URLPREFIX="$*" python ietf/manage.py test &
20+
pid=$!
21+
echo $pid > $pidfile
22+
wait $pid
1723

1824
# reset keyboard interrupt trap
1925
trap INT

test/shell-utils

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
[ "$program" ] || program=${0##*/}
88

9+
function die() {
10+
echo "$program: Error: $*" 1>&2;
11+
exit 2
12+
}
13+
914
function err() {
1015
echo "$program: Error: $*" 1>&2;
1116
exit 2
1217
}
13-
alias die='err'
1418

1519
function warn() {
1620
echo "$program: Warning: $*" 1>&2;

test/test-setup

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,17 @@ while true; do
6666
echo "$$" > $PIDFILE
6767
chmod a+rwx $LOCKDIR
6868
chmod a+rw $PIDFILE
69+
echo $PIDFILE # tell caller about the pidfile
6970
break
7071
else
7172
pid=$(< $PIDFILE )
7273
[ "$pid" ] || die "Couldn't read pidfile '$PIDFILE'"
7374
if kill -0 $pid; then
74-
echo "Pidfile for process $pid exists, and process is running. Sleeping."
75+
say "Pidfile for process $pid exists, and process is running. Sleeping."
7576
sleep 10
7677
else
77-
echo "Pidfile for process $pid exists, but process isn't running."
78-
echo "Removing lock and old pid file $pidfile."
79-
rm -rf $LOCKDIR
80-
break
78+
say "Pidfile for process $pid exists, but process doesn't seem to be running."
79+
die "Remove lockdir $LOCKDIR and old pid file $pidfile."
8180
fi
8281
fi
8382
done

0 commit comments

Comments
 (0)