Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions lib/std/Build/Step/CheckObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions test/link/macho/dead_strip/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

{
Expand All @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/link/macho/dylib/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion test/link/macho/entry/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion test/link/macho/entry_in_dylib/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
7 changes: 4 additions & 3 deletions test/link/macho/needed_library/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion test/link/macho/search_strategy/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion test/link/macho/stack_size/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion test/link/macho/strict_validation/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
7 changes: 4 additions & 3 deletions test/link/macho/unwind_info/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -57,7 +58,7 @@ fn testUnwindInfo(
\\
);

test_step.dependOn(&run_cmd.step);
test_step.dependOn(&run.step);
}

fn createScenario(
Expand Down
7 changes: 4 additions & 3 deletions test/link/macho/weak_library/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}