Skip to content

Commit 5924994

Browse files
committed
Fix run() for test_exe steps
1 parent 3771e77 commit 5924994

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/std/build.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,14 +1775,18 @@ pub const LibExeObjStep = struct {
17751775
/// Creates a `RunStep` with an executable built with `addExecutable`.
17761776
/// Add command line arguments with `addArg`.
17771777
pub fn run(exe: *LibExeObjStep) *RunStep {
1778-
assert(exe.kind == .exe);
1778+
assert(exe.kind == .exe or exe.kind == .test_exe);
17791779

17801780
// It doesn't have to be native. We catch that if you actually try to run it.
17811781
// Consider that this is declarative; the run step may not be run unless a user
17821782
// option is supplied.
17831783
const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name}));
17841784
run_step.addArtifactArg(exe);
17851785

1786+
if (exe.kind == .test_exe) {
1787+
run_step.addArg(exe.builder.zig_exe);
1788+
}
1789+
17861790
if (exe.vcpkg_bin_path) |path| {
17871791
run_step.addPathDir(path);
17881792
}
@@ -2065,7 +2069,7 @@ pub const LibExeObjStep = struct {
20652069
/// Returns the generated header file.
20662070
/// This function can only be called for libraries or object files which have `emit_h` set.
20672071
pub fn getOutputHSource(self: *LibExeObjStep) FileSource {
2068-
assert(self.kind != .exe);
2072+
assert(self.kind != .exe and self.kind != .test_exe and self.kind != .@"test");
20692073
assert(self.emit_h);
20702074
return FileSource{ .generated = &self.output_h_path_source };
20712075
}

0 commit comments

Comments
 (0)