|
switch (self.stdio) { |
|
.check => |checks| for (checks.items) |check| switch (check) { |
|
.expect_stderr_exact => |expected_bytes| { |
|
assert(!result.stdio.stderr_null); |
|
if (!mem.eql(u8, expected_bytes, result.stdio.stderr)) { |
|
return step.fail( |
|
\\ |
|
\\========= expected this stderr: ========= |
|
\\{s} |
|
\\========= but found: ==================== |
|
\\{s} |
|
\\========= from the following command: === |
|
\\{s} |
|
, .{ |
|
expected_bytes, |
|
result.stdio.stderr, |
|
try Step.allocPrintCmd(arena, self.cwd, final_argv), |
|
}); |
|
} |
|
}, |
|
.expect_stderr_match => |match| { |
|
assert(!result.stdio.stderr_null); |
|
if (mem.indexOf(u8, result.stdio.stderr, match) == null) { |
|
return step.fail( |
|
\\ |
|
\\========= expected to find in stderr: ========= |
|
\\{s} |
|
\\========= but stderr does not contain it: ===== |
|
\\{s} |
|
\\========= from the following command: ========= |
|
\\{s} |
|
, .{ |
|
match, |
|
result.stdio.stderr, |
|
try Step.allocPrintCmd(arena, self.cwd, final_argv), |
|
}); |
|
} |
|
}, |
|
.expect_stdout_exact => |expected_bytes| { |
|
assert(!result.stdio.stdout_null); |
|
if (!mem.eql(u8, expected_bytes, result.stdio.stdout)) { |
|
return step.fail( |
|
\\ |
|
\\========= expected this stdout: ========= |
|
\\{s} |
|
\\========= but found: ==================== |
|
\\{s} |
|
\\========= from the following command: === |
|
\\{s} |
|
, .{ |
|
expected_bytes, |
|
result.stdio.stdout, |
|
try Step.allocPrintCmd(arena, self.cwd, final_argv), |
|
}); |
|
} |
|
}, |
|
.expect_stdout_match => |match| { |
|
assert(!result.stdio.stdout_null); |
|
if (mem.indexOf(u8, result.stdio.stdout, match) == null) { |
|
return step.fail( |
|
\\ |
|
\\========= expected to find in stdout: ========= |
|
\\{s} |
|
\\========= but stdout does not contain it: ===== |
|
\\{s} |
|
\\========= from the following command: ========= |
|
\\{s} |
|
, .{ |
|
match, |
|
result.stdio.stdout, |
|
try Step.allocPrintCmd(arena, self.cwd, final_argv), |
|
}); |
|
} |
|
}, |
Extracted from #14647.
zig/lib/std/Build/RunStep.zig
Lines 87 to 105 in b3af5d0
zig/lib/std/Build/CheckFileStep.zig
Lines 56 to 81 in b3af5d0
zig/lib/std/Build/RunStep.zig
Lines 734 to 807 in b3af5d0
zig/lib/std/testing.zig
Lines 609 to 631 in b3af5d0
All this logic should be unified.
Plus there should be more kinds of checks: