Skip to content

Commit

Permalink
Helper integration test suite scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Aug 14, 2018
1 parent dae7e1e commit ff05a84
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
logs/
tests-fail/
tests-success/
13 changes: 13 additions & 0 deletions test/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ $ stack test --flag stack:integration-tests stack:test:stack-integration-test
Note that this command can take a _long_ time. It's also more thorough
than the quick command given above, as it will run each test with a
clean `STACK_ROOT`.

## Helper scripts

There are two helper scripts in this directory. Note that these may
not always work as anticipated, since some of the tests expect a clean
`STACK_ROOT`, and these scripts do not set that up.

* `run-sort-tests.sh` will run all of the tests in the `tests`
directory, and move the successful ones into `tests-success`, and
the failing ones into `tests-fail`. It will keep the logs of failing
tests in `logs`.
* `run-single-test.sh` takes a single argument (the name of a test),
and runs just that test.
22 changes: 22 additions & 0 deletions test/integration/run-single-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -uo pipefail

cd "$( dirname "${BASH_SOURCE[0]}" )"

export STACK_ROOT=$HOME/.stack
unset GHC_PACKAGE_PATH

DIR=$(pwd)
STACK=$(stack exec which stack)

if [[ ! -d "tests/$1" ]]
then
echo Test does not exist: $1
exit 1
fi

mkdir -p tests/$1/files
cd tests/$1/files
echo Running test $1
exec $STACK --stack-yaml $DIR/../../stack.yaml runghc --no-ghc-package-path -- -i../../../lib ../Main.hs
37 changes: 37 additions & 0 deletions test/integration/run-sort-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -uo pipefail

cd "$( dirname "${BASH_SOURCE[0]}" )"

export STACK_ROOT=$HOME/.stack

DIR=$(pwd)
STACK=$(stack exec which stack)

mkdir -p tests-success
mkdir -p tests-fail
mkdir -p logs

cd "$DIR/tests"
for f in *
do
cd "$DIR/tests"
if [[ -d "$f" ]]
then
mkdir -p "$f/files"
cd "$f/files"
echo Running test $f
$STACK --stack-yaml $DIR/../../stack.yaml runghc --no-ghc-package-path -- -i../../../lib ../Main.hs > $DIR/logs/$f 2>&1
RES=$?
cd "$DIR/tests"
echo Result code for $f: $RES
if [[ $RES -eq 0 ]]
then
mv "$f" ../tests-success
rm $DIR/logs/$f
else
mv "$f" ../tests-fail
fi
fi
done

0 comments on commit ff05a84

Please sign in to comment.