Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #3: Make tests run more quickly.
Add a new shell script to run the tests. It uses a new new environment variable `HREPL_TEST_OUTPUT` that lets the tests share the same output directory. Run `bazel clean` in between each test to make them essentially hermetic (as far as this test is concerned), without redoing expensive computations in each test such as fetching/installing the GHC build or building the `protoc` binary. Also set the disk cache explicitly in the test output directory to cache build outputs across tests. When I ran the tests with With this change, when I ran it two tests each took a little under 5 minutes (`joined_ffi_test`, because it was the first one, and `proto_test`, because it needed to rebuild more protobuf dependencies) and the rest of the tests each took ~10s. The total runtime was a little under 10 minutes.
- Loading branch information
Showing
5 changed files
with
117 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# | ||
# Runs one or more tests, sharing the output cache among them. | ||
# | ||
# Usage: | ||
# hrepl/tests/run_tests.sh $TARGETS | ||
|
||
|
||
set -ueo pipefail | ||
set -x | ||
|
||
# Build tests, including the hrepl binary, with the default parallelism | ||
bazel build "$@" | ||
|
||
OUTPUT="$(mktemp -d)" | ||
trap "bazel --output_base=$OUTPUT/output-base clean --expunge && rm -rf $OUTPUT" EXIT | ||
|
||
# Now run each test in sequence, using the same output directory to share the workspace | ||
# and cache: | ||
bazel test -j 1 \ | ||
--test_env=PATH \ | ||
--test_env=HREPL_TEST_CLIENT="$PWD" \ | ||
--test_env=HREPL_TEST_OUTPUT="$OUTPUT" \ | ||
--test_output=streamed \ | ||
-k \ | ||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters