Skip to content

Commit

Permalink
adjusted Python tests for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Feb 20, 2024
1 parent 2ef8db6 commit b6b6fd5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 23 additions & 11 deletions test/signal/test-signalhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b6b6fd5

Please sign in to comment.