Merge pull request #4860 from tiennou/ci/macos-leaks CI: Fix macOS leak detection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/ci/test.sh b/ci/test.sh
index 1bc710a..10c4d84 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -14,7 +14,7 @@ USER=${USER:-$(whoami)}
SUCCESS=1
VALGRIND="valgrind --leak-check=full --show-reachable=yes --error-exitcode=125 --num-callers=50 --suppressions=\"$SOURCE_DIR/libgit2_clar.supp\""
-LEAKS="MallocStackLogging=1 MallocScribble=1 leaks -quiet -atExit -- nohup"
+LEAKS="MallocStackLogging=1 MallocScribble=1 MallocLogFile=/dev/null CLAR_AT_EXIT=\"leaks -quiet \$PPID\""
cleanup() {
echo "Cleaning up..."
diff --git a/tests/main.c b/tests/main.c
index b4fccec..00b2bae 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -8,6 +8,7 @@ int main(int argc, char *argv[])
#endif
{
int res;
+ char *at_exit_cmd;
clar_test_init(argc, argv);
@@ -28,5 +29,11 @@ int main(int argc, char *argv[])
cl_global_trace_disable();
git_libgit2_shutdown();
+ at_exit_cmd = getenv("CLAR_AT_EXIT");
+ if (at_exit_cmd != NULL) {
+ int at_exit = system(at_exit_cmd);
+ return res || at_exit;
+ }
+
return res;
}