Skip to content

Commit

Permalink
Skip tests (#99)
Browse files Browse the repository at this point in the history
* SKIP-REST-OF-TESTS proof of concept for acronym exercise

* apply to rest of exercises

* markdown files must have exactly one top-level header

* rewrite help files

* re-add special words for pythagorean-triplet
  • Loading branch information
glennj authored Sep 25, 2023
1 parent a36ace9 commit fa3e12e
Show file tree
Hide file tree
Showing 52 changed files with 939 additions and 458 deletions.
2 changes: 1 addition & 1 deletion docs/ABOUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Security isn't an afterthought in 8th. It was designed from the beginning to avo
8th has a [forum](https://8th-dev.com/forum/) as well as extensive documentation including a [manual](https://8th-dev.com/manual.html), and a hyperlinked dictionary of builtin and library [words](https://8th-dev.com/words.html). [Compare](https://8th-dev.com/compare.html) 8th with other languages!


# Quick introduction for users of “mainstream” languages
## Quick introduction for users of “mainstream” languages

If you’re coming from C or Java or most more common languages, you may find 8th a bit puzzling. To help set you on the right path, here are some of the primary differences between 8th and “the mainstream”, as well as some helpful hints:

Expand Down
164 changes: 44 additions & 120 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
@@ -1,144 +1,68 @@
<!---
This file is inspired by, and adapted for the 8th track from:
https://github.com/exercism/java/blob/main/exercises/shared/.docs/tests.md.
--->

# Tests

Choose your current OS:

* [Windows](##windows)
* [macOS](##macos)
* [Linux](##linux)

# Running the Tests

## Windows

1. Open a Command Prompt.

2. Get the first exercise:

```batchfile
C:\Users\USERNAME> exercism download --exercise hello-world --track 8th
```
3. Change directory into the exercise folder:
```batchfile
C:\Users\USERNAME> cd C:\Users\USERNAME\exercism\8th\hello-world
```
4. Run the tests:
```batchfile
C:\Users\USERNAME\exercism\8th\hello-world> tester.bat
```
*(Don't worry if the tests fail when you first run them, this is how you begin each exercise.)*
5. Limit the number of tests:
All defined tests are run. Reducing the number of tests executed is done as follows:
- Open the *-tests.8th file in a text editor.
- Place a backslash and a space in front of each test to be disabled.
- Save the file.
Disable all but one, then progressively re-enable tests until all tests pass.
6. Solve the exercise.
Read through the `instructions.md` and see how to solve the exercise ([view on GitHub](https://github.com/exercism/8th/blob/main/exercises/practice/hello-world/.docs/instructions.md)).
Good luck, have fun and welcome to the 8th track!
If you get stuck, at any point, don't forget to reach out for [help](https://exercism.org/cli-walkthrough).
----
## macOS
1. Open a Terminal window.
2. Get the first exercise:
```
$ exercism download --exercise hello-world --track 8th
```
3. Change directory into the exercise folder:
```
$ cd /Users/USERNAME/exercism/8th/hello-world
```
4. Run the tests:
```
$ bash tester.sh
```
*(Don't worry if the tests fail when you first run them, this is how you begin each exercise.)*
5. Limit the number of tests:
All defined tests are run. Reducing the number of tests executed is done as follows:
- Open the *-tests.8th file in a text editor.
- Place a backslash and a space in front of each test to be disabled.
- Save the file.
Disable all but one, then progressively re-enable tests until all tests pass.
You can use the online editor on the Exercism website to solve the exercises.
Or, download the exercises to your computer, solve them locally and then submit them to Exercism.
The rest of this document talks about working locally.

6. Solve the exercise.
## Exercism CLI

Read through the `instructions.md` and see how to solve the exercise ([view on GitHub](https://github.com/exercism/8th/blob/main/exercises/practice/hello-world/.docs/instructions.md)).
You will need the `exercism` command-line tool to download and submit exercises.
See [the exercism cli documentation][exercism-cli] for instructions to download and configure it.

To download an exercise, do this:

Good luck, have fun and welcome to the 8th track!
```bash
exercism download --track 8th --exercise hello-world
```

If you get stuck, at any point, don't forget to reach out for [help](https://exercism.org/cli-walkthrough).
And change to the exercise directory:

```bash
cd /path/to/your/exercism_workspace/8th/hello-world
```

----
or if you are on Windows:

## Linux
```cmd
cd \path\to\your\exercism_workspace\8th\hello-world
```

1. Open a Terminal window.
Note you can get your exercism workspace using the `exercism configure` command.

2. Get the first exercise:
## Testing locally

```
$ exercism download --exercise hello-world --track 8th
```
To run the tests for an exercise, you must be in the correct exercise directory.
Then launch the tests with this command:

2. Change directory into the exercise folder:
```bash
8th test.8th
```

```
$ cd /home/USERNAME/exercism/8th/hello-world
```
## Skipped tests

4. Run the tests:
Solving an exercise means making all its tests pass.
By default, only one test (the first one) is executed when you run the tests.
This is intentional, as it allows you to focus on just making that one test pass.
Once it passes, you can enable the next test by moving the `SKIP-REST-OF-TESTS` line below it.

```
$ bash tester.sh
```
*(Don't worry if the tests fail when you first run them, this is how you begin each exercise.)*
### Overriding skips

5. Limit the number of tests:
To run all tests, including the ones after the `SKIP-REST-OF-TESTS` word, you can set an environment variable `RUN_ALL_TESTS` to the value `true`.
One way to set this just for the duration of running the tests is (macOS and Linux):

All defined tests are run. Reducing the number of tests executed is done as follows:
- Open the *-tests.8th file in a text editor.
- Place a backslash and a space in front of each test to be disabled.
- Save the file.
```bash
RUN_ALL_TESTS=true 8th test.8th
```

Disable all but one, then progressively re-enable tests until all tests pass.
6. Solve the exercise.
## Submit your solution

Read through the `instructions.md` and see how to solve the exercise ([view on GitHub](https://github.com/exercism/8th/blob/main/exercises/practice/hello-world/.docs/instructions.md)).
To upload your solution to the Exercism website using the exercism tool:

```bash
exercism submit
```

Good luck, have fun and welcome to the 8th track!
Note that you can upload your code even if it is not passing all the tests.
This is good if you are stuck and need some help from a mentor.

If you get stuck, at any point, don't forget to reach out for [help](https://exercism.org/cli-walkthrough).
[exercism-cli]: https://exercism.org/docs/using/solving-exercises/working-locally
3 changes: 2 additions & 1 deletion exercises/practice/acronym/acronym-tests.8th
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
9 tests

"ignoring punctuation and casing" "CMOS" ( "Complementary metal-oxide semiconductor" acronym ) test_eqs
SKIP-REST-OF-TESTS
"ignores punctuation" "FIFO" ( "First In, First Out" acronym ) test_eqs
"from phrases with acronyms" "GIMP" ( "GNU Image Manipulation Program" acronym ) test_eqs
"from phrases with apostrophes" "HC" ( "Halley's Comet" acronym ) test_eqs
Expand All @@ -9,5 +11,4 @@
"from phrases with consecutive delimiters" "SIMUFTA" ( "Something - I made up from thin air" acronym ) test_eqs
"from phrases with underscore emphasis" "TRNT" ( "The Road _Not_ Taken" acronym ) test_eqs


end-of-tests
45 changes: 33 additions & 12 deletions exercises/practice/acronym/test-words.8th
Original file line number Diff line number Diff line change
@@ -1,94 +1,115 @@
needs console/loaded
con:onBlack

-1 var, test-count
var tests-passed
var tests-failed
var tests-skipped

true var, run-test
: SKIP-REST-OF-TESTS false run-test ! ;

: tests \ n --
test-count !
;

: test-passed \ s --
tests-passed @ n:1+ tests-passed !
con:green . space " ... OK" . con:white cr
1 tests-passed n:+!
con:green con:onBlack . space " ... OK" . con:white con:onBlack cr
;

: test-skipped \ s --
1 tests-skipped n:+!
con:cyan con:onBlack . space " ... SKIPPED" . con:white con:onBlack cr
;

: test-failed \ s --
tests-failed @ n:1+ tests-failed !
con:red . space " ... FAIL" . con:white cr
1 tests-failed n:+!
con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr
;

: isword? \ x -- x f
dup >kind ns:w n:=
;

: run-test? \ -- T
run-test @ if true else "RUN_ALL_TESTS" getenv n:>bool then
;

: test_eq \ s x w -- | s w x --
run-test? !if 2drop test-skipped ;; then
isword? !if swap then
w:exec
n:=
if test-passed else test-failed then
;

: test_eqs \ s x w -- | s w x --
run-test? !if 2drop test-skipped ;; then
isword? !if swap then
w:exec
s:=
if test-passed else test-failed then
;

: test_true \ s w --
run-test? !if drop test-skipped ;; then
w:exec
if test-passed else test-failed then
;

: test_false \ s w --
run-test? !if drop test-skipped ;; then
w:exec
if test-failed else test-passed then
;

: test_null \ s w --
run-test? !if drop test-skipped ;; then
w:exec
null? nip
if test-passed else test-failed then
;

\ compare arrays by testing elements with string equality
: test_eqa \ s x w -- | s w x --
run-test? !if 2drop test-skipped ;; then
isword? !if swap then
w:exec
' s:= a:= 2nip
if test-passed else test-failed then
;


: test_map_eq \ m w -- | w m --
: test_map_eq \ s m w -- | s w m --
run-test? !if 2drop test-skipped ;; then
isword? !if swap then
w:exec
' n:= m:= 2nip
if test-passed else test-failed then
;

: test_map_neq \ m w -- | w m --
: test_map_neq \ s m w -- | s w m --
run-test? !if 2drop test-skipped ;; then
isword? !if swap then
w:exec
' n:= m:= 2nip
if test-failed else test-passed then
;

\ Num passed + num failed should == num tests
\ Num passed + num skipped + num failed should == num tests
: all-tests-run? \ -- T
tests-passed @ tests-failed @ n:+ test-count @ n:=
tests-passed @ tests-skipped @ tests-failed @ n:+ n:+
test-count @ n:=
;

( all-tests-run?
!if con:red "... FAIL - not all tests completed" . con:white cr then
!if con:red con:onBlack "... FAIL - not all tests completed" . con:white con:onBlack cr then
) onexit

\ Print a summary of the tests run
( con:white
( con:white con:onBlack
test-count @ . space "tests planned - " .
tests-passed @ . space "passed - " .
tests-skipped @ . space "skipped - " .
tests-failed @ . space "failed" . cr
) onexit

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/affine-cipher/affine-cipher-tests.8th
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"encode yes"
( "yes" 5 7 >code ) "xbt" test_eqs

SKIP-REST-OF-TESTS
"encode no"
( "no" 15 18 >code ) "fu" test_eqs

Expand Down Expand Up @@ -48,5 +49,4 @@
"decode with a not coprime to m"
( "Test" 13 5 code> ) test_null


end-of-tests
Loading

0 comments on commit fa3e12e

Please sign in to comment.