| author | |
| committer | |
| log | c76ce25a6165e96015b11d506e3c968c6c8dca2c |
| tree | 0b83e93af54588d41593fd941acfe72180b60577 |
| parent | 854f26ad8ac8dc39ef7ad60f86588c0c5dba131a |
| signature |
Closes #1496911 files changed, 32 insertions(+), 37 deletions(-)
lib/std/Build/Step/CheckObject.zig-16| ... | ... | @@ -42,22 +42,6 @@ pub fn create( |
| 42 | 42 | return self; |
| 43 | 43 | } |
| 44 | 44 | |
| 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 | ||
| 61 | 45 | const SearchPhrase = struct { |
| 62 | 46 | string: []const u8, |
| 63 | 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 | 17 | check.checkInSymtab(); |
| 18 | 18 | check.checkNext("{*} (__TEXT,__text) external _iAmUnused"); |
| 19 | 19 | |
| 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); | |
| 23 | 24 | } |
| 24 | 25 | |
| 25 | 26 | { |
| ... | ... | @@ -31,9 +32,10 @@ pub fn build(b: *std.Build) void { |
| 31 | 32 | check.checkInSymtab(); |
| 32 | 33 | check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused"); |
| 33 | 34 | |
| 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); | |
| 37 | 39 | } |
| 38 | 40 | } |
| 39 | 41 |
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 | 54 | check_exe.checkStart("cmd RPATH"); |
| 55 | 55 | check_exe.checkNextFileSource("path", dylib.getOutputDirectorySource()); |
| 56 | 56 | |
| 57 | const run = check_exe.runAndCompare(); | |
| 57 | const run = b.addRunArtifact(exe); | |
| 58 | run.skip_foreign_checks = true; | |
| 58 | 59 | run.expectStdOutEqual("Hello world"); |
| 59 | 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 | 35 | |
| 36 | 36 | check_exe.checkComputeCompare("vmaddr entryoff +", .{ .op = .eq, .value = .{ .variable = "n_value" } }); |
| 37 | 37 | |
| 38 | const run = check_exe.runAndCompare(); | |
| 38 | const run = b.addRunArtifact(exe); | |
| 39 | run.skip_foreign_checks = true; | |
| 39 | 40 | run.expectStdOutEqual("42"); |
| 40 | 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 | 48 | .value = .{ .variable = "stubs_vmaddr" }, // The entrypoint should be a synthetic stub |
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | const run = check_exe.runAndCompare(); | |
| 51 | const run = b.addRunArtifact(exe); | |
| 52 | run.skip_foreign_checks = true; | |
| 52 | 53 | run.expectStdOutEqual("Hello!\n"); |
| 53 | 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 | 42 | check.checkStart("cmd LOAD_DYLIB"); |
| 43 | 43 | check.checkNext("name @rpath/liba.dylib"); |
| 44 | 44 | |
| 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); | |
| 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 | 24 | check.checkStart("cmd LOAD_DYLIB"); |
| 25 | 25 | check.checkNext("name @rpath/libsearch_dylibs_first.dylib"); |
| 26 | 26 | |
| 27 | const run = check.runAndCompare(); | |
| 27 | const run = b.addRunArtifact(exe); | |
| 28 | run.skip_foreign_checks = true; | |
| 28 | 29 | run.expectStdOutEqual("Hello world"); |
| 29 | 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 | 28 | check_exe.checkStart("cmd MAIN"); |
| 29 | 29 | check_exe.checkNext("stacksize 100000000"); |
| 30 | 30 | |
| 31 | const run = check_exe.runAndCompare(); | |
| 31 | const run = b.addRunArtifact(exe); | |
| 32 | run.skip_foreign_checks = true; | |
| 32 | 33 | run.expectStdOutEqual(""); |
| 33 | 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 | 122 | else => unreachable, |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | const run = check_exe.runAndCompare(); | |
| 125 | const run = b.addRunArtifact(exe); | |
| 126 | run.skip_foreign_checks = true; | |
| 126 | 127 | run.expectStdOutEqual("Hello!\n"); |
| 127 | 128 | test_step.dependOn(&run.step); |
| 128 | 129 | } |
test/link/macho/unwind_info/build.zig+4-3| ... | ... | @@ -47,8 +47,9 @@ fn testUnwindInfo( |
| 47 | 47 | check.checkInSymtab(); |
| 48 | 48 | check.checkNext("{*} (__TEXT,__text) external ___gxx_personality_v0"); |
| 49 | 49 | |
| 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( | |
| 52 | 53 | \\Constructed: a |
| 53 | 54 | \\Constructed: b |
| 54 | 55 | \\About to destroy: b |
| ... | ... | @@ -57,7 +58,7 @@ fn testUnwindInfo( |
| 57 | 58 | \\ |
| 58 | 59 | ); |
| 59 | 60 | |
| 60 | test_step.dependOn(&run_cmd.step); | |
| 61 | test_step.dependOn(&run.step); | |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | fn 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 | 46 | check.checkInSymtab(); |
| 47 | 47 | check.checkNext("(undefined) weak external _asStr (from liba)"); |
| 48 | 48 | |
| 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); | |
| 52 | 53 | } |