authorgravatar for wc3ft2@gmail.comZapolsky Anton <wc3ft2@gmail.com> 2023-06-13 21:09:24+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-06-13 14:09:24-04:00
logc76ce25a6165e96015b11d506e3c968c6c8dca2c
tree0b83e93af54588d41593fd941acfe72180b60577
parent854f26ad8ac8dc39ef7ad60f86588c0c5dba131a
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Remove CheckObjectStep.runAndCompare (#15973)

Closes #14969

11 files changed, 32 insertions(+), 37 deletions(-)

lib/std/Build/Step/CheckObject.zig-16
......@@ -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.
50pub 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
6145const SearchPhrase = struct {
6246 string: []const u8,
6347 file_source: ?std.Build.FileSource = null,
test/link/macho/dead_strip/build.zig+8-6
......@@ -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+2-1
......@@ -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+2-1
......@@ -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+2-1
......@@ -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+4-3
......@@ -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+2-1
......@@ -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+2-1
......@@ -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+2-1
......@@ -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+4-3
......@@ -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
6364fn createScenario(
test/link/macho/weak_library/build.zig+4-3
......@@ -46,7 +46,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
4646 check.checkInSymtab();
4747 check.checkNext("(undefined) weak external _asStr (from liba)");
4848
49 const run_cmd = check.runAndCompare();
50 run_cmd.expectStdOutEqual("42 42");
51 test_step.dependOn(&run_cmd.step);
49 const run = b.addRunArtifact(exe);
50 run.skip_foreign_checks = true;
51 run.expectStdOutEqual("42 42");
52 test_step.dependOn(&run.step);
5253}