In test case 1 and 2, remove the `i` variable and use `ex.number()`
instead.
In test case 2, when checking the exercise output from stderr, also
check that stdout is empty and vice versa.
In order to simplify the code, the heal function is called during the
configuration phase, thus resulting in the function being always called
when the build.zig file is run.
This behavior unfortunately causes a serious issue when the user fix a
broken exercise and, during the next step, the heal function tries to heal
the fixed exercise resulting in GNU patch assuming an attempt to reverse
a patch, waiting for input from the terminal.
Run the heal function from the new HealStep step, so that it is called
only during tests.
Rename the outdir constant to work_path, for consistency with build.zig.
Fixes#272
The name "baseName" is confusing, since it refers to the UNIX basename
command, and not to the basename function in some programming languages
including Zig.
Use the std.fs.path.stem function to remove the file extension, instead
of slicing.
Remove the use of the assertion, since it is no longer necessary.
Instead, add a check to ensure that the exercise must be a Zig source
file in the validate_exercises function.
Update the validate_exercises function to check the last exercise, too.
The POSIX standard says that the patch command should not use stdout,
but GNU patch writes the message:
patching file patches/healed/xxx.zig (read from exercises/xxx.zig).
Add the -s flag to suppress these messages.
Note that the heal function from test/tests.zig is called when running
`zig build -Dhealed` because it is executed in the configure phase.
The deadlock was caused by setting stdout behavior to ignore, when
spawning the patch command. When the patch command writes to devnull it
causes some errors and a deadlock.
The cause of the bug is probably Zig using `\Device\Null` from `ntdll`
while git-bash uses `NUL` from `kernel32`.
In test case 1 and 2, move the -Dhealed option before the -Dn option,
for consistency.
Fix a typo in cmd.setName in test case 1 and 2.
Remove a confusing comment in test case 1.
The current cleanup code is incorrect, since it may delete the healed
directory while one test case is running.
The solution is to make each test case isolate, with its own setup and
teardown. Unfortunately it is currently not possible, since each test
case modify the same directory.
Disable the cleanup step, until a better solution is found.
Currently, if there is an error when creating the patches/healed
directory, the error message will be printed on stderr, but the build
runner will report the test as being successful.
Add the fail function and the FailStep, so that the error will be
correctly handled by the build runner.
Remove the PatchStep, and instead add the heal function so that all the
exercises are healed before starting the tests.
The heal function executes at the configuration phase, but the possible
error is handled by the build runner.
Simplify the code finding the exercise number from the exercise index,
when the -Dn option is set. This is now possible since the exercise
numbers have no holes.
Add the validate_exercises function to check that exercise number are in
the correct order, and call it at the start of the build function.
Add tests, with 2 test cases.