The Docker image to automatically run tests on Unison solutions submitted to Exercism.
To run the tests of an arbitrary exercise, do the following:
- Open a terminal in the project's root
- Run
./bin/run.sh <exercise-slug> <solution-dir> <output-dir>
Once the test runner has finished, its results will be written to <output-dir>/results.json
.
This script is provided for testing purposes, as it mimics how test runners run in Exercism's production environment.
To run the tests of an arbitrary exercise using the Docker image, do the following:
- Open a terminal in the project's root
- Run
./bin/run-in-docker.sh <exercise-slug> <solution-dir> <output-dir>
Once the test runner has finished, its results will be written to <output-dir>/results.json
.
If you are using Docker on an M1 mac, you'll need to build a docker image using DockerfileMac
: docker build -t exercism/test-runner -f DockerfileMac .
The M1 Mac build of the UCM is ucm-arm64
and it is too large for standard git storage, contact one of the Unison maintainers for the file.
To run the tests to verify the behavior of the test runner, do the following:
- Open a terminal in the project's root
- Run
./bin/run-tests.sh
These are golden tests that compare the results.json
generated by running the current state of the code against the "known good" tests/<test-name>/results.json
. All files created during the test run itself are discarded.
When you've made modifications to the code that will result in a new "golden" state, you'll need to generate and commit a new tests/<test-name>/results.json
file.
This script is provided for testing purposes, as it mimics how test runners run in Exercism's production environment.
To run the tests to verify the behavior of the test runner using the Docker image, do the following:
- Open a terminal in the project's root
- Run
./bin/run-tests-in-docker.sh
These are golden tests that compare the results.json
generated by running the current state of the code against the "known good" tests/<test-name>/results.json
. All files created during the test run itself are discarded.
When you've made modifications to the code that will result in a new "golden" state, you'll need to generate and commit a new tests/<test-name>/results.json
file.
The Unison test runner relies on a few conventions and contracts between the Unison Exercism repo proper and the files found here.
- Every solution's
name.test.u
file should expose a variabletests
of type[base.Test]
- Every solution directory contains two files under
.meta
, one calledtestAnnotation.json
, and another calledtestLoader.md
. testAnnotation.json
is used to capture the values that would otherwise be defined via metaprogramming or codebase introspection, in this case, individual test names and the body of the test itself.- The
src
directory in the test runner repo contains the files responsible for writing the Json output file. They rely on environment variables set by theexport
statements in therun.sh
script. - Currently this test runner is targeting v2 of the api spec.
- The dockerfile initializes a codebase which contains the standard lib, parser, and json libraries needed to run the tests.
- User submits test
- UCM transcript runner tries to load and add the user's files to a temp codebase with
testLoader.md
- If the code typechecks...
- The
testRunner.md
transcript runs thetestMain.u
file - The json file containing test results is created
- The
- If the users code does not typecheck...
- The json result file is not created. The UCM runs
errorRunner.md
to read the transcript output file produced bytestLoader.md
. It's calledtestLoader.output.md
and it is always located in the same directory as its associated transcript. - The
errorMain.u
code looks for the transcript failure message, and writes the json output file with associated status and message.
- The json result file is not created. The UCM runs