Skip to content

Commit ba4857b

Browse files
committed
test: cancel notify - message immediately after 'Trapped' may not be digit
Signed-off-by: Morgan Epp <60796713+epmog@users.noreply.github.com>
1 parent 48fdc35 commit ba4857b

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

hatch.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pre-install-commands = [
55

66
[envs.default.scripts]
77
sync = "pip install -r requirements-testing.txt"
8-
test = "pytest --cov-config pyproject.toml {args:test}"
8+
test = "pytest --cov-config pyproject.toml {args}"
99
typing = "mypy {args:src test}"
1010
style = [
1111
"ruff check {args:.}",

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ line-length = 100
137137

138138
[tool.pytest.ini_options]
139139
xfail_strict = false
140+
testpaths = [
141+
"test"
142+
]
140143
addopts = [
141144
"-rfEx",
142145
"--durations=5",

test/openjd/sessions/test_runner_base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ def test_cancel_notify(
822822
# Test that NOTIFY_THEN_CANCEL first signals a SIGTERM and then a SIGKILL
823823

824824
# GIVEN
825+
proc_id: Optional[int] = None
825826
logger = build_logger(queue_handler)
826827
with NotifyingRunner(logger=logger, session_working_directory=tmp_path) as runner:
827828
python_app_loc = (
@@ -833,6 +834,7 @@ def test_cancel_notify(
833834
secs = 2 if not is_windows() else 5
834835
time.sleep(secs) # Give the process a little time to do something
835836
now = datetime.now(timezone.utc)
837+
proc_id = runner._process._pid
836838
runner.cancel(time_limit=timedelta(seconds=2))
837839

838840
# THEN
@@ -849,9 +851,10 @@ def test_cancel_notify(
849851
messages = collect_queue_messages(message_queue)
850852
assert "Trapped" in messages
851853
trapped_idx = messages.index("Trapped")
854+
process_exit_idx = messages.index(f"Process pid {proc_id} exited with code: {runner.exit_code} (unsigned) / {hex(runner.exit_code)} (hex)")
852855
# Should be at least one more number printed after the Trapped
853856
# to indicate that we didn't immediately terminate the script.
854-
assert messages[trapped_idx + 1].isdigit()
857+
assert any(msg.isdigit() for msg in messages[trapped_idx + 1 : process_exit_idx])
855858
# Didn't get to the end
856859
assert "Log from test 9" not in messages
857860
# Notification file exists

0 commit comments

Comments
 (0)