Developer docs#11
Conversation
| Now complete the following steps: | ||
|
|
||
| - `config.json` - ensure that the new exercise data is correctly placed in order of difficulty and then alphabetically within that difficulty rating. | ||
| - implement exercise test cases, detailed in the [testing](#testing) section below. |
There was a problem hiding this comment.
We should be clear here that they need to make a template file first for the test generator to run. They then need to run the generator, making sure it runs a compilable ReScriptTest suite. Tests may need to be excluded from the tests.toml as well so that should be done as well. However, test generator may need to be rerun after you start working on the example solution and find a test for make sense for ReScript. Therefore we should mention or link out about the toml and how to skip a test there.
Most of that is in the below section but it should be inlined here or introduced beforehand.
Perhaps we break this into task-related sections:
Generating Tests?
Do this...
Updating An Existing Exercise?
Do this...
Adding A New Exercise?
Do this...
There was a problem hiding this comment.
The latest commit is draft 1 of this section. Please review. It is likely rough around the edges. I have commented out the old version for now, for reference.
There was a problem hiding this comment.
Can we remove the old version? Generally, it's old for a reason, and it's hard for me to skim through the file since I need to track regularly whether I'm in a commented-out section or not. The old versions if we need them are in the commit history.
There was a problem hiding this comment.
yes i will do that this evening, and start working on the suggestions
9e3f019 to
e2f1db1
Compare
|
I’ll take a look this weekend. |
|
|
||
| - **Configure the test template:** Edit `test_templates/<ExerciseName>_template.res`. Delete and uncomment the code where indicated. Use previous templates as examples of how to achieve what you need. Common comparator functions are found in `test_generator/Assertions.res` | ||
|
|
||
| - **Generate and run tests:** To build the test file and run it, run `make test EXERCISE=<exercise-slug>`. Your generated test cases are found in `exercises/<exercise-slug>/tests/<ExerciseName>_test.res`. Verify that the test cases accept and return the correct data. |
There was a problem hiding this comment.
| - **Generate and run tests:** To build the test file and run it, run `make test EXERCISE=<exercise-slug>`. Your generated test cases are found in `exercises/<exercise-slug>/tests/<ExerciseName>_test.res`. Verify that the test cases accept and return the correct data. | |
| - **Generate and run tests:** To build the test file and run it, run `make test EXERCISE=<exercise-slug>`. Your generated test cases are found in `exercises/practice/<exercise-slug>/tests/<ExerciseName>_test.res`. Verify that the test cases accept and return the correct data. |
|
|
||
| - **Generate and run tests:** To build the test file and run it, run `make test EXERCISE=<exercise-slug>`. Your generated test cases are found in `exercises/<exercise-slug>/tests/<ExerciseName>_test.res`. Verify that the test cases accept and return the correct data. | ||
|
|
||
| - **Creating new comparator functions:** If none of the comparator functions satisfy the exercise's test requirements, you can write a new one in `test_generator/Assertions.res` and `test_generator/AssersionGenerators.res`, following the guidelines at https://bloodyowl.github.io/rescript-test/assertions. The function should be returned as a string, so that our templating system can inject the code into the generated tests. |
There was a problem hiding this comment.
| - **Creating new comparator functions:** If none of the comparator functions satisfy the exercise's test requirements, you can write a new one in `test_generator/Assertions.res` and `test_generator/AssersionGenerators.res`, following the guidelines at https://bloodyowl.github.io/rescript-test/assertions. The function should be returned as a string, so that our templating system can inject the code into the generated tests. | |
| - **Creating new comparator functions:** If none of the comparator functions satisfy the exercise's test requirements, you can write a new one in `test_generator/Assertions.res` and `test_generator/AssertionGenerators.res`, following the guidelines at https://bloodyowl.github.io/rescript-test/assertions. The function should be returned as a string, so that our templating system can inject the code into the generated tests. |
|
|
||
| ```shell | ||
| bin/add-practice-exercise -a foobar -d 3 <exercise-slug> | ||
| # auto format files |
There was a problem hiding this comment.
configlet fmt -u prompts you on formatting the exercise. configlet fmt -uy would auto-confirm the prompt so that'd be the correct invocation for auto-formatting.
| ## Adding exercises | ||
|
|
||
| New (practice) exercises can be added via: | ||
| Run the [`fmt` command][configlet-fmt-link] to verify if exercises and configuration files are formatted correctly. Address any issues before pushing your changes: |
There was a problem hiding this comment.
configlet fmt works specifically on config.json files, nothing else.
| make test EXERCISE=<exercise-slug> | ||
| ``` | ||
|
|
||
| Run all exercise's tests: |
There was a problem hiding this comment.
| Run all exercise's tests: | |
| Run all exercises' tests: |
| - `exercises/practice/<exercise-slug>/.meta/tests.toml` - if any of these test cases are not relevant to the language, add `ignore = true` on a newline below the description | ||
| - `exercises/practice/<exercise-slug>/.meta/testTemplate.js` - edit this file to allow the test generator to automatically create test files. | ||
| - you must write your comparator functions - https://bloodyowl.github.io/rescript-test/assertions. | ||
| - common assertions with comparator functions are located at `test_generator/assertions.js`. Pass the required ones into the `assertionFunctions` array. |
There was a problem hiding this comment.
| - common assertions with comparator functions are located at `test_generator/assertions.js`. Pass the required ones into the `assertionFunctions` array. | |
| - common assertions with comparator functions are located at `test_generator/assertions.js`. Add the ones you'd like to use to the `assertionFunctions` array. |
|
|
||
| Tests are written using [rescript-test](https://bloodyowl.github.io/rescript-test/). Follow these steps when writing tests: | ||
|
|
||
| - **Filter canonical data:** Open `exercises/practice/<exercise-slug>/.meta/tests.toml`. If a specific canonical test case is not applicable to ReScript, add ignore = true below its description. E.g. |
There was a problem hiding this comment.
| - **Filter canonical data:** Open `exercises/practice/<exercise-slug>/.meta/tests.toml`. If a specific canonical test case is not applicable to ReScript, add ignore = true below its description. E.g. | |
| - **Filter canonical data:** Open `exercises/practice/<exercise-slug>/.meta/tests.toml`. If a specific canonical test case is not applicable to ReScript, add include = false below its description. E.g. |
e2f1db1 to
9b48f6e
Compare
|
I am not certain how to ensure the problem specification is the newest version. Running |
|
Hmm, I’m not sure to be honest so this will be a learning experience for me. I’ll take a look tonight or tomorrow. |
|
|
|
The CI isn't that terribly useful on PRs that don't interact with the problem-specifications submodule so I'll tweak the script so it only fires off in those situations. |
first draft of updating the repository's readme for contributing to the ReScript language track