Lichen

Changeset

455:aebbc02d5dfe
2017-01-10 Paul Boddie raw files shortlog changelog graph Added support for independently building and running tests.
test_all.sh (file)
     1.1 --- a/test_all.sh	Tue Jan 10 19:21:56 2017 +0100
     1.2 +++ b/test_all.sh	Tue Jan 10 21:41:46 2017 +0100
     1.3 @@ -28,18 +28,43 @@
     1.4  # Main program.
     1.5  
     1.6  OPTION=$1
     1.7 +TESTINPUT="_results/testinput.txt"
     1.8  
     1.9  # Make any required results directory.
    1.10  
    1.11 -if [ "$OPTION" = '--build' ]; then
    1.12 +if [ "$OPTION" = '--build' ] || [ "$OPTION" = '--build-only' ] ; then
    1.13      if [ ! -e "_results" ]; then
    1.14          mkdir "_results"
    1.15      else
    1.16          rm "_results/"*
    1.17      fi
    1.18 +
    1.19 +    cp "tests/testinput.txt" "$TESTINPUT"
    1.20  fi
    1.21  
    1.22 -TESTINPUT="tests/testinput.txt"
    1.23 +# If just running existing programs, do so now and exit.
    1.24 +
    1.25 +if [ "$OPTION" = '--run-built' ] ; then
    1.26 +    for FILENAME in _results/* ; do
    1.27 +        TESTNAME=`basename "$FILENAME"`
    1.28 +
    1.29 +        # Skip non-program files.
    1.30 +
    1.31 +        if [ ! -x "$FILENAME" ]; then
    1.32 +            continue
    1.33 +        fi
    1.34 +
    1.35 +        echo "$FILENAME..." 1>&2
    1.36 +        OUTLOG="_results/$TESTNAME.out"
    1.37 +
    1.38 +        echo " (run)..." 1>&2
    1.39 +        if ! "$FILENAME" > "$OUTLOG" < "$TESTINPUT" ; then
    1.40 +            exit 1
    1.41 +        fi
    1.42 +    done
    1.43 +
    1.44 +    exit 0
    1.45 +fi
    1.46  
    1.47  # Perform each test.
    1.48  
    1.49 @@ -100,7 +125,7 @@
    1.50  
    1.51      # Build and run if appropriate.
    1.52  
    1.53 -    if [ "$OPTION" = '--build' ]; then
    1.54 +    if [ "$OPTION" = '--build' ] || [ "$OPTION" = "--build-only" ] ; then
    1.55          BUILDLOG="_results/$TESTNAME.build"
    1.56          OUTLOG="_results/$TESTNAME.out"
    1.57  
    1.58 @@ -110,9 +135,13 @@
    1.59              exit 1
    1.60          fi
    1.61  
    1.62 -        echo " (run)..." 1>&2
    1.63 -        if ! "$DATADIR/_generated/main" > "$OUTLOG" < "$TESTINPUT" ; then
    1.64 -            exit 1
    1.65 +        if [ "$OPTION" = "--build-only" ]; then
    1.66 +            mv "$DATADIR/_generated/main" "_results/$TESTNAME"
    1.67 +        else
    1.68 +            echo " (run)..." 1>&2
    1.69 +            if ! "$DATADIR/_generated/main" > "$OUTLOG" < "$TESTINPUT" ; then
    1.70 +                exit 1
    1.71 +            fi
    1.72          fi
    1.73      fi
    1.74