From eab44307f02fe73f3ea6fa05b45f2ab2eb45eaac Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 14 Mar 2024 12:37:59 +0100 Subject: [PATCH] run-tests: Avoid starting a shell to spawn test processes --- tests/run-tests.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/run-tests.cpp b/tests/run-tests.cpp index b98414b1..6560b3d0 100644 --- a/tests/run-tests.cpp +++ b/tests/run-tests.cpp @@ -24,7 +24,13 @@ Result luna_main(int argc, char** argv) for (const auto& program : files) { auto command = TRY(String::format("%s/%s"_sv, test_dir.chars(), program.chars())); - int status = system(command.chars()); + StringView args[] = { command.view() }; + + auto pid = TRY(os::Process::spawn(args[0], Slice { args, 1 }, false)); + + int status; + TRY(os::Process::wait(pid, &status)); + if (WEXITSTATUS(status) != 0) { os::Process::kill(1, SIGQUIT); // Tell init to report a failed test run.