aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test
AgeCommit message (Collapse)Author
2024-05-29Fixed the changes from reworking std.Progress.Chris Boesch
For details: https://github.com/ziglang/zig/pull/20059
2024-03-31Fix breaking zig change to @fieldParentPtr parameterskamidev
See https://github.com/ziglang/zig/pull/19470
2024-02-06Fix zig_exe location in Build structAlexander Saltanov
Reflect Zig breaking changes as of https://github.com/ziglang/zig/commit/105db13536b4dc2affe130cb8d2eee6c97c89bcd
2024-01-05Use std.Build.LazyPath over now removed std.Build.FileSource.drglove
See corresponding ziglang change here: https://github.com/ziglang/zig/issues/16353
2024-01-05Fix casing of std.build -> std.Build in tests.drglove
2023-10-05changed the patch files that we can also use them with busybox for testing ↵Chris Boesch
in Woodpecker
2023-10-04added woodpecker integrationChris Boesch
2023-05-15Refactor testing supportManlio Perillo
Following the implementation in `std.Build.Step.Compile, add the Kind type to differentiate between a normal executable and a test executable running zig tests. Replace `Exercise.run_test` field with `kind`. Compile the exercise in both the exe and test cases, reducing code duplication. Add the `check_output` and `check_test` methods in ZiglingStep, in order to differentiate the code checking a normal executable and a test executable. Update the tests to correctly check both the exe and test cases. Remove the temporary code added in commit 832772c.
2023-05-15Added testing exercise.Chris Boesch
2023-05-14tests: improve test case 3Manlio Perillo
Update test case 3 to check all exercises with an hint.
2023-05-14build: show the logo in named modeManlio Perillo
When running `zig build -Dn=n`, ensure that the logo is printed. Update the tests. Closes #214
2023-05-14build: simplify the named build modeManlio Perillo
Remove the following steps, since they are rarely (if never) used and only increase the complexity of the `build.zig` file: - install step (zig build -Dn=n install) - test step (zig build -Dn=n test) - start step (zig build -Dn=n start) The only remaining step is the default zigling step (zig build -Dn=n), where the user can choose the exercise to solve. Update the tests. Additionally, update CheckNamedStep and CheckStep so that they can share the same functions. Closes #299
2023-05-09Restore unit testsManlio Perillo
Commit dbd42bb (Cleaning up zig build output) broke the unit test. Always use exit code 2, instead of 0. This is the exit code used by the build runner to notify the compiler to not report any further diagnostics. Move the Ziglings logo from the `build` function scope to the global scope, and make it public so that tests.zig can use it to find the number of lines to skip, instead of using an hard coded value. Fixes #295
2023-05-09build: make literal paths portableManlio Perillo
Use fs.path.sep_str instead of a slash, in literal paths.
2023-05-09tests: remove the missing functions from RunStepManlio Perillo
Use directly the RunStep.addCheck method, instead.
2023-05-06build: use multiline string literals when necessaryManlio Perillo
Update the output and hint fields in the `exercises` slice to use a multiline string literal when the string have multiple lines or use the `"` character. This will greatly improve readability. Additionally, remove the trailing whitespace on each line and check it in the validate_exercises function. Update the output comparison logic in ZiglingStep, since the current code assumes that the string has only one line. Update test/tests.zig to use the new `CheckNamedStep` in test case 1, since RunStep.StdIo.Check is no longer able to correctly check the output. Fixes #283
2023-05-06build: make `Exercise.hint` optionalManlio Perillo
Use an optional type, instead of an empty string, since it is more idiomatic.
2023-05-05build: add the healed-path optionManlio Perillo
This is necessary in the unit tests, to ensure each test case use a different exercises directory. Update test/tests.zig to use the new healed-path option, ensuring that each temp directory is removed. In test case 3, 4 and 5, move case_step as the first step in the dependency chain. This will improve the build summary tree. In test case 5, remove the dependency to heal_step, since it is not necessary.
2023-05-04test: remove obsolete comment in the heal functionManlio Perillo
Remove the comment about using POSIX patch variant, since we now use the -s option.
2023-05-04test: fix doc-commentsManlio Perillo
CheckStep, FailStep, fail, HealStep and heal incorrectly used a normal comment, instead of a doc-comment. Additionally, improve the documentation for FailStep and HealStep.
2023-05-04test: improve test case 1 and 2Manlio Perillo
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.
2023-05-02test: don't run heal during configuration phaseManlio Perillo
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
2023-05-01build: rename Exercise.baseName to nameManlio Perillo
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.
2023-04-29test: make the patch command silentManlio Perillo
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.
2023-04-29test: fix deadlock on windows when running testsManlio Perillo
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`.
2023-04-24test: add a test for `zig build -Dn=1`Manlio Perillo
Add a test for `zig build -Dn=1` in order to test that a broken exercise will print an hint.
2023-04-24test: change the order of `zig build` optionsManlio Perillo
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.
2023-04-24test: add test for `zig build` and `zig build -Dn=1 start`Manlio Perillo
Add tests for `zig build` and `zig build -Dn=1 start`, in order to test that the all the exercises are processed in the correct order.
2023-04-24test: fix incorrect cleanup codeManlio Perillo
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.
2023-04-24test: refactorize the codeManlio Perillo
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.
2023-04-11build: improve PrintStep, SkipStep and PatchStep namesManlio Perillo
Use lover case for the step names. Add the exercise name for the SkipStep and PatchStep step name.
2023-04-11build: simplify code and add testsManlio Perillo
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.