From b6b6fd52c367424e4ecfcfb0ca222bc5dd9291f7 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 20 Feb 2024 14:19:09 +0100 Subject: [PATCH] adjusted Python tests for MacOS --- .github/workflows/CI-unixish.yml | 13 ++++++++++-- test/signal/test-signalhandler.py | 34 +++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index dbe148272f54..3b62410a4011 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -421,9 +421,18 @@ jobs: - name: Test Signalhandler run: | cmake -S . -B cmake.output.signal -G "Unix Makefiles" -DBUILD_TESTS=On - cmake --build cmake.output.signal --target test-signalhandler test-stacktrace -- -j$(nproc) + cmake --build cmake.output.signal --target test-signalhandler -- -j$(nproc) cp cmake.output.signal/bin/test-s* . - python3 -m pytest -Werror --strict-markers -vv test/signal/test-*.py + python3 -m pytest -Werror --strict-markers -vv test/signal/test-signalhandler.py + + # no unix backtrace support on MacOs + - name: Test Stacktrace + if: !contains(matrix.os, 'macos') + run: | + cmake -S . -B cmake.output.signal -G "Unix Makefiles" -DBUILD_TESTS=On + cmake --build cmake.output.signal --target test-stacktrace -- -j$(nproc) + cp cmake.output.signal/bin/test-s* . + python3 -m pytest -Werror --strict-markers -vv test/signal/test-stacktrace.py # TODO: move to scriptcheck.yml so these are tested with all Python versions? - name: Test addons diff --git a/test/signal/test-signalhandler.py b/test/signal/test-signalhandler.py index 1562a5e22382..93303d008591 100644 --- a/test/signal/test-signalhandler.py +++ b/test/signal/test-signalhandler.py @@ -32,31 +32,43 @@ def _call_process(arg): def test_assert(): exitcode, stdout, stderr = _call_process('assert') - assert stderr.endswith("test-signalhandler.cpp:32: void my_assert(): Assertion `false' failed.\n"), stderr + if sys.platform == "darwin": + assert stderr.startswith("Assertion failed: (false), function my_assert, file test-signalhandler.cpp, line "), stderr + else: + assert stderr.endswith("test-signalhandler.cpp:32: void my_assert(): Assertion `false' failed.\n"), stderr lines = stdout.splitlines() assert lines[0] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion' - assert lines[1] == 'Callstack:' - assert lines[2].endswith('my_abort()'), lines[2] # TODO: wrong function - assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!' + # no stacktrace of MacOs + if sys.platform != "darwin": + assert lines[1] == 'Callstack:' + assert lines[2].endswith('my_abort()'), lines[2] # TODO: wrong function + assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!' def test_abort(): exitcode, stdout, stderr = _call_process('abort') lines = stdout.splitlines() assert lines[0] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion' - assert lines[1] == 'Callstack:' - assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function - assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!' + # no stacktrace on MaCos + if sys.platform != "darwin": + assert lines[1] == 'Callstack:' + assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function + assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!' def test_segv(): exitcode, stdout, stderr = _call_process('segv') assert stderr == '' lines = stdout.splitlines() - assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (reading at 0x0).' - assert lines[1] == 'Callstack:' - assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function - assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!' + if sys.platform == "darwin": + assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (at 0x0).' + else: + assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (reading at 0x0).' + # no stacktrace on MacOS + if sys.platform != "darwin": + assert lines[1] == 'Callstack:' + assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function + assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!' # TODO: make this work