Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pre-install-commands = [

[envs.default.scripts]
sync = "pip install -r requirements-testing.txt"
test = "pytest --cov-config pyproject.toml {args:test}"
test = "pytest --cov-config pyproject.toml {args}"
typing = "mypy {args:src test}"
style = [
"ruff check {args:.}",
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ line-length = 100

[tool.pytest.ini_options]
xfail_strict = false
testpaths = [
"test"
]
addopts = [
"-rfEx",
"--durations=5",
Expand Down
11 changes: 10 additions & 1 deletion test/openjd/sessions/test_runner_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ def test_cancel_notify(
# Test that NOTIFY_THEN_CANCEL first signals a SIGTERM and then a SIGKILL

# GIVEN
proc_id: Optional[int] = None
logger = build_logger(queue_handler)
with NotifyingRunner(logger=logger, session_working_directory=tmp_path) as runner:
python_app_loc = (
Expand All @@ -833,6 +834,11 @@ def test_cancel_notify(
secs = 2 if not is_windows() else 5
time.sleep(secs) # Give the process a little time to do something
now = datetime.now(timezone.utc)

assert runner._process is not None
assert runner._process._pid is not None
proc_id = runner._process._pid

runner.cancel(time_limit=timedelta(seconds=2))

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