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'
|
-e 's,[@]GODIR[@],$(guileobjectdir),g'
|
||||||
|
|
||||||
scripts/gash: scripts/gash.in Makefile
|
scripts/gash: scripts/gash.in Makefile
|
||||||
|
mkdir -p scripts
|
||||||
$(do_subst) < $(srcdir)/scripts/gash.in > scripts/gash
|
$(do_subst) < $(srcdir)/scripts/gash.in > scripts/gash
|
||||||
chmod a+x scripts/gash
|
chmod a+x scripts/gash
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ EXTRA_DIST += \
|
||||||
TEST_EXTENSIONS = .scm .sh
|
TEST_EXTENSIONS = .scm .sh
|
||||||
SCM_LOG_COMPILER = $(top_builddir)/pre-inst-env $(GUILE)
|
SCM_LOG_COMPILER = $(top_builddir)/pre-inst-env $(GUILE)
|
||||||
AM_SCM_LOG_FLAGS = --no-auto-compile
|
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
|
.PHONY: check-spec
|
||||||
check-spec:
|
check-spec:
|
||||||
|
|
26
test.sh
26
test.sh
|
@ -3,23 +3,31 @@ if [ -n "$V" ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
DIFF=${DIFF-diff}
|
DIFF=${DIFF-diff}
|
||||||
TEST_SHELL=${TEST_SHELL-scripts/gash}
|
TEST_SHELL=${TEST_SHELL-gash}
|
||||||
|
|
||||||
t="$1"
|
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
|
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=$?
|
r=$?
|
||||||
set -e
|
set -e
|
||||||
if [ -f "$b".exit ]; then
|
if [ -f "$s".exit ]; then
|
||||||
e=$(cat "$b".exit)
|
e=$(cat "$s".exit)
|
||||||
else
|
else
|
||||||
e=0
|
e=0
|
||||||
fi
|
fi
|
||||||
[ $r = $e ] || exit 1
|
[ $r = $e ] || exit 1
|
||||||
if [ -f "$b".stdout ]; then
|
if [ -f "$s".stdout ]; then
|
||||||
$DIFF -u "$b".stdout $b.1
|
$DIFF -u "$s".stdout $b.1
|
||||||
fi
|
fi
|
||||||
if [ -f "$b".stderr ]; then
|
if [ -f "$s".stderr ]; then
|
||||||
$DIFF -u "$b".stderr "$b".2
|
$DIFF -u "$s".stderr "$b".2
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
echo foo > bar
|
echo foo > $TEST_TMP/bar
|
||||||
echo foo >> bar
|
echo foo >> $TEST_TMP/bar
|
||||||
cat bar
|
cat $TEST_TMP/bar
|
||||||
rm bar
|
rm $TEST_TMP/bar
|
||||||
|
|
|
@ -4,6 +4,6 @@ subst () {
|
||||||
$1 > $2
|
$1 > $2
|
||||||
}
|
}
|
||||||
|
|
||||||
subst tests/data/foo foo.tmp
|
subst tests/data/foo $TEST_TMP/foo.tmp
|
||||||
cat foo.tmp
|
cat $TEST_TMP/foo.tmp
|
||||||
rm foo.tmp
|
rm $TEST_TMP/foo.tmp
|
||||||
|
|
Loading…
Reference in New Issue