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(...@@ -42,22 +42,6 @@ pub fn create(
42 return self;42 return self;
43}43}
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
61const SearchPhrase = struct {45const SearchPhrase = struct {
62 string: []const u8,46 string: []const u8,
63 file_source: ?std.Build.FileSource = null,47 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 {...@@ -17,9 +17,10 @@ pub fn build(b: *std.Build) void {
17 check.checkInSymtab();17 check.checkInSymtab();
18 check.checkNext("{*} (__TEXT,__text) external _iAmUnused");18 check.checkNext("{*} (__TEXT,__text) external _iAmUnused");
1919
20 const run_cmd = check.runAndCompare();20 const run = b.addRunArtifact(exe);
21 run_cmd.expectStdOutEqual("Hello!\n");21 run.skip_foreign_checks = true;
22 test_step.dependOn(&run_cmd.step);22 run.expectStdOutEqual("Hello!\n");
23 test_step.dependOn(&run.step);
23 }24 }
2425
25 {26 {
...@@ -31,9 +32,10 @@ pub fn build(b: *std.Build) void {...@@ -31,9 +32,10 @@ pub fn build(b: *std.Build) void {
31 check.checkInSymtab();32 check.checkInSymtab();
32 check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused");33 check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused");
3334
34 const run_cmd = check.runAndCompare();35 const run = b.addRunArtifact(exe);
35 run_cmd.expectStdOutEqual("Hello!\n");36 run.skip_foreign_checks = true;
36 test_step.dependOn(&run_cmd.step);37 run.expectStdOutEqual("Hello!\n");
38 test_step.dependOn(&run.step);
37 }39 }
38}40}
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...@@ -54,7 +54,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
54 check_exe.checkStart("cmd RPATH");54 check_exe.checkStart("cmd RPATH");
55 check_exe.checkNextFileSource("path", dylib.getOutputDirectorySource());55 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;
58 run.expectStdOutEqual("Hello world");59 run.expectStdOutEqual("Hello world");
59 test_step.dependOn(&run.step);60 test_step.dependOn(&run.step);
60}61}
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...@@ -35,7 +35,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3535
36 check_exe.checkComputeCompare("vmaddr entryoff +", .{ .op = .eq, .value = .{ .variable = "n_value" } });36 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;
39 run.expectStdOutEqual("42");40 run.expectStdOutEqual("42");
40 test_step.dependOn(&run.step);41 test_step.dependOn(&run.step);
41}42}
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...@@ -48,7 +48,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
48 .value = .{ .variable = "stubs_vmaddr" }, // The entrypoint should be a synthetic stub48 .value = .{ .variable = "stubs_vmaddr" }, // The entrypoint should be a synthetic stub
49 });49 });
5050
51 const run = check_exe.runAndCompare();51 const run = b.addRunArtifact(exe);
52 run.skip_foreign_checks = true;
52 run.expectStdOutEqual("Hello!\n");53 run.expectStdOutEqual("Hello!\n");
53 test_step.dependOn(&run.step);54 test_step.dependOn(&run.step);
54}55}
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...@@ -42,7 +42,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
42 check.checkStart("cmd LOAD_DYLIB");42 check.checkStart("cmd LOAD_DYLIB");
43 check.checkNext("name @rpath/liba.dylib");43 check.checkNext("name @rpath/liba.dylib");
4444
45 const run_cmd = check.runAndCompare();45 const run = b.addRunArtifact(exe);
46 run_cmd.expectStdOutEqual("");46 run.skip_foreign_checks = true;
47 test_step.dependOn(&run_cmd.step);47 run.expectStdOutEqual("");
48 test_step.dependOn(&run.step);
48}49}
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...@@ -24,7 +24,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
24 check.checkStart("cmd LOAD_DYLIB");24 check.checkStart("cmd LOAD_DYLIB");
25 check.checkNext("name @rpath/libsearch_dylibs_first.dylib");25 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;
28 run.expectStdOutEqual("Hello world");29 run.expectStdOutEqual("Hello world");
29 test_step.dependOn(&run.step);30 test_step.dependOn(&run.step);
30 }31 }
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...@@ -28,7 +28,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
28 check_exe.checkStart("cmd MAIN");28 check_exe.checkStart("cmd MAIN");
29 check_exe.checkNext("stacksize 100000000");29 check_exe.checkNext("stacksize 100000000");
3030
31 const run = check_exe.runAndCompare();31 const run = b.addRunArtifact(exe);
32 run.skip_foreign_checks = true;
32 run.expectStdOutEqual("");33 run.expectStdOutEqual("");
33 test_step.dependOn(&run.step);34 test_step.dependOn(&run.step);
34}35}
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...@@ -122,7 +122,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
122 else => unreachable,122 else => unreachable,
123 }123 }
124124
125 const run = check_exe.runAndCompare();125 const run = b.addRunArtifact(exe);
126 run.skip_foreign_checks = true;
126 run.expectStdOutEqual("Hello!\n");127 run.expectStdOutEqual("Hello!\n");
127 test_step.dependOn(&run.step);128 test_step.dependOn(&run.step);
128}129}
test/link/macho/unwind_info/build.zig+4-3
...@@ -47,8 +47,9 @@ fn testUnwindInfo(...@@ -47,8 +47,9 @@ fn testUnwindInfo(
47 check.checkInSymtab();47 check.checkInSymtab();
48 check.checkNext("{*} (__TEXT,__text) external ___gxx_personality_v0");48 check.checkNext("{*} (__TEXT,__text) external ___gxx_personality_v0");
4949
50 const run_cmd = check.runAndCompare();50 const run = b.addRunArtifact(exe);
51 run_cmd.expectStdOutEqual(51 run.skip_foreign_checks = true;
52 run.expectStdOutEqual(
52 \\Constructed: a53 \\Constructed: a
53 \\Constructed: b54 \\Constructed: b
54 \\About to destroy: b55 \\About to destroy: b
...@@ -57,7 +58,7 @@ fn testUnwindInfo(...@@ -57,7 +58,7 @@ fn testUnwindInfo(
57 \\58 \\
58 );59 );
5960
60 test_step.dependOn(&run_cmd.step);61 test_step.dependOn(&run.step);
61}62}
6263
63fn createScenario(64fn 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...@@ -46,7 +46,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
46 check.checkInSymtab();46 check.checkInSymtab();
47 check.checkNext("(undefined) weak external _asStr (from liba)");47 check.checkNext("(undefined) weak external _asStr (from liba)");
4848
49 const run_cmd = check.runAndCompare();49 const run = b.addRunArtifact(exe);
50 run_cmd.expectStdOutEqual("42 42");50 run.skip_foreign_checks = true;
51 test_step.dependOn(&run_cmd.step);51 run.expectStdOutEqual("42 42");
52 test_step.dependOn(&run.step);
52}53}