Fix building from an external directory.
* Makefile.am (scripts/gash): Make sure the 'scripts' directory exists in the build tree. (SH_LOG_COMPILER): Call 'test.sh' from the source tree. * test.sh: Change the default test shell from 'scripts/gash' to 'gash'; export a 'TEST_TMP' variable that tells tests where to store temporary files; and make sure all output is written to the build directory. tests/50-redirect-append.sh: Use the 'TEST_TMP' variable. tests/60-subst.sh: Ditto.
This commit is contained in:
parent
d257dac0c6
commit
95545c9269
|
@ -61,6 +61,7 @@ do_subst = sed \
|
|||
-e 's,[@]GODIR[@],$(guileobjectdir),g'
|
||||
|
||||
scripts/gash: scripts/gash.in Makefile
|
||||
mkdir -p scripts
|
||||
$(do_subst) < $(srcdir)/scripts/gash.in > scripts/gash
|
||||
chmod a+x scripts/gash
|
||||
|
||||
|
@ -83,7 +84,7 @@ EXTRA_DIST += \
|
|||
TEST_EXTENSIONS = .scm .sh
|
||||
SCM_LOG_COMPILER = $(top_builddir)/pre-inst-env $(GUILE)
|
||||
AM_SCM_LOG_FLAGS = --no-auto-compile
|
||||
SH_LOG_COMPILER = $(top_builddir)/pre-inst-env $(top_builddir)/test.sh
|
||||
SH_LOG_COMPILER = $(top_builddir)/pre-inst-env $(top_srcdir)/test.sh
|
||||
|
||||
.PHONY: check-spec
|
||||
check-spec:
|
||||
|
|
26
test.sh
26
test.sh
|
@ -3,23 +3,31 @@ if [ -n "$V" ]; then
|
|||
set -x
|
||||
fi
|
||||
DIFF=${DIFF-diff}
|
||||
TEST_SHELL=${TEST_SHELL-scripts/gash}
|
||||
TEST_SHELL=${TEST_SHELL-gash}
|
||||
|
||||
t="$1"
|
||||
b=tests/$(basename "$t" .sh)
|
||||
s=tests/$(basename "$t" .sh)
|
||||
|
||||
# This is a hack to make sure we can build from an external directory.
|
||||
# We move into the source directory, and then send all of our output
|
||||
# back to the build directory.
|
||||
export TEST_TMP=$(pwd)
|
||||
b=$(pwd)/$s
|
||||
cd $(dirname "$t")/..
|
||||
|
||||
set +e
|
||||
timeout 10 $TEST_SHELL -e "$b".sh -s --long file0 file1 > "$b".1 2> "$b".2
|
||||
timeout 10 $TEST_SHELL -e "$s".sh -s --long file0 file1 > "$b".1 2> "$b".2
|
||||
r=$?
|
||||
set -e
|
||||
if [ -f "$b".exit ]; then
|
||||
e=$(cat "$b".exit)
|
||||
if [ -f "$s".exit ]; then
|
||||
e=$(cat "$s".exit)
|
||||
else
|
||||
e=0
|
||||
fi
|
||||
[ $r = $e ] || exit 1
|
||||
if [ -f "$b".stdout ]; then
|
||||
$DIFF -u "$b".stdout $b.1
|
||||
if [ -f "$s".stdout ]; then
|
||||
$DIFF -u "$s".stdout $b.1
|
||||
fi
|
||||
if [ -f "$b".stderr ]; then
|
||||
$DIFF -u "$b".stderr "$b".2
|
||||
if [ -f "$s".stderr ]; then
|
||||
$DIFF -u "$s".stderr "$b".2
|
||||
fi
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
echo foo > bar
|
||||
echo foo >> bar
|
||||
cat bar
|
||||
rm bar
|
||||
echo foo > $TEST_TMP/bar
|
||||
echo foo >> $TEST_TMP/bar
|
||||
cat $TEST_TMP/bar
|
||||
rm $TEST_TMP/bar
|
||||
|
|
|
@ -4,6 +4,6 @@ subst () {
|
|||
$1 > $2
|
||||
}
|
||||
|
||||
subst tests/data/foo foo.tmp
|
||||
cat foo.tmp
|
||||
rm foo.tmp
|
||||
subst tests/data/foo $TEST_TMP/foo.tmp
|
||||
cat $TEST_TMP/foo.tmp
|
||||
rm $TEST_TMP/foo.tmp
|
||||
|
|
Loading…
Reference in New Issue