File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -916,6 +916,26 @@ test "expectEqualDeep composite type" {
916
916
}
917
917
}
918
918
919
+ // TODO: test blocks can observe their own index fn argument.
920
+ // Do not leaks implementation details from the test runner into libstd.
921
+ // `test_fns_i` is index into builtin.test_functions set by test runner.
922
+ const TestFn_iT = if (! builtin .is_test ) u32 else void ;
923
+ threadlocal var test_fns_i : TestFn_iT = if (! builtin .is_test ) 0 else void ;
924
+
925
+ /// Send expected panic message to server from test runner, spawns itself as a
926
+ /// child process with the test number, tells the server pid and process group
927
+ /// of child and waits for the child process. The child process executes exactly
928
+ /// one test block up to panic or returns with error code 1.
929
+ /// If another expected panic message has been received by the server for the
930
+ /// same test block, then the test is marked as error.InvalidPanicMsg and the
931
+ /// child of the test runner thread is terminated via pid and process group,
932
+ ///
933
+ /// In case no server is desired, the to be run test block is provided as cli
934
+ /// argument.
935
+ pub fn expectPanic (msg : []const u8 ) ! void {
936
+ _ = msg ;
937
+ }
938
+
919
939
fn printIndicatorLine (source : []const u8 , indicator_index : usize ) void {
920
940
const line_begin_index = if (std .mem .lastIndexOfScalar (u8 , source [0.. indicator_index ], '\n ' )) | line_begin |
921
941
line_begin + 1
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ pub const Message = struct {
42
42
/// - 0 means not async
43
43
/// * expected_panic_msg: [tests_len]u32,
44
44
/// - null-terminated string_bytes index
45
- /// - 0 means does not expect pani
45
+ /// - 0 means does not expect panic
46
46
/// * string_bytes: [string_bytes_len]u8,
47
47
pub const TestMetadata = extern struct {
48
48
string_bytes_len : u32 ,
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ fn mainTerminal() void {
146
146
147
147
var leaks : usize = 0 ;
148
148
for (test_fn_list , 0.. ) | test_fn , i | {
149
+ std .testing .test_fns_i = i ;
149
150
std .testing .allocator_instance = .{};
150
151
defer {
151
152
if (std .testing .allocator_instance .deinit () == .leak ) {
You can’t perform that action at this time.
0 commit comments