Skip to content

Commit a902a4c

Browse files
committed
adjusted Python tests for MacOS
1 parent 2ef8db6 commit a902a4c

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

.github/workflows/CI-unixish.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,18 @@ jobs:
421421
- name: Test Signalhandler
422422
run: |
423423
cmake -S . -B cmake.output.signal -G "Unix Makefiles" -DBUILD_TESTS=On
424-
cmake --build cmake.output.signal --target test-signalhandler test-stacktrace -- -j$(nproc)
424+
cmake --build cmake.output.signal --target test-signalhandler -- -j$(nproc)
425425
cp cmake.output.signal/bin/test-s* .
426-
python3 -m pytest -Werror --strict-markers -vv test/signal/test-*.py
426+
python3 -m pytest -Werror --strict-markers -vv test/signal/test-signalhandler.py
427+
428+
# no unix backtrace support on MacOs
429+
- name: Test Stacktrace
430+
if: contains(matrix.os, 'ubuntu')
431+
run: |
432+
cmake -S . -B cmake.output.signal -G "Unix Makefiles" -DBUILD_TESTS=On
433+
cmake --build cmake.output.signal --target test-stacktrace -- -j$(nproc)
434+
cp cmake.output.signal/bin/test-s* .
435+
python3 -m pytest -Werror --strict-markers -vv test/signal/test-stacktrace.py
427436
428437
# TODO: move to scriptcheck.yml so these are tested with all Python versions?
429438
- name: Test addons

test/signal/test-signalhandler.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,43 @@ def _call_process(arg):
3232

3333
def test_assert():
3434
exitcode, stdout, stderr = _call_process('assert')
35-
assert stderr.endswith("test-signalhandler.cpp:32: void my_assert(): Assertion `false' failed.\n"), stderr
35+
if sys.platform == "darwin":
36+
assert stderr.startswith("Assertion failed: (false), function my_assert, file test-signalhandler.cpp, line "), stderr
37+
else:
38+
assert stderr.endswith("test-signalhandler.cpp:32: void my_assert(): Assertion `false' failed.\n"), stderr
3639
lines = stdout.splitlines()
3740
assert lines[0] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion'
38-
assert lines[1] == 'Callstack:'
39-
assert lines[2].endswith('my_abort()'), lines[2] # TODO: wrong function
40-
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
41+
# no stacktrace of MacOs
42+
if sys.platform != "darwin":
43+
assert lines[1] == 'Callstack:'
44+
assert lines[2].endswith('my_abort()'), lines[2] # TODO: wrong function
45+
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
4146

4247

4348
def test_abort():
4449
exitcode, stdout, stderr = _call_process('abort')
4550
lines = stdout.splitlines()
4651
assert lines[0] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion'
47-
assert lines[1] == 'Callstack:'
48-
assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function
49-
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
52+
# no stacktrace on MaCos
53+
if sys.platform != "darwin":
54+
assert lines[1] == 'Callstack:'
55+
assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function
56+
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
5057

5158

5259
def test_segv():
5360
exitcode, stdout, stderr = _call_process('segv')
5461
assert stderr == ''
5562
lines = stdout.splitlines()
56-
assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (reading at 0x0).'
57-
assert lines[1] == 'Callstack:'
58-
assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function
59-
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
63+
if sys.platform == "darwin":
64+
assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (at 0x0).'
65+
else:
66+
assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (reading at 0x0).'
67+
# no stacktrace on MacOS
68+
if sys.platform != "darwin":
69+
assert lines[1] == 'Callstack:'
70+
assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function
71+
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
6072

6173

6274
# TODO: make this work

0 commit comments

Comments
 (0)