build: inherit setExecCmd from test compile steps when creating run steps

This should fix #17756
This commit is contained in:
Robin Voetter
2024-04-13 15:30:03 +02:00
parent fba6b7e4c2
commit 44443b833b

View File

@@ -972,10 +972,24 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
// Consider that this is declarative; the run step may not be run unless a user
// option is supplied.
const run_step = Step.Run.create(b, b.fmt("run {s}", .{exe.name}));
run_step.addArtifactArg(exe);
if (exe.kind == .@"test") {
if (exe.exec_cmd_args) |exec_cmd_args| {
for (exec_cmd_args) |cmd_arg| {
if (cmd_arg) |arg| {
run_step.addArg(arg);
} else {
run_step.addArtifactArg(exe);
}
}
} else {
run_step.addArtifactArg(exe);
}
if (exe.kind == .@"test" and exe.test_server_mode) {
run_step.enableTestRunnerMode();
if (exe.test_server_mode) {
run_step.enableTestRunnerMode();
}
} else {
run_step.addArtifactArg(exe);
}
return run_step;