diff --git a/Userland/Libraries/LibTest/TestMain.cpp b/Userland/Libraries/LibTest/TestMain.cpp index 657946fad7..0eace12ed2 100644 --- a/Userland/Libraries/LibTest/TestMain.cpp +++ b/Userland/Libraries/LibTest/TestMain.cpp @@ -29,5 +29,8 @@ int TEST_MAIN(int argc, char** argv) int ret = ::Test::TestSuite::the().main(argv[0], arguments); ::Test::TestSuite::release(); - return ret; + // As TestSuite::main() returns the number of test cases that did not pass, + // ret can be >=256 which cannot be returned as an exit status directly. + // Return 0 if all of the test cases pass and return 1 otherwise. + return ret != 0; } diff --git a/Userland/Utilities/run-tests.cpp b/Userland/Utilities/run-tests.cpp index a1825b16d0..bdd5da182e 100644 --- a/Userland/Utilities/run-tests.cpp +++ b/Userland/Utilities/run-tests.cpp @@ -280,7 +280,7 @@ FileResult TestRunner::run_test_file(ByteString const& test_path) break; // we'll end up with a failure if (WIFEXITED(wstatus)) { - if (wstatus == 0) { + if (WEXITSTATUS(wstatus) == 0) { test_result = Test::Result::Pass; } break;