Repository navigation
Add Jinja2 templating - #351
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
|
Hello 👋 Thanks for your PR. This repo does not currently have dedicated maintainers. Our cross-track maintainers team will attempt to review and merge your PR, but it will likely take longer for your PR to be reviewed. If you enjoy contributing to Exercism and have a track-record of doing so successfully, you might like to become an Exercism maintainer for this track. Please feel free to ask any questions, or chat to us about anything to do with this PR or the reviewing process on the Exercism forum. (cc @exercism/cross-track-maintainers) |
|
Use Once the template is filled in, run I wondered about adding a linting/formatting step, but didn't like the options. |
|
https://github.com/raviqqe/schemat looks a bit promising for a formatter, but I haven't tested it yet. It seems to be opinionated though since I don't see configuration info. |
|
I noticed schemat, but haven't tried it yet. When we're already juggling Scheme and Python (plus Makefiles and shell scripts), adding Rust to the mix is not very appealing. I'm pretty relaxed about leaving this out. Scheme isn't fussy about formatting, I don't think there is anything equivalent to PEP 8, and a direct translation of the j2 template gives a decent, human-readable test file. |
|
Is anything blocking approval of this, other than @exercism/cross-track-maintainers being very busy people? It's messing up some other stuff I want to PR. |
This is the kind of knowledge that belongs in a CONTRIBUTING.md doc. Hint hint. |
Co-authored-by: Glenn Jackman <glenn.jackman@gmail.com>
|
|
||
| Prerequisites | ||
| - Python 3.x (it may work with Python 2.x, but that is untested) | ||
| - Up-to-date local version of the https://github.com/exercism/problem-specifications.git repo |
There was a problem hiding this comment.
Note that configlet caches the repo in $XDG_CACHE_DIR/exercism/configlet/proglem-specifications
XDG_CACHE_DIR is by default $HOME/.cache
There was a problem hiding this comment.
In my (partial) defence, @IsaacG wrote that bit. Actually, he wrote most of the Python...
There was a problem hiding this comment.
I don't recall writing the update-new-exercise-files.py file. Just the generate_tests.py. That file has a problem_spec_dir() which does mimic the configlet behavior IIUC. It may be possible to reuse some logic across the Python files.
glennj
left a comment
There was a problem hiding this comment.
I didn't really review the python scripts, not my area of expertise.
| def template_stub() -> str: | ||
| return textwrap.dedent("""\ | ||
| {{ header }} |
There was a problem hiding this comment.
In some of my repos, like exercism/moonscript, I store the generator template in /exercises/shared/templates -- that shared directory is underused IMO
Co-authored-by: Glenn Jackman <glenn.jackman@gmail.com>
|
Thanks for the review. I'll merge for now, and add a I'll probably move the template-stub code to a separate file, both here and on the (closely similar) Fortran track. |
Apologies. I missed that this was blocked on cross-track-maintainers and assumed there were other Scheme maintainers. |
|
The track was unmaintained for a long time. I became sole maintainer about a week ago - hesitantly, but I'd rather not see it die through neglect. |
I think this is basically working. I've updated a couple of exercises with templates to test it.
No doubt there will be further refinements to the Python scripts as we get more experience.
Collatz Conjecture is cheating a bit, for backwards compatibility. The old version had no tests for invalid input (<1), so I set
include = falsefor the two tests expecting errors. We can update it later, but be sure to avoid retesting: old solutions don't just fail benignly, they get in an infinite loop and time out.