-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: enable testing panics in mainTerminal #15991
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matu3ba
force-pushed
the
enable_testing_panics
branch
from
June 9, 2023 23:04
e4796b1
to
9c13fcc
Compare
Question: Is the approach lit? Should I include it like this in Server with test code or are there any concerns? // testfile.zig
const std = @import("std");
const testing = std.testing;
test "panic" {
try testing.spawnExpectPanic("test1");
try testing.expectEqual(@as(u8, 1), @as(u32, 1));
@panic("test1");
}
test "wrong_panic" {
try testing.spawnExpectPanic("test1");
@panic("test2");
}
// Test [2/3] test.wrong_panic... Signal: 6
// Test [2/3] test.wrong_panic... FAIL expected_panic_msg: 'test1', got: 'test2
test "no panic but one was expected" {
try testing.spawnExpectPanic("test3");
}
// Test [2/3] test.no panic but one was expected... error.SpawnZigTest
// Test [2/3] test.no panic but one was expected... spawning '/home/misterspoon/dev/git/zi/zig/enable_testing_pan
ics/zig-cache/o/4b2b4b4abad5f54a10c57ea01651fa0d/test --test_panic_index 2'
// Test [2/3] test.no panic but one was expected... FAIL term exited, status: 0)
// stdout: ()
// stderr: ()
// unhandled case:
// test "testme" {
// @panic("123123");
// }
|
later after design issues resolved or approach clarified:
|
matu3ba
force-pushed
the
enable_testing_panics
branch
from
June 13, 2023 21:55
3fd8734
to
8ac2f53
Compare
andrewrk
force-pushed
the
enable_testing_panics
branch
from
October 19, 2023 00:40
8ac2f53
to
7afbfc5
Compare
This
|
The user can use std.testing.spawnExpectPanic() in a test to spawn a child process, which must panic or the test fails. Internally, - 1. is_panic_parentproc is set from the cli arguments for simple reproduction of both test spawn and panic behavior, - 2. panic_msg is set as threadlocal, if comptime-detectable capabilities exist, to enable multithreaded processing and user-customized messages, - 3. error.SpawnZigTest is returned to the test_runner.zig - 4. the test_runner spawns a child_process on correct usage - 5. the child_process expected to panic executes only one test block This means, that only one @Panic is possible within a test block and that no follow-up code after the @Panic in the test block can be run. This commit does not add the panic test capability to the server yet, since there are open design questions how many processes should be spawned at the same time and how to manage time quotas to prevent unnecessary slowdowns. Supersedes ziglang#14351. Work on ziglang#1356.
Also add the signal to the user as additional info.
matu3ba
force-pushed
the
enable_testing_panics
branch
from
October 20, 2023 15:03
02efbfa
to
87d7eb0
Compare
Closing abandoned pull request (last update 3 months ago, not passing CI checks) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The user can use std.testing.spawnExpectPanic() in a test to spawn a child process, which must panic or the test fails. Internally,
This means, that only one @Panic is possible within a test block and that no follow-up code after the @Panic in the test block can be run.
This commit does not add the panic test capability to the server yet, since there are open design questions how many processes should be spawned at the same time and how to manage time quotas to prevent unnecessary slowdowns.
Supersedes #14351.
Work on #1356.