]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
test: Relax util::exec_to_string missing command assertion
authorMaksym Sobolyev <sobomax@sippysoft.com>
Fri, 13 Mar 2026 01:56:40 +0000 (18:56 -0700)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 21 Mar 2026 09:23:20 +0000 (10:23 +0100)
The POSIX error for a missing command is not stable across systems. Some
environments report the posix_spawnp failure directly, while others
return a shell-style "Non-zero exit code: 127" instead.

Accept both outcomes in the test and capture the actual error string to
make future failures easier to diagnose.

unittest/test_util_exec.cpp

index 42b3da95b585ef090d9ad0f19bde8d35b58cd9dd..d4c85fd3ce4edf64ed3a81a817268fa99736fc65 100644 (file)
@@ -57,7 +57,11 @@ TEST_CASE("util::exec_to_string")
 #ifdef _WIN32
     CHECK(result.error().starts_with("CreateProcess failure: "));
 #else
-    CHECK(result.error() == "posix_spawnp failed: No such file or directory");
+    CAPTURE(result.error());
+    const bool expected_spawn_failure =
+      result.error().starts_with("posix_spawnp failed: ")
+      || result.error() == "Non-zero exit code: 127";
+    CHECK(expected_spawn_failure);
 #endif
   }
 }