| author | |
| committer | |
| log | fbe1bbf662e339dd5f3bc01c83d236d867726854 |
| tree | 61b7eb271e0804daf0b5ae62d404e96494b15f44 |
| parent | 488c15320b6e2848dd61245303e75f7577313ff2 |
8 files changed, 181 insertions(+), 211 deletions(-)
test/incremental2/change_panic_handler_explicit/0-main.zig deleted-46| ... | ... | @@ -1,46 +0,0 @@ |
| 1 | pub fn main() !u8 { | |
| 2 | var a: u8 = undefined; | |
| 3 | a = 255; | |
| 4 | _ = a + 1; | |
| 5 | return 1; | |
| 6 | } | |
| 7 | const no_panic = std.debug.no_panic; | |
| 8 | pub const panic = struct { | |
| 9 | pub const call = myPanic; | |
| 10 | pub fn integerOverflow() noreturn { | |
| 11 | @panic("integer overflow"); | |
| 12 | } | |
| 13 | pub const sentinelMismatch = no_panic.sentinelMismatch; | |
| 14 | pub const unwrapError = no_panic.unwrapError; | |
| 15 | pub const outOfBounds = no_panic.outOfBounds; | |
| 16 | pub const startGreaterThanEnd = no_panic.startGreaterThanEnd; | |
| 17 | pub const inactiveUnionField = no_panic.inactiveUnionField; | |
| 18 | pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder; | |
| 19 | pub const reachedUnreachable = no_panic.reachedUnreachable; | |
| 20 | pub const unwrapNull = no_panic.unwrapNull; | |
| 21 | pub const castToNull = no_panic.castToNull; | |
| 22 | pub const incorrectAlignment = no_panic.incorrectAlignment; | |
| 23 | pub const invalidErrorCode = no_panic.invalidErrorCode; | |
| 24 | pub const unexpectedErrorCode = no_panic.unexpectedErrorCode; | |
| 25 | pub const integerOutOfBounds = no_panic.integerOutOfBounds; | |
| 26 | pub const shlOverflow = no_panic.shlOverflow; | |
| 27 | pub const shrOverflow = no_panic.shrOverflow; | |
| 28 | pub const divideByZero = no_panic.divideByZero; | |
| 29 | pub const exactDivisionRemainder = no_panic.exactDivisionRemainder; | |
| 30 | pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds; | |
| 31 | pub const corruptSwitch = no_panic.corruptSwitch; | |
| 32 | pub const shiftRhsTooBig = no_panic.shiftRhsTooBig; | |
| 33 | pub const invalidEnumValue = no_panic.invalidEnumValue; | |
| 34 | pub const forLenMismatch = no_panic.forLenMismatch; | |
| 35 | pub const copyLenMismatch = no_panic.copyLenMismatch; | |
| 36 | pub const memcpyAlias = no_panic.memcpyAlias; | |
| 37 | pub const noreturnReturned = no_panic.noreturnReturned; | |
| 38 | pub const loadUninstantiableType = no_panic.loadUninstantiableType; | |
| 39 | }; | |
| 40 | fn myPanic(msg: []const u8, _: ?usize) noreturn { | |
| 41 | var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); | |
| 42 | stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {}; | |
| 43 | std.process.exit(0); | |
| 44 | } | |
| 45 | const std = @import("std"); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); |
test/incremental2/change_panic_handler_explicit/0/main.zig created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | pub fn main() !u8 { | |
| 2 | var a: u8 = undefined; | |
| 3 | a = 255; | |
| 4 | _ = a + 1; | |
| 5 | return 1; | |
| 6 | } | |
| 7 | const no_panic = std.debug.no_panic; | |
| 8 | pub const panic = struct { | |
| 9 | pub const call = myPanic; | |
| 10 | pub fn integerOverflow() noreturn { | |
| 11 | @panic("integer overflow"); | |
| 12 | } | |
| 13 | pub const sentinelMismatch = no_panic.sentinelMismatch; | |
| 14 | pub const unwrapError = no_panic.unwrapError; | |
| 15 | pub const outOfBounds = no_panic.outOfBounds; | |
| 16 | pub const startGreaterThanEnd = no_panic.startGreaterThanEnd; | |
| 17 | pub const inactiveUnionField = no_panic.inactiveUnionField; | |
| 18 | pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder; | |
| 19 | pub const reachedUnreachable = no_panic.reachedUnreachable; | |
| 20 | pub const unwrapNull = no_panic.unwrapNull; | |
| 21 | pub const castToNull = no_panic.castToNull; | |
| 22 | pub const incorrectAlignment = no_panic.incorrectAlignment; | |
| 23 | pub const invalidErrorCode = no_panic.invalidErrorCode; | |
| 24 | pub const unexpectedErrorCode = no_panic.unexpectedErrorCode; | |
| 25 | pub const integerOutOfBounds = no_panic.integerOutOfBounds; | |
| 26 | pub const shlOverflow = no_panic.shlOverflow; | |
| 27 | pub const shrOverflow = no_panic.shrOverflow; | |
| 28 | pub const divideByZero = no_panic.divideByZero; | |
| 29 | pub const exactDivisionRemainder = no_panic.exactDivisionRemainder; | |
| 30 | pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds; | |
| 31 | pub const corruptSwitch = no_panic.corruptSwitch; | |
| 32 | pub const shiftRhsTooBig = no_panic.shiftRhsTooBig; | |
| 33 | pub const invalidEnumValue = no_panic.invalidEnumValue; | |
| 34 | pub const forLenMismatch = no_panic.forLenMismatch; | |
| 35 | pub const copyLenMismatch = no_panic.copyLenMismatch; | |
| 36 | pub const memcpyAlias = no_panic.memcpyAlias; | |
| 37 | pub const noreturnReturned = no_panic.noreturnReturned; | |
| 38 | pub const loadUninstantiableType = no_panic.loadUninstantiableType; | |
| 39 | }; | |
| 40 | fn myPanic(msg: []const u8, _: ?usize) noreturn { | |
| 41 | var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); | |
| 42 | stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {}; | |
| 43 | std.process.exit(0); | |
| 44 | } | |
| 45 | const std = @import("std"); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); |
test/incremental2/change_panic_handler_explicit/1-main.zig deleted-46| ... | ... | @@ -1,46 +0,0 @@ |
| 1 | pub fn main() !u8 { | |
| 2 | var a: u8 = undefined; | |
| 3 | a = 255; | |
| 4 | _ = a + 1; | |
| 5 | return 1; | |
| 6 | } | |
| 7 | const no_panic = std.debug.no_panic; | |
| 8 | pub const panic = struct { | |
| 9 | pub const call = myPanic; | |
| 10 | pub fn integerOverflow() noreturn { | |
| 11 | @panic("integer overflow"); | |
| 12 | } | |
| 13 | pub const sentinelMismatch = no_panic.sentinelMismatch; | |
| 14 | pub const unwrapError = no_panic.unwrapError; | |
| 15 | pub const outOfBounds = no_panic.outOfBounds; | |
| 16 | pub const startGreaterThanEnd = no_panic.startGreaterThanEnd; | |
| 17 | pub const inactiveUnionField = no_panic.inactiveUnionField; | |
| 18 | pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder; | |
| 19 | pub const reachedUnreachable = no_panic.reachedUnreachable; | |
| 20 | pub const unwrapNull = no_panic.unwrapNull; | |
| 21 | pub const castToNull = no_panic.castToNull; | |
| 22 | pub const incorrectAlignment = no_panic.incorrectAlignment; | |
| 23 | pub const invalidErrorCode = no_panic.invalidErrorCode; | |
| 24 | pub const unexpectedErrorCode = no_panic.unexpectedErrorCode; | |
| 25 | pub const integerOutOfBounds = no_panic.integerOutOfBounds; | |
| 26 | pub const shlOverflow = no_panic.shlOverflow; | |
| 27 | pub const shrOverflow = no_panic.shrOverflow; | |
| 28 | pub const divideByZero = no_panic.divideByZero; | |
| 29 | pub const exactDivisionRemainder = no_panic.exactDivisionRemainder; | |
| 30 | pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds; | |
| 31 | pub const corruptSwitch = no_panic.corruptSwitch; | |
| 32 | pub const shiftRhsTooBig = no_panic.shiftRhsTooBig; | |
| 33 | pub const invalidEnumValue = no_panic.invalidEnumValue; | |
| 34 | pub const forLenMismatch = no_panic.forLenMismatch; | |
| 35 | pub const copyLenMismatch = no_panic.copyLenMismatch; | |
| 36 | pub const memcpyAlias = no_panic.memcpyAlias; | |
| 37 | pub const noreturnReturned = no_panic.noreturnReturned; | |
| 38 | pub const loadUninstantiableType = no_panic.loadUninstantiableType; | |
| 39 | }; | |
| 40 | fn myPanic(msg: []const u8, _: ?usize) noreturn { | |
| 41 | var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); | |
| 42 | stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {}; | |
| 43 | std.process.exit(0); | |
| 44 | } | |
| 45 | const std = @import("std"); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); |
test/incremental2/change_panic_handler_explicit/1/main.zig created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | pub fn main() !u8 { | |
| 2 | var a: u8 = undefined; | |
| 3 | a = 255; | |
| 4 | _ = a + 1; | |
| 5 | return 1; | |
| 6 | } | |
| 7 | const no_panic = std.debug.no_panic; | |
| 8 | pub const panic = struct { | |
| 9 | pub const call = myPanic; | |
| 10 | pub fn integerOverflow() noreturn { | |
| 11 | @panic("integer overflow"); | |
| 12 | } | |
| 13 | pub const sentinelMismatch = no_panic.sentinelMismatch; | |
| 14 | pub const unwrapError = no_panic.unwrapError; | |
| 15 | pub const outOfBounds = no_panic.outOfBounds; | |
| 16 | pub const startGreaterThanEnd = no_panic.startGreaterThanEnd; | |
| 17 | pub const inactiveUnionField = no_panic.inactiveUnionField; | |
| 18 | pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder; | |
| 19 | pub const reachedUnreachable = no_panic.reachedUnreachable; | |
| 20 | pub const unwrapNull = no_panic.unwrapNull; | |
| 21 | pub const castToNull = no_panic.castToNull; | |
| 22 | pub const incorrectAlignment = no_panic.incorrectAlignment; | |
| 23 | pub const invalidErrorCode = no_panic.invalidErrorCode; | |
| 24 | pub const unexpectedErrorCode = no_panic.unexpectedErrorCode; | |
| 25 | pub const integerOutOfBounds = no_panic.integerOutOfBounds; | |
| 26 | pub const shlOverflow = no_panic.shlOverflow; | |
| 27 | pub const shrOverflow = no_panic.shrOverflow; | |
| 28 | pub const divideByZero = no_panic.divideByZero; | |
| 29 | pub const exactDivisionRemainder = no_panic.exactDivisionRemainder; | |
| 30 | pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds; | |
| 31 | pub const corruptSwitch = no_panic.corruptSwitch; | |
| 32 | pub const shiftRhsTooBig = no_panic.shiftRhsTooBig; | |
| 33 | pub const invalidEnumValue = no_panic.invalidEnumValue; | |
| 34 | pub const forLenMismatch = no_panic.forLenMismatch; | |
| 35 | pub const copyLenMismatch = no_panic.copyLenMismatch; | |
| 36 | pub const memcpyAlias = no_panic.memcpyAlias; | |
| 37 | pub const noreturnReturned = no_panic.noreturnReturned; | |
| 38 | pub const loadUninstantiableType = no_panic.loadUninstantiableType; | |
| 39 | }; | |
| 40 | fn myPanic(msg: []const u8, _: ?usize) noreturn { | |
| 41 | var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); | |
| 42 | stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {}; | |
| 43 | std.process.exit(0); | |
| 44 | } | |
| 45 | const std = @import("std"); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); |
test/incremental2/change_panic_handler_explicit/2-main.zig deleted-46| ... | ... | @@ -1,46 +0,0 @@ |
| 1 | pub fn main() !u8 { | |
| 2 | var a: u8 = undefined; | |
| 3 | a = 255; | |
| 4 | _ = a + 1; | |
| 5 | return 1; | |
| 6 | } | |
| 7 | const no_panic = std.debug.no_panic; | |
| 8 | pub const panic = struct { | |
| 9 | pub const call = myPanicNew; | |
| 10 | pub fn integerOverflow() noreturn { | |
| 11 | @panic("integer overflow"); | |
| 12 | } | |
| 13 | pub const sentinelMismatch = no_panic.sentinelMismatch; | |
| 14 | pub const unwrapError = no_panic.unwrapError; | |
| 15 | pub const outOfBounds = no_panic.outOfBounds; | |
| 16 | pub const startGreaterThanEnd = no_panic.startGreaterThanEnd; | |
| 17 | pub const inactiveUnionField = no_panic.inactiveUnionField; | |
| 18 | pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder; | |
| 19 | pub const reachedUnreachable = no_panic.reachedUnreachable; | |
| 20 | pub const unwrapNull = no_panic.unwrapNull; | |
| 21 | pub const castToNull = no_panic.castToNull; | |
| 22 | pub const incorrectAlignment = no_panic.incorrectAlignment; | |
| 23 | pub const invalidErrorCode = no_panic.invalidErrorCode; | |
| 24 | pub const unexpectedErrorCode = no_panic.unexpectedErrorCode; | |
| 25 | pub const integerOutOfBounds = no_panic.integerOutOfBounds; | |
| 26 | pub const shlOverflow = no_panic.shlOverflow; | |
| 27 | pub const shrOverflow = no_panic.shrOverflow; | |
| 28 | pub const divideByZero = no_panic.divideByZero; | |
| 29 | pub const exactDivisionRemainder = no_panic.exactDivisionRemainder; | |
| 30 | pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds; | |
| 31 | pub const corruptSwitch = no_panic.corruptSwitch; | |
| 32 | pub const shiftRhsTooBig = no_panic.shiftRhsTooBig; | |
| 33 | pub const invalidEnumValue = no_panic.invalidEnumValue; | |
| 34 | pub const forLenMismatch = no_panic.forLenMismatch; | |
| 35 | pub const copyLenMismatch = no_panic.copyLenMismatch; | |
| 36 | pub const memcpyAlias = no_panic.memcpyAlias; | |
| 37 | pub const noreturnReturned = no_panic.noreturnReturned; | |
| 38 | pub const loadUninstantiableType = no_panic.loadUninstantiableType; | |
| 39 | }; | |
| 40 | fn myPanicNew(msg: []const u8, _: ?usize) noreturn { | |
| 41 | var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); | |
| 42 | stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {}; | |
| 43 | std.process.exit(0); | |
| 44 | } | |
| 45 | const std = @import("std"); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); |
test/incremental2/change_panic_handler_explicit/2/main.zig created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | pub fn main() !u8 { | |
| 2 | var a: u8 = undefined; | |
| 3 | a = 255; | |
| 4 | _ = a + 1; | |
| 5 | return 1; | |
| 6 | } | |
| 7 | const no_panic = std.debug.no_panic; | |
| 8 | pub const panic = struct { | |
| 9 | pub const call = myPanicNew; | |
| 10 | pub fn integerOverflow() noreturn { | |
| 11 | @panic("integer overflow"); | |
| 12 | } | |
| 13 | pub const sentinelMismatch = no_panic.sentinelMismatch; | |
| 14 | pub const unwrapError = no_panic.unwrapError; | |
| 15 | pub const outOfBounds = no_panic.outOfBounds; | |
| 16 | pub const startGreaterThanEnd = no_panic.startGreaterThanEnd; | |
| 17 | pub const inactiveUnionField = no_panic.inactiveUnionField; | |
| 18 | pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder; | |
| 19 | pub const reachedUnreachable = no_panic.reachedUnreachable; | |
| 20 | pub const unwrapNull = no_panic.unwrapNull; | |
| 21 | pub const castToNull = no_panic.castToNull; | |
| 22 | pub const incorrectAlignment = no_panic.incorrectAlignment; | |
| 23 | pub const invalidErrorCode = no_panic.invalidErrorCode; | |
| 24 | pub const unexpectedErrorCode = no_panic.unexpectedErrorCode; | |
| 25 | pub const integerOutOfBounds = no_panic.integerOutOfBounds; | |
| 26 | pub const shlOverflow = no_panic.shlOverflow; | |
| 27 | pub const shrOverflow = no_panic.shrOverflow; | |
| 28 | pub const divideByZero = no_panic.divideByZero; | |
| 29 | pub const exactDivisionRemainder = no_panic.exactDivisionRemainder; | |
| 30 | pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds; | |
| 31 | pub const corruptSwitch = no_panic.corruptSwitch; | |
| 32 | pub const shiftRhsTooBig = no_panic.shiftRhsTooBig; | |
| 33 | pub const invalidEnumValue = no_panic.invalidEnumValue; | |
| 34 | pub const forLenMismatch = no_panic.forLenMismatch; | |
| 35 | pub const copyLenMismatch = no_panic.copyLenMismatch; | |
| 36 | pub const memcpyAlias = no_panic.memcpyAlias; | |
| 37 | pub const noreturnReturned = no_panic.noreturnReturned; | |
| 38 | pub const loadUninstantiableType = no_panic.loadUninstantiableType; | |
| 39 | }; | |
| 40 | fn myPanicNew(msg: []const u8, _: ?usize) noreturn { | |
| 41 | var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{}); | |
| 42 | stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {}; | |
| 43 | std.process.exit(0); | |
| 44 | } | |
| 45 | const std = @import("std"); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); |
test/incremental2/change_panic_handler_explicit/manifest+3-3| ... | ... | @@ -2,20 +2,20 @@ |
| 2 | 2 | -Mroot=main.zig |
| 3 | 3 | #} |
| 4 | 4 | |
| 5 | #write main.zig 0-main.zig | |
| 5 | #write main.zig 0/main.zig | |
| 6 | 6 | #update |
| 7 | 7 | #check stdout { |
| 8 | 8 | panic message: integer overflow |
| 9 | 9 | #} |
| 10 | 10 | |
| 11 | #write main.zig 1-main.zig | |
| 11 | #write main.zig 1/main.zig | |
| 12 | 12 | #update { |
| 13 | 13 | change the panic handler body#} |
| 14 | 14 | #check stdout { |
| 15 | 15 | new panic message: integer overflow |
| 16 | 16 | #} |
| 17 | 17 | |
| 18 | #write main.zig 2-main.zig | |
| 18 | #write main.zig 2/main.zig | |
| 19 | 19 | #update { |
| 20 | 20 | change the panic handler function value#} |
| 21 | 21 | #check stdout { |
test/src/runner.zig+40-70| ... | ... | @@ -42,12 +42,13 @@ pub fn main(init: std.process.Init) !void { |
| 42 | 42 | const zig_path = zig_path_arg orelse fatal("missing '--zig=path/to/zig'", .{}); |
| 43 | 43 | const lib_path = lib_path_arg orelse fatal("missing '--lib=path/to/lib'", .{}); |
| 44 | 44 | |
| 45 | const test_file = try std.Io.Dir.cwd().openFile(init.io, test_path, .{ | |
| 45 | const cwd: std.Io.Dir = .cwd(); | |
| 46 | const test_file = try cwd.openFile(init.io, test_path, .{ | |
| 46 | 47 | .allow_directory = true, |
| 47 | 48 | }); |
| 48 | const zig_exe = try std.Io.Dir.cwd().openFile(init.io, zig_path, .{}); | |
| 49 | const zig_exe = try cwd.openFile(init.io, zig_path, .{}); | |
| 49 | 50 | defer zig_exe.close(init.io); |
| 50 | const lib_dir = try std.Io.Dir.cwd().openDir(init.io, lib_path, .{}); | |
| 51 | const lib_dir = try cwd.openDir(init.io, lib_path, .{}); | |
| 51 | 52 | defer lib_dir.close(init.io); |
| 52 | 53 | |
| 53 | 54 | const src_dir_path = "src_" ++ std.fmt.hex(rand_int: { |
| ... | ... | @@ -55,10 +56,10 @@ pub fn main(init: std.process.Init) !void { |
| 55 | 56 | init.io.random(@ptrCast(&rand_int)); |
| 56 | 57 | break :rand_int rand_int; |
| 57 | 58 | }); |
| 58 | var src_dir = try std.Io.Dir.cwd().createDirPathOpen(init.io, src_dir_path, .{}); | |
| 59 | var src_dir = try cwd.createDirPathOpen(init.io, src_dir_path, .{}); | |
| 59 | 60 | defer { |
| 60 | 61 | src_dir.close(init.io); |
| 61 | if (!keep_src) std.Io.Dir.cwd().deleteTree(init.io, src_dir_path) catch |err| { | |
| 62 | if (!keep_src) cwd.deleteTree(init.io, src_dir_path) catch |err| { | |
| 62 | 63 | std.log.warn("fataled to delete tree '{s}': {t}", .{ src_dir_path, err }); |
| 63 | 64 | }; |
| 64 | 65 | } |
| ... | ... | @@ -423,7 +424,8 @@ fn runTest( |
| 423 | 424 | target_string: []const u8, |
| 424 | 425 | ) !void { |
| 425 | 426 | const manifest_file = args.manifest_file orelse return error.MissingManifestArg; |
| 426 | const src_dir = args.src_dir orelse return error.MissingSrcDir; | |
| 427 | const src_dir = | |
| 428 | try (args.src_dir orelse return error.MissingSrcDir).createDirPathOpen(io, target_string, .{}); | |
| 427 | 429 | const target: Compiler.Target = target: { |
| 428 | 430 | const backend_split = std.mem.findScalarLast(u8, target_string, '-') orelse |
| 429 | 431 | return error.TargetMissingBackend; |
| ... | ... | @@ -544,6 +546,8 @@ fn runTest( |
| 544 | 546 | }, |
| 545 | 547 | "-target", |
| 546 | 548 | target.triple, |
| 549 | "--cache-dir", | |
| 550 | ".zig-cache", | |
| 547 | 551 | }); |
| 548 | 552 | switch (target.mode) { |
| 549 | 553 | .whole => {}, |
| ... | ... | @@ -663,28 +667,6 @@ fn runTest( |
| 663 | 667 | }; |
| 664 | 668 | const body = comp.client.in.take(header.bytes_len) catch unreachable; |
| 665 | 669 | switch (header.tag) { |
| 666 | .error_bundle => { | |
| 667 | const error_bundle = try std.zig.Server.allocErrorBundle(arena, body); | |
| 668 | if (stderr.bufferedLen() > 0) { | |
| 669 | if (comp.allow_compiler_stderr) { | |
| 670 | std.log.info("error_bundle stderr:\n{s}", .{stderr.buffered()}); | |
| 671 | } else { | |
| 672 | fatal("error_bundle unexpected stderr:\n{s}", .{stderr.buffered()}); | |
| 673 | } | |
| 674 | stderr.tossBuffered(); | |
| 675 | } | |
| 676 | switch (check) { | |
| 677 | .errors => if (error_bundle.errorMessageCount() != 0) { | |
| 678 | @panic("TODO"); | |
| 679 | } else fatal("expected compile errors", .{}), | |
| 680 | .stdout, .exit, .lldb => if (error_bundle.errorMessageCount() != 0) { | |
| 681 | try error_bundle.renderToStderr(io, .{}, .auto); | |
| 682 | fatal("unexpected compile errors", .{}); | |
| 683 | }, | |
| 684 | } | |
| 685 | comp.state = .idle; | |
| 686 | break :cmd; | |
| 687 | }, | |
| 688 | 670 | .emit_digest => { |
| 689 | 671 | var r: std.Io.Reader = .fixed(body); |
| 690 | 672 | _ = r.takeStruct(std.zig.Server.Message.EmitDigest, .little) catch |
| ... | ... | @@ -708,7 +690,7 @@ fn runTest( |
| 708 | 690 | } |
| 709 | 691 | const digest = r.takeArray(std.Build.Cache.bin_digest_len) catch |
| 710 | 692 | unreachable; |
| 711 | const result_dir = ".zig-cache" ++ std.Io.Dir.path.sep_str ++ | |
| 693 | const bin_dir = ".zig-cache" ++ std.Io.Dir.path.sep_str ++ | |
| 712 | 694 | "o" ++ std.Io.Dir.path.sep_str ++ std.Build.Cache.binToHex(digest.*); |
| 713 | 695 | const bin_name = try std.zig.EmitArtifact.bin.cacheName(arena, .{ |
| 714 | 696 | .root_name = comp.root_name, |
| ... | ... | @@ -719,16 +701,20 @@ fn runTest( |
| 719 | 701 | .output_mode = comp.output_mode, |
| 720 | 702 | }); |
| 721 | 703 | const bin_path = |
| 722 | try std.Io.Dir.path.join(arena, &.{ result_dir, bin_name }); | |
| 723 | const bin_file = try std.Io.Dir.cwd().openFile(io, bin_path, .{}); | |
| 704 | try std.Io.Dir.path.join(arena, &.{ bin_dir, bin_name }); | |
| 705 | const bin_file = try src_dir.openFile(io, bin_path, .{}); | |
| 724 | 706 | defer bin_file.close(io); |
| 725 | 707 | switch (check) { |
| 726 | 708 | .errors => unreachable, |
| 727 | 709 | .stdout, .exit => { |
| 728 | const result = std.process.run(arena, io, .{ | |
| 710 | const result = std.process.run(gpa, io, .{ | |
| 729 | 711 | .exe = .{ .file = bin_file }, |
| 730 | 712 | .argv = &.{bin_path}, |
| 731 | 713 | }) catch continue; |
| 714 | defer { | |
| 715 | gpa.free(result.stdout); | |
| 716 | gpa.free(result.stderr); | |
| 717 | } | |
| 732 | 718 | switch (result.term) { |
| 733 | 719 | .exited => |code| switch (check) { |
| 734 | 720 | .errors, .lldb => unreachable, |
| ... | ... | @@ -752,6 +738,28 @@ fn runTest( |
| 752 | 738 | .lldb => {}, |
| 753 | 739 | } |
| 754 | 740 | }, |
| 741 | .error_bundle => { | |
| 742 | const error_bundle = try std.zig.Server.allocErrorBundle(arena, body); | |
| 743 | if (stderr.bufferedLen() > 0) { | |
| 744 | if (comp.allow_compiler_stderr) { | |
| 745 | std.log.info("error_bundle stderr:\n{s}", .{stderr.buffered()}); | |
| 746 | } else { | |
| 747 | fatal("error_bundle unexpected stderr:\n{s}", .{stderr.buffered()}); | |
| 748 | } | |
| 749 | stderr.tossBuffered(); | |
| 750 | } | |
| 751 | switch (check) { | |
| 752 | .errors => if (error_bundle.errorMessageCount() != 0) { | |
| 753 | @panic("TODO"); | |
| 754 | } else fatal("expected compile errors", .{}), | |
| 755 | .stdout, .exit, .lldb => if (error_bundle.errorMessageCount() != 0) { | |
| 756 | try error_bundle.renderToStderr(io, .{}, .auto); | |
| 757 | fatal("unexpected compile errors", .{}); | |
| 758 | }, | |
| 759 | } | |
| 760 | comp.state = .idle; | |
| 761 | break :cmd; | |
| 762 | }, | |
| 755 | 763 | else => {}, // Ignore other messages, |
| 756 | 764 | } |
| 757 | 765 | } |
| ... | ... | @@ -861,44 +869,6 @@ const Compiler = struct { |
| 861 | 869 | }; |
| 862 | 870 | }; |
| 863 | 871 | |
| 864 | fn update(comp: *Compiler, io: std.Io) !void { | |
| 865 | comp.client.serveBodylessMessage(.update) catch |err| switch (err) { | |
| 866 | error.WriteFailed => return comp.fw.err.?, | |
| 867 | }; | |
| 868 | while (true) { | |
| 869 | const header = comp.client.receiveMessageWithMultiReader( | |
| 870 | &comp.mr, | |
| 871 | .none, | |
| 872 | ) catch |err| switch (err) { | |
| 873 | error.Timeout => unreachable, | |
| 874 | error.EndOfStream => break, | |
| 875 | else => |e| return e, | |
| 876 | }; | |
| 877 | const body = comp.client.in.take(header.bytes_len) catch unreachable; | |
| 878 | switch (header.tag) { | |
| 879 | .error_bundle => { | |
| 880 | return; | |
| 881 | }, | |
| 882 | .emit_digest => { | |
| 883 | _ = body; | |
| 884 | }, | |
| 885 | else => {}, // Ignore other messages, | |
| 886 | } | |
| 887 | } | |
| 888 | ||
| 889 | const buffered_stderr = comp.mr.reader(1).buffered(); | |
| 890 | if (buffered_stderr.len > 0) { | |
| 891 | if (comp.allow_compiler_stderr) { | |
| 892 | std.log.info("stderr:\n{s}", .{buffered_stderr}); | |
| 893 | } else { | |
| 894 | fatal("unexpected stderr:\n{s}", .{buffered_stderr}); | |
| 895 | } | |
| 896 | } | |
| 897 | ||
| 898 | try comp.exit(io); | |
| 899 | fatal("compiler failed to send terminating error_bundle", .{}); | |
| 900 | } | |
| 901 | ||
| 902 | 872 | fn exit(comp: *Compiler, io: std.Io) !void { |
| 903 | 873 | comp.client.serveBodylessMessage(.exit) catch |err| switch (err) { |
| 904 | 874 | error.WriteFailed => switch (comp.fw.err.?) { |