You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now tests are compiled in and executed only if test is specified on command line. Testing mechanism is in zig/std/special/test_runner.zig and its use is probably hardcoded.
This arrangement is not the only possible one. For example, one may prefer to always compile tests in (in debug mode) and to run tests from recently modified files automatically, whenever the executable runs.
I propose:
Expand builtin.__zig_test_fn_slice structure. Add source file name and line for every test. Add how "old" every test is (e.g. how many minutes passed since the source file was last modified).
Add "currently running test file/line/name" members into the same structure. These values would be set/unset by the test runner. assert then could inspect them and show more detailed error message. This is above stack tracing feature: stack trace is rather clumsy to parse.
Document how can one replace the default test runner. (Modifying stdlib is IMHO valid choice.)
This is related to #531 (comment). If one can discover at runtime whether tests were enabled or not, he may then invoke/not try to invoke the most recent ones.
Yet more ambitious testing mechanism may ensure that tests do not exceed certain time limit. (If they do there's grave performance regression.) It may look like:
test "test with default timeout, say 20 milliseconds"
{
...
}
test(100) "test which is expected take no more than 100 milliseconds"
{
...
}
If a test exceeds the timeout test runner may execute it few more times, to eliminate influence of imprecise time measuring (could be ~15 milliseconds on Windows) and influence of OS activities.
The text was updated successfully, but these errors were encountered:
If the suggestion here ( #531 (comment) ) is implemented the Zig compilation mode flags (debug/release/tests/...) may be also "exported" to C as preprocessor definitions.
Right now tests are compiled in and executed only if
test
is specified on command line. Testing mechanism is inzig/std/special/test_runner.zig
and its use is probably hardcoded.This arrangement is not the only possible one. For example, one may prefer to always compile tests in (in debug mode) and to run tests from recently modified files automatically, whenever the executable runs.
I propose:
Expand
builtin.__zig_test_fn_slice
structure. Add source file name and line for every test. Add how "old" every test is (e.g. how many minutes passed since the source file was last modified).Add "currently running test file/line/name" members into the same structure. These values would be set/unset by the test runner.
assert
then could inspect them and show more detailed error message. This is above stack tracing feature: stack trace is rather clumsy to parse.Document how can one replace the default test runner. (Modifying stdlib is IMHO valid choice.)
This is related to #531 (comment). If one can discover at runtime whether tests were enabled or not, he may then invoke/not try to invoke the most recent ones.
Yet more ambitious testing mechanism may ensure that tests do not exceed certain time limit. (If they do there's grave performance regression.) It may look like:
If a test exceeds the timeout test runner may execute it few more times, to eliminate influence of imprecise time measuring (could be ~15 milliseconds on Windows) and influence of OS activities.
The text was updated successfully, but these errors were encountered: