From a659d4983939f9a82dbc242405296dc9b5620bd8 Mon Sep 17 00:00:00 2001 From: Sean T Allen Date: Wed, 27 Nov 2024 12:11:44 -0500 Subject: [PATCH] Don't swallow gtest failures when running tests in LLDB (#4552) In CI, we run our various tests in LLDB as a debugger. LLDB when run in batch mode like we are doing, always returns 0 as the exit code. It doesn't return the exit code from the program being run. The LLDB documentation states this is because more than 1 process can be being debugged so the concept that GDB has for returning the error code is more problematic with LLDB. The result of this is that non-exception errors in CI are not being flagged because LLDB is eating the exit code from gtest when a test fails. gest offers the `--gtest_throw_on_failure` option that turns test failures into exceptions. Those exceptions will be caught when we are using LLDB and reported correctly in CI. Long term, we have discussed adding an LLDB module with python to get us the "return exit code". There is discussion on Stack Overflow of this approach at https://stackoverflow.com/questions/56456724/quit-lldb-with-exit-code-of-process/76741573#76741573 --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a159e502f6..d0a775908d 100644 --- a/Makefile +++ b/Makefile @@ -163,6 +163,7 @@ endif ifneq ($(findstring lldb,$(usedebugger)),) debuggercmd := $(usedebugger) --batch --one-line "breakpoint set --name main" --one-line run --one-line "process handle SIGINT --pass true --stop false" --one-line "process handle SIGUSR2 --pass true --stop false" --one-line "thread continue" --one-line-on-crash "frame variable" --one-line-on-crash "register read" --one-line-on-crash "bt all" --one-line-on-crash "quit 1" -- + testextras := --gtest_throw_on_failure else ifneq ($(findstring gdb,$(usedebugger)),) debuggercmd := $(usedebugger) --quiet --batch --return-child-result --eval-command="set confirm off" --eval-command="set pagination off" --eval-command="handle SIGINT nostop pass" --eval-command="handle SIGUSR2 nostop pass" --eval-command=run --eval-command="info args" --eval-command="info locals" --eval-command="info registers" --eval-command="thread apply all bt full" --eval-command=quit --args else ifneq ($(strip $(usedebugger)),) @@ -214,10 +215,10 @@ test-check-version: all test-core: all test-libponyrt test-libponyc test-full-programs-release test-full-programs-debug test-libponyrt: all - $(SILENT)cd '$(outDir)' && $(debuggercmd) ./libponyrt.tests --gtest_shuffle + $(SILENT)cd '$(outDir)' && $(debuggercmd) ./libponyrt.tests --gtest_shuffle $(testextras) test-libponyc: all - $(SILENT)cd '$(outDir)' && $(debuggercmd) ./libponyc.tests --gtest_shuffle + $(SILENT)cd '$(outDir)' && $(debuggercmd) ./libponyc.tests --gtest_shuffle $(testextras) ifeq ($(shell uname -s),FreeBSD) num_cores := `sysctl -n hw.ncpu`