diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig index 24ebfef388..1c2d86e4e3 100644 --- a/lib/std/Build/Step/CheckObject.zig +++ b/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, diff --git a/test/link/macho/dead_strip/build.zig b/test/link/macho/dead_strip/build.zig index 9d00bad9e0..5ca3e5f89f 100644 --- a/test/link/macho/dead_strip/build.zig +++ b/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); } } diff --git a/test/link/macho/dylib/build.zig b/test/link/macho/dylib/build.zig index a4085b51e6..fe294f3333 100644 --- a/test/link/macho/dylib/build.zig +++ b/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); } diff --git a/test/link/macho/entry/build.zig b/test/link/macho/entry/build.zig index e983bc9391..454956ad41 100644 --- a/test/link/macho/entry/build.zig +++ b/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); } diff --git a/test/link/macho/entry_in_dylib/build.zig b/test/link/macho/entry_in_dylib/build.zig index 135661872d..acb26efceb 100644 --- a/test/link/macho/entry_in_dylib/build.zig +++ b/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); } diff --git a/test/link/macho/needed_library/build.zig b/test/link/macho/needed_library/build.zig index cb9ea38d4b..7b56572cc3 100644 --- a/test/link/macho/needed_library/build.zig +++ b/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); } diff --git a/test/link/macho/search_strategy/build.zig b/test/link/macho/search_strategy/build.zig index 853c471969..4b52d9aa0a 100644 --- a/test/link/macho/search_strategy/build.zig +++ b/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); } diff --git a/test/link/macho/stack_size/build.zig b/test/link/macho/stack_size/build.zig index c7d308d004..219d65cdb8 100644 --- a/test/link/macho/stack_size/build.zig +++ b/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); } diff --git a/test/link/macho/strict_validation/build.zig b/test/link/macho/strict_validation/build.zig index 34a0cd73fc..d75b4c5820 100644 --- a/test/link/macho/strict_validation/build.zig +++ b/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); } diff --git a/test/link/macho/unwind_info/build.zig b/test/link/macho/unwind_info/build.zig index 96b5f6cacc..6f19acef38 100644 --- a/test/link/macho/unwind_info/build.zig +++ b/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( diff --git a/test/link/macho/weak_library/build.zig b/test/link/macho/weak_library/build.zig index 88d72ad487..81a694be9b 100644 --- a/test/link/macho/weak_library/build.zig +++ b/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); }