diff options
| author | Robin Voetter <robin@voetter.nl> | 2023-10-08 21:00:20 +0200 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-10-15 14:00:26 +0200 |
| commit | 3ca1f888980641c9d9aff02100f277833b988413 (patch) | |
| tree | 8d7dd1f1fcaeca8eec03bac05729290a63ea07f1 /lib/std/testing.zig | |
| parent | e2e4e1f8b4fa5d8394cb571d00b4b62eacea97df (diff) | |
| download | zig-3ca1f888980641c9d9aff02100f277833b988413.tar.gz zig-3ca1f888980641c9d9aff02100f277833b988413.zip | |
std.testing: disable expectEqualSlices printing for spirv
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index d4d162721d..95f1b156c1 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -21,13 +21,13 @@ pub var base_allocator_instance = std.heap.FixedBufferAllocator.init(""); /// TODO https://github.com/ziglang/zig/issues/5738 pub var log_level = std.log.Level.warn; +// Disable printing in tests for simple backends. +pub const backend_can_print = builtin.zig_backend != .stage2_spirv64; + fn print(comptime fmt: []const u8, args: anytype) void { if (@inComptime()) { @compileError(std.fmt.comptimePrint(fmt, args)); - } else { - // Disable printing in tests for simple backends. - if (builtin.zig_backend == .stage2_spirv64) return; - + } else if (backend_can_print) { std.debug.print(fmt, args); } } @@ -304,6 +304,10 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const break :diff_index if (expected.len == actual.len) return else shortest; }; + if (!backend_can_print) { + return error.TestExpectedEqual; + } + print("slices differ. first difference occurs at index {d} (0x{X})\n", .{ diff_index, diff_index }); // TODO: Should this be configurable by the caller? |
