Files
zig/test/incremental/change_panic_handler_explicit
T
Matthew Lugg 291addadf8 tests: move incremental target matrix out of manifests
Having the matrix of test targets for incremental compilation in the
individual test manifests has turned out to be inconvenient for a few
reasons: the tests are almost certain to accidentally get out of sync,
disabling targets entirely is annoying to do, and incr-check needs to
take care to print the target in all error messages (which currently
does not always happen).

If I recall correctly, I originally designed it this way because it
allows targets to be disabled at the granularity of individual tests,
but there's an easier approach to that: just let a test manifest that it
should be *skipped* on a certain target! As skipping is the rare case,
and also the case you want readers to notice, it makes sense for *it* to
be explicitly specified, like how unit tests use `error.SkipZigTest`.

So, `incr-check` no longer runs through a list of targets specified in
the manifest. Instead, it accepts (and, in fact, requires) a single
target on the command line, and runs the test for that specific target.
If the file contains a `#skip_target` directive for that target, then
`incr-check` exits immediately, so we can still disable targets at
individual test granularity, but you can also disable a target for all
tests by just commenting it out of the matrix in `test/tests.zig`.

As a nice bonus, this also allows the build system to run different
incremental test targets in parallel, because the targets are now
different steps.

This definitely seems like a better way to split the work between the
build system and incr-check---sorry for getting this wrong initially!
2026-04-15 00:06:18 +02:00

144 lines
6.2 KiB
Plaintext

#update=initial version
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
const no_panic = std.debug.no_panic;
pub const panic = struct {
pub const call = myPanic;
pub fn integerOverflow() noreturn {
@panic("integer overflow");
}
pub const sentinelMismatch = no_panic.sentinelMismatch;
pub const unwrapError = no_panic.unwrapError;
pub const outOfBounds = no_panic.outOfBounds;
pub const startGreaterThanEnd = no_panic.startGreaterThanEnd;
pub const inactiveUnionField = no_panic.inactiveUnionField;
pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder;
pub const reachedUnreachable = no_panic.reachedUnreachable;
pub const unwrapNull = no_panic.unwrapNull;
pub const castToNull = no_panic.castToNull;
pub const incorrectAlignment = no_panic.incorrectAlignment;
pub const invalidErrorCode = no_panic.invalidErrorCode;
pub const integerOutOfBounds = no_panic.integerOutOfBounds;
pub const shlOverflow = no_panic.shlOverflow;
pub const shrOverflow = no_panic.shrOverflow;
pub const divideByZero = no_panic.divideByZero;
pub const exactDivisionRemainder = no_panic.exactDivisionRemainder;
pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds;
pub const corruptSwitch = no_panic.corruptSwitch;
pub const shiftRhsTooBig = no_panic.shiftRhsTooBig;
pub const invalidEnumValue = no_panic.invalidEnumValue;
pub const forLenMismatch = no_panic.forLenMismatch;
pub const copyLenMismatch = no_panic.copyLenMismatch;
pub const memcpyAlias = no_panic.memcpyAlias;
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanic(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
const io = std.Io.Threaded.global_single_threaded.io();
#expect_stdout="panic message: integer overflow\n"
#update=change the panic handler body
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
const no_panic = std.debug.no_panic;
pub const panic = struct {
pub const call = myPanic;
pub fn integerOverflow() noreturn {
@panic("integer overflow");
}
pub const sentinelMismatch = no_panic.sentinelMismatch;
pub const unwrapError = no_panic.unwrapError;
pub const outOfBounds = no_panic.outOfBounds;
pub const startGreaterThanEnd = no_panic.startGreaterThanEnd;
pub const inactiveUnionField = no_panic.inactiveUnionField;
pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder;
pub const reachedUnreachable = no_panic.reachedUnreachable;
pub const unwrapNull = no_panic.unwrapNull;
pub const castToNull = no_panic.castToNull;
pub const incorrectAlignment = no_panic.incorrectAlignment;
pub const invalidErrorCode = no_panic.invalidErrorCode;
pub const integerOutOfBounds = no_panic.integerOutOfBounds;
pub const shlOverflow = no_panic.shlOverflow;
pub const shrOverflow = no_panic.shrOverflow;
pub const divideByZero = no_panic.divideByZero;
pub const exactDivisionRemainder = no_panic.exactDivisionRemainder;
pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds;
pub const corruptSwitch = no_panic.corruptSwitch;
pub const shiftRhsTooBig = no_panic.shiftRhsTooBig;
pub const invalidEnumValue = no_panic.invalidEnumValue;
pub const forLenMismatch = no_panic.forLenMismatch;
pub const copyLenMismatch = no_panic.copyLenMismatch;
pub const memcpyAlias = no_panic.memcpyAlias;
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanic(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
const io = std.Io.Threaded.global_single_threaded.io();
#expect_stdout="new panic message: integer overflow\n"
#update=change the panic handler function value
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
const no_panic = std.debug.no_panic;
pub const panic = struct {
pub const call = myPanicNew;
pub fn integerOverflow() noreturn {
@panic("integer overflow");
}
pub const sentinelMismatch = std.debug.no_panic.sentinelMismatch;
pub const unwrapError = std.debug.no_panic.unwrapError;
pub const outOfBounds = std.debug.no_panic.outOfBounds;
pub const startGreaterThanEnd = std.debug.no_panic.startGreaterThanEnd;
pub const inactiveUnionField = std.debug.no_panic.inactiveUnionField;
pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder;
pub const reachedUnreachable = no_panic.reachedUnreachable;
pub const unwrapNull = no_panic.unwrapNull;
pub const castToNull = no_panic.castToNull;
pub const incorrectAlignment = no_panic.incorrectAlignment;
pub const invalidErrorCode = no_panic.invalidErrorCode;
pub const integerOutOfBounds = no_panic.integerOutOfBounds;
pub const shlOverflow = no_panic.shlOverflow;
pub const shrOverflow = no_panic.shrOverflow;
pub const divideByZero = no_panic.divideByZero;
pub const exactDivisionRemainder = no_panic.exactDivisionRemainder;
pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds;
pub const corruptSwitch = no_panic.corruptSwitch;
pub const shiftRhsTooBig = no_panic.shiftRhsTooBig;
pub const invalidEnumValue = no_panic.invalidEnumValue;
pub const forLenMismatch = no_panic.forLenMismatch;
pub const copyLenMismatch = no_panic.copyLenMismatch;
pub const memcpyAlias = no_panic.memcpyAlias;
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
const io = std.Io.Threaded.global_single_threaded.io();
#expect_stdout="third panic message: integer overflow\n"