Skip to content

Commit c76ce25

Browse files
authored
Remove CheckObjectStep.runAndCompare (#15973)
Closes #14969
1 parent 854f26a commit c76ce25

File tree

11 files changed

+32
-37
lines changed

11 files changed

+32
-37
lines changed

lib/std/Build/Step/CheckObject.zig

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,6 @@ pub fn create(
4242
return self;
4343
}
4444

45-
/// Runs and (optionally) compares the output of a binary.
46-
/// Asserts `self` was generated from an executable step.
47-
/// TODO this doesn't actually compare, and there's no apparent reason for it
48-
/// to depend on the check object step. I don't see why this function should exist,
49-
/// the caller could just add the run step directly.
50-
pub fn runAndCompare(self: *CheckObject) *std.Build.Step.Run {
51-
const dependencies_len = self.step.dependencies.items.len;
52-
assert(dependencies_len > 0);
53-
const exe_step = self.step.dependencies.items[dependencies_len - 1];
54-
const exe = exe_step.cast(std.Build.Step.Compile).?;
55-
const run = self.step.owner.addRunArtifact(exe);
56-
run.skip_foreign_checks = true;
57-
run.step.dependOn(&self.step);
58-
return run;
59-
}
60-
6145
const SearchPhrase = struct {
6246
string: []const u8,
6347
file_source: ?std.Build.FileSource = null,

test/link/macho/dead_strip/build.zig

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ pub fn build(b: *std.Build) void {
1717
check.checkInSymtab();
1818
check.checkNext("{*} (__TEXT,__text) external _iAmUnused");
1919

20-
const run_cmd = check.runAndCompare();
21-
run_cmd.expectStdOutEqual("Hello!\n");
22-
test_step.dependOn(&run_cmd.step);
20+
const run = b.addRunArtifact(exe);
21+
run.skip_foreign_checks = true;
22+
run.expectStdOutEqual("Hello!\n");
23+
test_step.dependOn(&run.step);
2324
}
2425

2526
{
@@ -31,9 +32,10 @@ pub fn build(b: *std.Build) void {
3132
check.checkInSymtab();
3233
check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused");
3334

34-
const run_cmd = check.runAndCompare();
35-
run_cmd.expectStdOutEqual("Hello!\n");
36-
test_step.dependOn(&run_cmd.step);
35+
const run = b.addRunArtifact(exe);
36+
run.skip_foreign_checks = true;
37+
run.expectStdOutEqual("Hello!\n");
38+
test_step.dependOn(&run.step);
3739
}
3840
}
3941

test/link/macho/dylib/build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
5454
check_exe.checkStart("cmd RPATH");
5555
check_exe.checkNextFileSource("path", dylib.getOutputDirectorySource());
5656

57-
const run = check_exe.runAndCompare();
57+
const run = b.addRunArtifact(exe);
58+
run.skip_foreign_checks = true;
5859
run.expectStdOutEqual("Hello world");
5960
test_step.dependOn(&run.step);
6061
}

test/link/macho/entry/build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3535

3636
check_exe.checkComputeCompare("vmaddr entryoff +", .{ .op = .eq, .value = .{ .variable = "n_value" } });
3737

38-
const run = check_exe.runAndCompare();
38+
const run = b.addRunArtifact(exe);
39+
run.skip_foreign_checks = true;
3940
run.expectStdOutEqual("42");
4041
test_step.dependOn(&run.step);
4142
}

test/link/macho/entry_in_dylib/build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
4848
.value = .{ .variable = "stubs_vmaddr" }, // The entrypoint should be a synthetic stub
4949
});
5050

51-
const run = check_exe.runAndCompare();
51+
const run = b.addRunArtifact(exe);
52+
run.skip_foreign_checks = true;
5253
run.expectStdOutEqual("Hello!\n");
5354
test_step.dependOn(&run.step);
5455
}

test/link/macho/needed_library/build.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
4242
check.checkStart("cmd LOAD_DYLIB");
4343
check.checkNext("name @rpath/liba.dylib");
4444

45-
const run_cmd = check.runAndCompare();
46-
run_cmd.expectStdOutEqual("");
47-
test_step.dependOn(&run_cmd.step);
45+
const run = b.addRunArtifact(exe);
46+
run.skip_foreign_checks = true;
47+
run.expectStdOutEqual("");
48+
test_step.dependOn(&run.step);
4849
}

test/link/macho/search_strategy/build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2424
check.checkStart("cmd LOAD_DYLIB");
2525
check.checkNext("name @rpath/libsearch_dylibs_first.dylib");
2626

27-
const run = check.runAndCompare();
27+
const run = b.addRunArtifact(exe);
28+
run.skip_foreign_checks = true;
2829
run.expectStdOutEqual("Hello world");
2930
test_step.dependOn(&run.step);
3031
}

test/link/macho/stack_size/build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2828
check_exe.checkStart("cmd MAIN");
2929
check_exe.checkNext("stacksize 100000000");
3030

31-
const run = check_exe.runAndCompare();
31+
const run = b.addRunArtifact(exe);
32+
run.skip_foreign_checks = true;
3233
run.expectStdOutEqual("");
3334
test_step.dependOn(&run.step);
3435
}

test/link/macho/strict_validation/build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
122122
else => unreachable,
123123
}
124124

125-
const run = check_exe.runAndCompare();
125+
const run = b.addRunArtifact(exe);
126+
run.skip_foreign_checks = true;
126127
run.expectStdOutEqual("Hello!\n");
127128
test_step.dependOn(&run.step);
128129
}

test/link/macho/unwind_info/build.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ fn testUnwindInfo(
4747
check.checkInSymtab();
4848
check.checkNext("{*} (__TEXT,__text) external ___gxx_personality_v0");
4949

50-
const run_cmd = check.runAndCompare();
51-
run_cmd.expectStdOutEqual(
50+
const run = b.addRunArtifact(exe);
51+
run.skip_foreign_checks = true;
52+
run.expectStdOutEqual(
5253
\\Constructed: a
5354
\\Constructed: b
5455
\\About to destroy: b
@@ -57,7 +58,7 @@ fn testUnwindInfo(
5758
\\
5859
);
5960

60-
test_step.dependOn(&run_cmd.step);
61+
test_step.dependOn(&run.step);
6162
}
6263

6364
fn createScenario(

0 commit comments

Comments
 (0)