std.testing: use debug Io instance in expectEqualSlices

This commit is contained in:
Andrew Kelley 2025-12-26 13:26:14 -08:00
parent 28639bd6d7
commit eb0d5b1377

View file

@ -368,11 +368,11 @@ 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;
if (io.lockStderr(&.{}, null)) |stderr| {
defer io.unlockStderr();
const w = &stderr.file_writer.interface;
failEqualSlices(T, expected, actual, diff_index, w, stderr.terminal_mode) catch {};
} else |_| {}
// Intentionally using the debug Io instance rather than the testing Io instance.
const stderr = std.debug.lockStderr(&.{});
defer std.debug.unlockStderr();
const w = &stderr.file_writer.interface;
failEqualSlices(T, expected, actual, diff_index, w, stderr.terminal_mode) catch {};
return error.TestExpectedEqual;
}