| author | |
| committer | |
| log | e68ae8d7a1e78a25392e271d7ca894e0f09aa218 |
| tree | b22e9e6b67cc782635e614e0a010179f5c3c4d7d |
| parent | 54e4a3456ce2d5a497a166b94737fe5407052921 |
4 files changed, 31 insertions(+), 26 deletions(-)
lib/compiler/test_runner.zig+12-5| ... | @@ -405,15 +405,22 @@ pub fn fuzz( | ... | @@ -405,15 +405,22 @@ pub fn fuzz( |
| 405 | testOne(ctx, input.toSlice()) catch |err| switch (err) { | 405 | testOne(ctx, input.toSlice()) catch |err| switch (err) { |
| 406 | error.SkipZigTest => return, | 406 | error.SkipZigTest => return, |
| 407 | else => { | 407 | else => { |
| 408 | std.debug.lockStdErr(); | 408 | const stderr = std.debug.lockStderrWriter(&.{}); |
| 409 | if (@errorReturnTrace()) |trace| std.debug.dumpStackTrace(trace); | 409 | p: { |
| 410 | std.debug.print("failed with error.{t}\n", .{err}); | 410 | if (@errorReturnTrace()) |trace| { |
| 411 | std.debug.writeStackTrace(trace, &stderr.interface, stderr.mode) catch break :p; | ||
| 412 | } | ||
| 413 | stderr.interface.print("failed with error.{t}\n", .{err}) catch break :p; | ||
| 414 | stderr.interface.flush() catch break :p; | ||
| 415 | } | ||
| 416 | stderr.interface.flush() catch {}; | ||
| 411 | std.process.exit(1); | 417 | std.process.exit(1); |
| 412 | }, | 418 | }, |
| 413 | }; | 419 | }; |
| 414 | if (log_err_count != 0) { | 420 | if (log_err_count != 0) { |
| 415 | std.debug.lockStdErr(); | 421 | const stderr = std.debug.lockStderrWriter(&.{}); |
| 416 | std.debug.print("error logs detected\n", .{}); | 422 | stderr.interface.print("error logs detected\n", .{}) catch {}; |
| 423 | stderr.interface.flush() catch {}; | ||
| 417 | std.process.exit(1); | 424 | std.process.exit(1); |
| 418 | } | 425 | } |
| 419 | } | 426 | } |
lib/std/debug/simple_panic.zig+3-3| ... | @@ -14,9 +14,9 @@ const std = @import("../std.zig"); | ... | @@ -14,9 +14,9 @@ const std = @import("../std.zig"); |
| 14 | pub fn call(msg: []const u8, ra: ?usize) noreturn { | 14 | pub fn call(msg: []const u8, ra: ?usize) noreturn { |
| 15 | @branchHint(.cold); | 15 | @branchHint(.cold); |
| 16 | _ = ra; | 16 | _ = ra; |
| 17 | std.debug.lockStdErr(); | 17 | const stderr = std.debug.lockStderrWriter(&.{}); |
| 18 | const stderr: std.Io.File = .stderr(); | 18 | stderr.interface.writeAll(msg) catch {}; |
| 19 | stderr.writeAll(msg) catch {}; | 19 | stderr.interface.flush(msg) catch {}; |
| 20 | @trap(); | 20 | @trap(); |
| 21 | } | 21 | } |
| 22 | 22 |
lib/std/process.zig+11-13| ... | @@ -1841,21 +1841,19 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 { | ... | @@ -1841,21 +1841,19 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 { |
| 1841 | } | 1841 | } |
| 1842 | } | 1842 | } |
| 1843 | 1843 | ||
| 1844 | /// Indicate that we are now terminating with a successful exit code. | 1844 | /// Indicate intent to terminate with a successful exit code. |
| 1845 | /// In debug builds, this is a no-op, so that the calling code's | 1845 | /// |
| 1846 | /// cleanup mechanisms are tested and so that external tools that | 1846 | /// In debug builds, this is a no-op, so that the calling code's cleanup |
| 1847 | /// check for resource leaks can be accurate. In release builds, this | 1847 | /// mechanisms are tested and so that external tools checking for resource |
| 1848 | /// calls exit(0), and does not return. | 1848 | /// leaks can be accurate. In release builds, this calls `exit` with code zero, |
| 1849 | pub fn cleanExit() void { | 1849 | /// and does not return. |
| 1850 | if (builtin.mode == .Debug) { | 1850 | pub fn cleanExit(io: Io) void { |
| 1851 | return; | 1851 | if (builtin.mode == .Debug) return; |
| 1852 | } else { | 1852 | _ = io.lockStderrWriter(&.{}); |
| 1853 | std.debug.lockStdErr(); | 1853 | exit(0); |
| 1854 | exit(0); | ||
| 1855 | } | ||
| 1856 | } | 1854 | } |
| 1857 | 1855 | ||
| 1858 | /// Raise the open file descriptor limit. | 1856 | /// Request ability to have more open file descriptors simultaneously. |
| 1859 | /// | 1857 | /// |
| 1860 | /// On some systems, this raises the limit before seeing ProcessFdQuotaExceeded | 1858 | /// On some systems, this raises the limit before seeing ProcessFdQuotaExceeded |
| 1861 | /// errors. On other systems, this does nothing. | 1859 | /// errors. On other systems, this does nothing. |
src/main.zig+5-5| ... | @@ -4429,12 +4429,12 @@ fn runOrTest( | ... | @@ -4429,12 +4429,12 @@ fn runOrTest( |
| 4429 | // the error message and invocation below. | 4429 | // the error message and invocation below. |
| 4430 | if (process.can_execv and arg_mode == .run) { | 4430 | if (process.can_execv and arg_mode == .run) { |
| 4431 | // execv releases the locks; no need to destroy the Compilation here. | 4431 | // execv releases the locks; no need to destroy the Compilation here. |
| 4432 | std.debug.lockStdErr(); | 4432 | _ = std.debug.lockStderrWriter(&.{}); |
| 4433 | const err = process.execve(gpa, argv.items, &env_map); | 4433 | const err = process.execve(gpa, argv.items, &env_map); |
| 4434 | std.debug.unlockStdErr(); | 4434 | std.debug.unlockStderrWriter(); |
| 4435 | try warnAboutForeignBinaries(io, arena, arg_mode, target, link_libc); | 4435 | try warnAboutForeignBinaries(io, arena, arg_mode, target, link_libc); |
| 4436 | const cmd = try std.mem.join(arena, " ", argv.items); | 4436 | const cmd = try std.mem.join(arena, " ", argv.items); |
| 4437 | fatal("the following command failed to execve with '{s}':\n{s}", .{ @errorName(err), cmd }); | 4437 | fatal("the following command failed to execve with '{t}':\n{s}", .{ err, cmd }); |
| 4438 | } else if (process.can_spawn) { | 4438 | } else if (process.can_spawn) { |
| 4439 | var child = std.process.Child.init(argv.items, gpa); | 4439 | var child = std.process.Child.init(argv.items, gpa); |
| 4440 | child.env_map = &env_map; | 4440 | child.env_map = &env_map; |
| ... | @@ -4448,8 +4448,8 @@ fn runOrTest( | ... | @@ -4448,8 +4448,8 @@ fn runOrTest( |
| 4448 | comp_destroyed.* = true; | 4448 | comp_destroyed.* = true; |
| 4449 | 4449 | ||
| 4450 | const term_result = t: { | 4450 | const term_result = t: { |
| 4451 | std.debug.lockStdErr(); | 4451 | _ = std.debug.lockStderrWriter(); |
| 4452 | defer std.debug.unlockStdErr(); | 4452 | defer std.debug.unlockStderrWriter(); |
| 4453 | break :t child.spawnAndWait(io); | 4453 | break :t child.spawnAndWait(io); |
| 4454 | }; | 4454 | }; |
| 4455 | const term = term_result catch |err| { | 4455 | const term = term_result catch |err| { |