File tree Expand file tree Collapse file tree 5 files changed +47
-6
lines changed
Expand file tree Collapse file tree 5 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,19 @@ AGDA_EXEC=agda-2.6.4 GHC_EXEC=ghc-9.2.8 make testsuite
1010
1111# Structure of the test suite
1212
13+ ## Test case
14+
15+ Each test case is under 2 levels of nesting (this is hard-coded)
16+ and should comprise:
17+
18+ 1 . A ` Main.agda ` file containing a ` main ` entrypoint
19+ 2 . An ` expected ` file containing the expected output of running ` Main `
20+ 3 . A ` run ` file describing how to run ` Main ` (most likely implemented
21+ using the ` goldenTest ` function defined in
22+ [ _ config/config.sh] ( _config/config.sh ) .
23+ 4 . Optionally, an ` input ` file for the stdin content to feed to
24+ the executable obtained by compiling ` Main ` .
25+
1326## Configuration
1427
1528The Agda & GHC version numbers the stdlib is tested against
Original file line number Diff line number Diff line change 77#
88# Usage: . ../../config.sh
99
10- set -eu
10+ set -eux
1111
1212# Ugh, paths are relative to the script sourcing this file!
1313. ../../_config/version-numbers.sh
1414
15+
16+
17+ # Main entry point to build and run an Agda program
18+ #
19+ # Typically called like `goldenTest "$1" "echo" "hello world"`
20+ #
21+ # INPUTS:
22+ # $1 is the agda executable (typically "$1" in the ̀ run` file
23+ # because this info is provided by the test runner
24+ # $2 the name of the test as a string
25+ # $3 is OPTIONAL and corresponds to the extra arguments to pass
26+ # to the executable obtained by compiling the Agda program
27+ #
28+ # LOGGING:
29+ # logs/agda-build for the trace produced by Agda
30+ # logs/cabal-build for the trace produced by cabal+ghc
31+ #
32+ # OUTPUT:
33+ # the output obtained by running the Agda program is stored in
34+ # the file named `output`. The test runner will then diff it
35+ # against the expected file.
1536goldenTest () {
1637
1738 AGDA=$1
1839 TEST_NAME=" stdlib-test-$2 "
1940
41+ # Taking extra args for the executable?
42+ if [ -z ${3-} ]; then
43+ EXTRA_ARGS=" "
44+ else
45+ EXTRA_ARGS=" -- $3 "
46+ fi
47+
2048 # Remember whether the script has an input -- ugh
2149 if [ -f input ]; then
2250 HAS_INPUT=" true"
@@ -47,7 +75,7 @@ goldenTest () {
4775 cabal build " $TEST_NAME " --with-compiler " $GHC_EXEC " > logs/cabal-build
4876
4977 # Run the test
50- cabal exec -v0 " $TEST_NAME " --with-compiler " $GHC_EXEC " < input > output
78+ cabal exec -v0 " $TEST_NAME " --with-compiler " $GHC_EXEC " $EXTRA_ARGS < input > output
5179
5280 # Clean up after ourselves
5381 if ! " $HAS_INPUT " ; then
Original file line number Diff line number Diff line change 77#
88# Usage: . PATH/TO/version-numbers.sh
99
10- if [ -z ${AGDA_EXEC} ]; then
10+ if [ -z ${AGDA_EXEC- } ]; then
1111 export AGDA_EXEC=agda-2.6.4
1212fi
1313
14- if [ -z ${GHC_EXEC} ]; then
14+ if [ -z ${GHC_EXEC- } ]; then
1515 export GHC_EXEC=ghc-9.2.8
1616fi
Original file line number Diff line number Diff line change 1- environment
1+ stdlib-test- environment
22hello world
33hello back!
Original file line number Diff line number Diff line change 11. ../../_config/config.sh
2- goldenTest "$1" "environment"
2+ goldenTest "$1" "environment" "hello world"
You can’t perform that action at this time.
0 commit comments