Skip to content

Commit 91326ac

Browse files
0xNeshiIsaacG
andauthored
Add test script for local solution testing (#366)
* add test script * add readme * remove curDir * Apply suggestions from code review Co-authored-by: Isaac Good <[email protected]> * simplify * fix scripts * fix scripts --------- Co-authored-by: Isaac Good <[email protected]>
1 parent af52b03 commit 91326ac

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ _Thoughtful suggestions will likely result faster & more enthusiastic responses
5757

5858
<br>
5959

60-
## Testing
60+
## Verifying
6161

62-
Tests currently use Cairo v2.9.2 (included with Scarb v2.9.2).
62+
The track currently uses Cairo v2.9.2 (included with Scarb v2.9.2).
6363

64-
To test all exercises, run `./bin/verify-exercises`.
65-
This command will iterate over all exercises and check to see if their exemplar/example implementation passes all the tests.
64+
To verify all exercises, run `./bin/verify-exercises`.
65+
This command will iterate over all exercises and check to see if the stub compiles and the exemplar/example implementation passes all the tests.
6666

67-
To test a single exercise, run `./bin/verify-exercises <exercise-slug>`.
67+
To verify a single exercise, run `./bin/verify-exercises <exercise-slug>`.
68+
69+
# Testing
70+
71+
To check whether your solution passes the tests, just run `./bin/test <exercise-slug>`
6872

6973
### Track linting
7074

bin/test

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
# Synopsis:
4+
# Test the student's solution.
5+
6+
# Example: test two-fer
7+
# ./bin/test two-fer
8+
9+
set -eo pipefail
10+
11+
repo=$(git rev-parse --show-toplevel)
12+
13+
if (( "$#" != 1 )); then
14+
echo "Error: Incorrect number of arguments. This script requires exactly one argument."
15+
echo "Expected: './bin/test <exercise-slug>'"
16+
exit 1
17+
fi
18+
19+
slug="$1"
20+
21+
exercise_path="$repo/exercises/*/$slug"
22+
if [[ ! -d "$exercise_path" ]]; then
23+
echo "No such exercise $slug"
24+
exit 1
25+
fi
26+
27+
# Exercism sets a timeout limit for tests
28+
timeout 20 scarb --manifest-path "$exercise_path/Scarb.toml" cairo-test --include-ignored --test-kind integration || { echo "$slug timed out"; exit 1; }

0 commit comments

Comments
 (0)