Commit c76ce25a61
Changed files (11)
lib/std/Build/Step/CheckObject.zig
@@ -42,22 +42,6 @@ pub fn create(
return self;
}
-/// Runs and (optionally) compares the output of a binary.
-/// Asserts `self` was generated from an executable step.
-/// TODO this doesn't actually compare, and there's no apparent reason for it
-/// to depend on the check object step. I don't see why this function should exist,
-/// the caller could just add the run step directly.
-pub fn runAndCompare(self: *CheckObject) *std.Build.Step.Run {
- const dependencies_len = self.step.dependencies.items.len;
- assert(dependencies_len > 0);
- const exe_step = self.step.dependencies.items[dependencies_len - 1];
- const exe = exe_step.cast(std.Build.Step.Compile).?;
- const run = self.step.owner.addRunArtifact(exe);
- run.skip_foreign_checks = true;
- run.step.dependOn(&self.step);
- return run;
-}
-
const SearchPhrase = struct {
string: []const u8,
file_source: ?std.Build.FileSource = null,
test/link/macho/dead_strip/build.zig
@@ -17,9 +17,10 @@ pub fn build(b: *std.Build) void {
check.checkInSymtab();
check.checkNext("{*} (__TEXT,__text) external _iAmUnused");
- const run_cmd = check.runAndCompare();
- run_cmd.expectStdOutEqual("Hello!\n");
- test_step.dependOn(&run_cmd.step);
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
+ run.expectStdOutEqual("Hello!\n");
+ test_step.dependOn(&run.step);
}
{
@@ -31,9 +32,10 @@ pub fn build(b: *std.Build) void {
check.checkInSymtab();
check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused");
- const run_cmd = check.runAndCompare();
- run_cmd.expectStdOutEqual("Hello!\n");
- test_step.dependOn(&run_cmd.step);
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
+ run.expectStdOutEqual("Hello!\n");
+ test_step.dependOn(&run.step);
}
}
test/link/macho/dylib/build.zig
@@ -54,7 +54,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check_exe.checkStart("cmd RPATH");
check_exe.checkNextFileSource("path", dylib.getOutputDirectorySource());
- const run = check_exe.runAndCompare();
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
run.expectStdOutEqual("Hello world");
test_step.dependOn(&run.step);
}
test/link/macho/entry/build.zig
@@ -35,7 +35,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check_exe.checkComputeCompare("vmaddr entryoff +", .{ .op = .eq, .value = .{ .variable = "n_value" } });
- const run = check_exe.runAndCompare();
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
run.expectStdOutEqual("42");
test_step.dependOn(&run.step);
}
test/link/macho/entry_in_dylib/build.zig
@@ -48,7 +48,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
.value = .{ .variable = "stubs_vmaddr" }, // The entrypoint should be a synthetic stub
});
- const run = check_exe.runAndCompare();
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
run.expectStdOutEqual("Hello!\n");
test_step.dependOn(&run.step);
}
test/link/macho/needed_library/build.zig
@@ -42,7 +42,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check.checkStart("cmd LOAD_DYLIB");
check.checkNext("name @rpath/liba.dylib");
- const run_cmd = check.runAndCompare();
- run_cmd.expectStdOutEqual("");
- test_step.dependOn(&run_cmd.step);
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
+ run.expectStdOutEqual("");
+ test_step.dependOn(&run.step);
}
test/link/macho/search_strategy/build.zig
@@ -24,7 +24,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check.checkStart("cmd LOAD_DYLIB");
check.checkNext("name @rpath/libsearch_dylibs_first.dylib");
- const run = check.runAndCompare();
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
run.expectStdOutEqual("Hello world");
test_step.dependOn(&run.step);
}
test/link/macho/stack_size/build.zig
@@ -28,7 +28,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check_exe.checkStart("cmd MAIN");
check_exe.checkNext("stacksize 100000000");
- const run = check_exe.runAndCompare();
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
run.expectStdOutEqual("");
test_step.dependOn(&run.step);
}
test/link/macho/strict_validation/build.zig
@@ -122,7 +122,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
else => unreachable,
}
- const run = check_exe.runAndCompare();
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
run.expectStdOutEqual("Hello!\n");
test_step.dependOn(&run.step);
}
test/link/macho/unwind_info/build.zig
@@ -47,8 +47,9 @@ fn testUnwindInfo(
check.checkInSymtab();
check.checkNext("{*} (__TEXT,__text) external ___gxx_personality_v0");
- const run_cmd = check.runAndCompare();
- run_cmd.expectStdOutEqual(
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
+ run.expectStdOutEqual(
\\Constructed: a
\\Constructed: b
\\About to destroy: b
@@ -57,7 +58,7 @@ fn testUnwindInfo(
\\
);
- test_step.dependOn(&run_cmd.step);
+ test_step.dependOn(&run.step);
}
fn createScenario(
test/link/macho/weak_library/build.zig
@@ -46,7 +46,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check.checkInSymtab();
check.checkNext("(undefined) weak external _asStr (from liba)");
- const run_cmd = check.runAndCompare();
- run_cmd.expectStdOutEqual("42 42");
- test_step.dependOn(&run_cmd.step);
+ const run = b.addRunArtifact(exe);
+ run.skip_foreign_checks = true;
+ run.expectStdOutEqual("42 42");
+ test_step.dependOn(&run.step);
}