From b103107f101155f0ac71bca907d9fc17c8530bc4 Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Thu, 26 Oct 2023 21:20:42 -0400 Subject: [PATCH 1/2] Instructions to run tests from the command line --- docs/TESTS.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/TESTS.md b/docs/TESTS.md index 43f8bd5d..694df1b4 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -12,4 +12,49 @@ As you make changes to the solution you are writing use your editor's functional Remember to evaluate `(exercise-name-test:run-tests)` to re-run the tests after loading your updated solution. +## Testing from the command line +Executing the tests from the command line is possible, but it depends on which CL implementation you have chosen. +For example, with SBCL you could execute this in the directory for exercise "foo" + +```sh +sbcl --noinform \ + --load foo-test \ + --eval '(exit :code (if (foo-test:run-tests) 0 1))' +``` + +Other CL implementations will have similar but slightly different command-line options and exit commands. + +This assumes you have already installed SBCL and Quicklisp. +See [Installing Common Lisp locally](https://exercism.org/docs/tracks/common-lisp/installation) + +~~~~exercism/note +That command can be made more convenient. The `exercism` CLI has been updated so that the command + +```sh +exercism test +``` + +does "The Right Thing"™ to invoke the test suite for _most tracks_. +Unfortunately CL does not benefit because there is no single prescribed way to run the tests. + +However, there are ways to wrap the exercism CLI to provide additional functionality, or override existing functionality. +If you use the bash shell, you can add the following to your `~/.bashrc` file. +It looks complicated but it just checks that you are in a directory for a CL exercise and invokes SBCL: + +```sh +function exercism { + if [[ $1 == "test" && $PWD =~ "$(command exercism workspace)/common-lisp/"([^/]+) ]] + then + local exercise=${BASH_REMATCH[1]} + sbcl --noinform \ + --load "${exercise}-test" \ + --eval "(exit :code (if (${exercise}-test:run-tests) 0 1))" + else + command exercism "$@" + fi +} +``` + +With that, you can run `exercism test` to run the tests for your CL exercises. +~~~~ From 1f983f1c194d3c3f983dbd924255ae18ffb53407 Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Sat, 28 Oct 2023 18:06:04 -0400 Subject: [PATCH 2/2] Remove shell wrapper note. CL -> Common Lisp --- docs/TESTS.md | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/docs/TESTS.md b/docs/TESTS.md index 694df1b4..c32717a1 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -14,7 +14,7 @@ Remember to evaluate `(exercise-name-test:run-tests)` to re-run the tests after ## Testing from the command line -Executing the tests from the command line is possible, but it depends on which CL implementation you have chosen. +Executing the tests from the command line is possible, but it depends on which Common Lisp implementation you have chosen. For example, with SBCL you could execute this in the directory for exercise "foo" ```sh @@ -23,38 +23,10 @@ sbcl --noinform \ --eval '(exit :code (if (foo-test:run-tests) 0 1))' ``` -Other CL implementations will have similar but slightly different command-line options and exit commands. +Other Common Lisp implementations will have similar but slightly different command-line options and exit commands. This assumes you have already installed SBCL and Quicklisp. See [Installing Common Lisp locally](https://exercism.org/docs/tracks/common-lisp/installation) -~~~~exercism/note -That command can be made more convenient. The `exercism` CLI has been updated so that the command - -```sh -exercism test -``` - -does "The Right Thing"™ to invoke the test suite for _most tracks_. -Unfortunately CL does not benefit because there is no single prescribed way to run the tests. - -However, there are ways to wrap the exercism CLI to provide additional functionality, or override existing functionality. -If you use the bash shell, you can add the following to your `~/.bashrc` file. -It looks complicated but it just checks that you are in a directory for a CL exercise and invokes SBCL: - -```sh -function exercism { - if [[ $1 == "test" && $PWD =~ "$(command exercism workspace)/common-lisp/"([^/]+) ]] - then - local exercise=${BASH_REMATCH[1]} - sbcl --noinform \ - --load "${exercise}-test" \ - --eval "(exit :code (if (${exercise}-test:run-tests) 0 1))" - else - command exercism "$@" - fi -} -``` - -With that, you can run `exercism test` to run the tests for your CL exercises. -~~~~ +That command is somewhat unwieldy. +A method to wrap that into the `exercism` CLI is [shown here](https://glennj.github.io/exercism/cli).