Skip to content

Fix silently-passing subprocess tests and process resource leak#112

Merged
filmor merged 5 commits intomainfrom
copilot/fix-pickling-error-in-multiprocessing
Mar 19, 2026
Merged

Fix silently-passing subprocess tests and process resource leak#112
filmor merged 5 commits intomainfrom
copilot/fix-pickling-error-in-multiprocessing

Conversation

Copy link
Contributor

Copilot AI commented Mar 18, 2026

run_in_subprocess never checked p.exitcode, so subprocess crashes were invisible — tests reported PASSED while error tracebacks printed to stderr. This masked a pre-existing bug in test_coreclr_properties and left processes unclosed on failure.

Changes

  • Assert subprocess exit coderun_in_subprocess now asserts p.exitcode == 0, turning silent subprocess failures into actual test failures.

  • Wrap assertion in try/finally — ensures p.close() is always called, preventing ResourceWarning: process not closed when the assertion raises.

  • Fix test_coreclr_properties kwarg mis-passing — was passing properties=dict(APP_CONTEXT_BASE_DIRECTORY=...), which **properties captured as {'properties': {'APP_CONTEXT_BASE_DIRECTORY': ...}}, causing AttributeError: 'dict' object has no attribute 'encode' in the subprocess. Fixed by passing the kwarg directly:

    # Before (broken)
    run_in_subprocess(..., properties=dict(APP_CONTEXT_BASE_DIRECTORY=str(example_netcore)))
    
    # After (correct)
    run_in_subprocess(..., APP_CONTEXT_BASE_DIRECTORY=str(example_netcore))
  • Move fixtures to conftest.py — separates build fixtures from test logic.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: lostmsu <239520+lostmsu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix pickling error in multiprocessing Fix PicklingError in spawn subprocesses with pytest 9 + Python 3.13 Mar 18, 2026
Copilot AI requested a review from lostmsu March 18, 2026 18:43
Copilot AI changed the title Fix PicklingError in spawn subprocesses with pytest 9 + Python 3.13 Fix PicklingError in spawn subprocesses on Python 3.13 with pytest 9 Mar 18, 2026
…properties kwargs

The real reason CI doesn't fail despite Python 3.13 being tested:
run_in_subprocess never checked p.exitcode, so any subprocess crash was
silently ignored by the parent test.

Adding the assert immediately exposes a pre-existing bug:
test_coreclr_properties passed properties=dict(...) as a single kwarg,
but _do_test_coreclr_autogenerated_runtimeconfig uses **properties to
collect individual kwargs. This double-wrapped the dict, causing
AttributeError: 'dict' object has no attribute 'encode' in the subprocess
— silently swallowed until now.

Co-authored-by: lostmsu <239520+lostmsu@users.noreply.github.com>
Copilot AI changed the title Fix PicklingError in spawn subprocesses on Python 3.13 with pytest 9 Fix silently-passing subprocess tests and broken property kwarg Mar 18, 2026
… always runs

Without try/finally, if `assert p.exitcode == 0` raises AssertionError,
`p.close()` is never called. This leaves the Process object unclosed
and causes `ResourceWarning: process ... not closed` on Python 3.12+.

Co-authored-by: lostmsu <239520+lostmsu@users.noreply.github.com>
Copilot AI changed the title Fix silently-passing subprocess tests and broken property kwarg Fix silently-passing subprocess tests and process resource leak Mar 18, 2026
@filmor filmor marked this pull request as ready for review March 19, 2026 10:37
@filmor filmor merged commit e14cebd into main Mar 19, 2026
34 checks passed
@filmor filmor deleted the copilot/fix-pickling-error-in-multiprocessing branch March 19, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants