diff --git a/test/integration/.gitignore b/test/integration/.gitignore new file mode 100644 index 0000000000..185be12bb3 --- /dev/null +++ b/test/integration/.gitignore @@ -0,0 +1,3 @@ +logs/ +tests-fail/ +tests-success/ diff --git a/test/integration/README.md b/test/integration/README.md index 3108199ff5..6db87f1488 100644 --- a/test/integration/README.md +++ b/test/integration/README.md @@ -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. diff --git a/test/integration/run-single-test.sh b/test/integration/run-single-test.sh new file mode 100755 index 0000000000..f9ba6e5cb9 --- /dev/null +++ b/test/integration/run-single-test.sh @@ -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 diff --git a/test/integration/run-sort-tests.sh b/test/integration/run-sort-tests.sh new file mode 100755 index 0000000000..3546fbf60a --- /dev/null +++ b/test/integration/run-sort-tests.sh @@ -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