Problem
bashunit learn writes a starter file for each lesson, and 7 of the 10 templates do not parse. A function body of only comments is a syntax error in bash, and the templates are full of them — 28 comment-only bodies across the lessons:
functiontear_down() {
# TODO: Clean up test files
}So a learner who runs the lesson to generate the file, fills in one TODO and runs again gets:
challenge_test.sh: line 72: syntax error near unexpected token `}'
✗ Error: Source
That says nothing about the lesson, and the invalid file came from bashunit itself. It is the first thing a newcomer to the tool sees.
The fix needs two halves
Adding a : no-op to each body makes the file parse — and on its own that is worse, because an untouched template then passes the lesson:
| template | run | result |
|---|
| comments only (today) | plain | syntax error |
valid with : | plain | exit 0 — lesson completed with no work done |
valid with : | --fail-on-risky | exit 1 |
| actually solved | --fail-on-risky | exit 0 |
bashunit::learn::run_lesson_test runs "$BASHUNIT_ROOT_DIR/bashunit" "$test_file" --simple and treats exit 0 as success. A test with no assertions is risky, and risky exits 0 by default.
So: make the templates parse, and run the lesson's verification with --fail-on-risky. The learner then sees "risky: no assertions" — which is the actual state of their work — instead of a bash syntax error, and cannot complete a lesson without writing an assertion.
Verified
All 16 assertions the lessons teach exist in src/assert/, so the taught API itself is accurate; this is about the generated files.
Problem
bashunit learnwrites a starter file for each lesson, and 7 of the 10 templates do not parse. A function body of only comments is a syntax error in bash, and the templates are full of them — 28 comment-only bodies across the lessons:So a learner who runs the lesson to generate the file, fills in one TODO and runs again gets:
That says nothing about the lesson, and the invalid file came from bashunit itself. It is the first thing a newcomer to the tool sees.
The fix needs two halves
Adding a
:no-op to each body makes the file parse — and on its own that is worse, because an untouched template then passes the lesson:::--fail-on-risky--fail-on-riskybashunit::learn::run_lesson_testruns"$BASHUNIT_ROOT_DIR/bashunit" "$test_file" --simpleand treats exit 0 as success. A test with no assertions is risky, and risky exits 0 by default.So: make the templates parse, and run the lesson's verification with
--fail-on-risky. The learner then sees "risky: no assertions" — which is the actual state of their work — instead of a bash syntax error, and cannot complete a lesson without writing an assertion.Verified
All 16 assertions the lessons teach exist in
src/assert/, so the taught API itself is accurate; this is about the generated files.