Remove CheckObjectStep.runAndCompare (#15973)

Closes #14969
This commit is contained in:
Zapolsky Anton 2023-06-13 21:09:24 +03:00 committed by GitHub
parent 854f26ad8a
commit c76ce25a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 32 additions and 37 deletions

View File

@ -42,22 +42,6 @@ pub fn create(
return self; 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 { const SearchPhrase = struct {
string: []const u8, string: []const u8,
file_source: ?std.Build.FileSource = null, file_source: ?std.Build.FileSource = null,

View File

@ -17,9 +17,10 @@ pub fn build(b: *std.Build) void {
check.checkInSymtab(); check.checkInSymtab();
check.checkNext("{*} (__TEXT,__text) external _iAmUnused"); check.checkNext("{*} (__TEXT,__text) external _iAmUnused");
const run_cmd = check.runAndCompare(); const run = b.addRunArtifact(exe);
run_cmd.expectStdOutEqual("Hello!\n"); run.skip_foreign_checks = true;
test_step.dependOn(&run_cmd.step); run.expectStdOutEqual("Hello!\n");
test_step.dependOn(&run.step);
} }
{ {
@ -31,9 +32,10 @@ pub fn build(b: *std.Build) void {
check.checkInSymtab(); check.checkInSymtab();
check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused"); check.checkNotPresent("{*} (__TEXT,__text) external _iAmUnused");
const run_cmd = check.runAndCompare(); const run = b.addRunArtifact(exe);
run_cmd.expectStdOutEqual("Hello!\n"); run.skip_foreign_checks = true;
test_step.dependOn(&run_cmd.step); run.expectStdOutEqual("Hello!\n");
test_step.dependOn(&run.step);
} }
} }

View File

@ -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.checkStart("cmd RPATH");
check_exe.checkNextFileSource("path", dylib.getOutputDirectorySource()); 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"); run.expectStdOutEqual("Hello world");
test_step.dependOn(&run.step); test_step.dependOn(&run.step);
} }

View File

@ -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" } }); 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"); run.expectStdOutEqual("42");
test_step.dependOn(&run.step); test_step.dependOn(&run.step);
} }

View File

@ -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 .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"); run.expectStdOutEqual("Hello!\n");
test_step.dependOn(&run.step); test_step.dependOn(&run.step);
} }

View File

@ -42,7 +42,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check.checkStart("cmd LOAD_DYLIB"); check.checkStart("cmd LOAD_DYLIB");
check.checkNext("name @rpath/liba.dylib"); check.checkNext("name @rpath/liba.dylib");
const run_cmd = check.runAndCompare(); const run = b.addRunArtifact(exe);
run_cmd.expectStdOutEqual(""); run.skip_foreign_checks = true;
test_step.dependOn(&run_cmd.step); run.expectStdOutEqual("");
test_step.dependOn(&run.step);
} }

View File

@ -24,7 +24,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check.checkStart("cmd LOAD_DYLIB"); check.checkStart("cmd LOAD_DYLIB");
check.checkNext("name @rpath/libsearch_dylibs_first.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"); run.expectStdOutEqual("Hello world");
test_step.dependOn(&run.step); test_step.dependOn(&run.step);
} }

View File

@ -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.checkStart("cmd MAIN");
check_exe.checkNext("stacksize 100000000"); check_exe.checkNext("stacksize 100000000");
const run = check_exe.runAndCompare(); const run = b.addRunArtifact(exe);
run.skip_foreign_checks = true;
run.expectStdOutEqual(""); run.expectStdOutEqual("");
test_step.dependOn(&run.step); test_step.dependOn(&run.step);
} }

View File

@ -122,7 +122,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
else => unreachable, else => unreachable,
} }
const run = check_exe.runAndCompare(); const run = b.addRunArtifact(exe);
run.skip_foreign_checks = true;
run.expectStdOutEqual("Hello!\n"); run.expectStdOutEqual("Hello!\n");
test_step.dependOn(&run.step); test_step.dependOn(&run.step);
} }

View File

@ -47,8 +47,9 @@ fn testUnwindInfo(
check.checkInSymtab(); check.checkInSymtab();
check.checkNext("{*} (__TEXT,__text) external ___gxx_personality_v0"); check.checkNext("{*} (__TEXT,__text) external ___gxx_personality_v0");
const run_cmd = check.runAndCompare(); const run = b.addRunArtifact(exe);
run_cmd.expectStdOutEqual( run.skip_foreign_checks = true;
run.expectStdOutEqual(
\\Constructed: a \\Constructed: a
\\Constructed: b \\Constructed: b
\\About to destroy: b \\About to destroy: b
@ -57,7 +58,7 @@ fn testUnwindInfo(
\\ \\
); );
test_step.dependOn(&run_cmd.step); test_step.dependOn(&run.step);
} }
fn createScenario( fn createScenario(

View File

@ -46,7 +46,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
check.checkInSymtab(); check.checkInSymtab();
check.checkNext("(undefined) weak external _asStr (from liba)"); check.checkNext("(undefined) weak external _asStr (from liba)");
const run_cmd = check.runAndCompare(); const run = b.addRunArtifact(exe);
run_cmd.expectStdOutEqual("42 42"); run.skip_foreign_checks = true;
test_step.dependOn(&run_cmd.step); run.expectStdOutEqual("42 42");
test_step.dependOn(&run.step);
} }