Skip to content

Commit cc608e4

Browse files
committed
[ fix ] add generic support for input files
1 parent ae83967 commit cc608e4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/_config/config.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Usage: . ../../config.sh
99

10-
set -e
10+
set -eu
1111

1212
# Ugh, paths are relative to the script sourcing this file!
1313
. ../../_config/version-numbers.sh
@@ -17,6 +17,14 @@ goldenTest () {
1717
AGDA=$1
1818
TEST_NAME=$2
1919

20+
# Remember whether the script has an input -- ugh
21+
if [ -f input ]; then
22+
HAS_INPUT="true"
23+
else
24+
touch input
25+
HAS_INPUT="false"
26+
fi
27+
2028
# Specialise template agda-lib & cabal files
2129
sed "s/TEST_NAME/$TEST_NAME/g" ../../_config/template.agda-lib > "$TEST_NAME".agda-lib
2230
sed "s/TEST_NAME/$TEST_NAME/g" ../../_config/template.cabal > "$TEST_NAME".cabal
@@ -39,9 +47,12 @@ goldenTest () {
3947
cabal build "$TEST_NAME" --with-compiler "$GHC_EXEC" > logs/cabal-build
4048

4149
# Run the test
42-
cabal exec -v0 "$TEST_NAME" --with-compiler "$GHC_EXEC" > output
50+
cabal exec -v0 "$TEST_NAME" --with-compiler "$GHC_EXEC" < input > output
4351

4452
# Clean up after ourselves
53+
if ! "$HAS_INPUT"; then
54+
rm input
55+
fi
4556
rm "$TEST_NAME".cabal
4657
rm "$TEST_NAME".agda-lib
4758
rm _build

0 commit comments

Comments
 (0)