mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
e3424332d3
* `doc/langref` formatting * upgrade `.{ .path = "..." }` to `b.path("...")` * avoid using arguments named `self` * make `Build.Step.Id` usage more consistent * add `Build.pathResolve` * use `pathJoin` and `pathResolve` everywhere * make sure `Build.LazyPath.getPath2` returns an absolute path
45 lines
1.5 KiB
Zig
45 lines
1.5 KiB
Zig
const std = @import("std");
|
|
const posix = std.posix;
|
|
|
|
pub fn build(b: *std.build.Builder) !void {
|
|
const test_step = b.step("test", "Test it");
|
|
b.default_step = test_step;
|
|
|
|
// TODO signal handling code has no business being in a build script.
|
|
// this logic needs to move to a file called parent.zig which is
|
|
// added as an executable.
|
|
|
|
//if (!std.os.have_sigpipe_support) {
|
|
// return;
|
|
//}
|
|
|
|
// This test runs "breakpipe" as a child process and that process
|
|
// depends on inheriting a SIGPIPE disposition of "default".
|
|
{
|
|
const act = posix.Sigaction{
|
|
.handler = .{ .handler = posix.SIG.DFL },
|
|
.mask = posix.empty_sigset,
|
|
.flags = 0,
|
|
};
|
|
try posix.sigaction(posix.SIG.PIPE, &act, null);
|
|
}
|
|
|
|
for ([_]bool{ false, true }) |keep_sigpipe| {
|
|
const options = b.addOptions();
|
|
options.addOption(bool, "keep_sigpipe", keep_sigpipe);
|
|
const exe = b.addExecutable(.{
|
|
.name = "breakpipe",
|
|
.root_source_file = b.path("breakpipe.zig"),
|
|
});
|
|
exe.addOptions("build_options", options);
|
|
const run = b.addRunArtifact(exe);
|
|
if (keep_sigpipe) {
|
|
run.addCheck(.{ .expect_term = .{ .Signal = std.posix.SIG.PIPE } });
|
|
} else {
|
|
run.addCheck(.{ .expect_stdout_exact = "BrokenPipe\n" });
|
|
run.addCheck(.{ .expect_term = .{ .Exited = 123 } });
|
|
}
|
|
test_step.dependOn(&run.step);
|
|
}
|
|
}
|