From 592499404527b49e9d09a8fa358a8d702e61f614 Mon Sep 17 00:00:00 2001 From: Martin Wickham Date: Mon, 6 Dec 2021 15:57:19 -0600 Subject: [PATCH] Fix run() for test_exe steps --- lib/std/build.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/std/build.zig b/lib/std/build.zig index 43633d82c4..e3e3041dbb 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1775,7 +1775,7 @@ pub const LibExeObjStep = struct { /// Creates a `RunStep` with an executable built with `addExecutable`. /// Add command line arguments with `addArg`. pub fn run(exe: *LibExeObjStep) *RunStep { - assert(exe.kind == .exe); + assert(exe.kind == .exe or exe.kind == .test_exe); // It doesn't have to be native. We catch that if you actually try to run it. // Consider that this is declarative; the run step may not be run unless a user @@ -1783,6 +1783,10 @@ pub const LibExeObjStep = struct { const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name})); run_step.addArtifactArg(exe); + if (exe.kind == .test_exe) { + run_step.addArg(exe.builder.zig_exe); + } + if (exe.vcpkg_bin_path) |path| { run_step.addPathDir(path); } @@ -2065,7 +2069,7 @@ pub const LibExeObjStep = struct { /// Returns the generated header file. /// This function can only be called for libraries or object files which have `emit_h` set. pub fn getOutputHSource(self: *LibExeObjStep) FileSource { - assert(self.kind != .exe); + assert(self.kind != .exe and self.kind != .test_exe and self.kind != .@"test"); assert(self.emit_h); return FileSource{ .generated = &self.output_h_path_source }; }