Skip to content

test(background): add process lifecycle, polling, and PID validation tests - #111

Merged
knight22-21 merged 1 commit into
knight22-21:mainfrom
chiragjangiir:test/background-jobs-coverage-72
Oct 22, 2026
Merged

knight22-21 merged 1 commit into
knight22-21:mainfrom
chiragjangiir:test/background-jobs-coverage-72

Conversation

@chiragjangiir

Copy link
Copy Markdown
Contributor

Closes #72

Summary

This PR addresses issue #72 by adding comprehensive unit test coverage for devagent/background/jobs.py.

Changes

  1. Safety Fix: In devagent/background/jobs.py:_is_running, added a guard for pid <= 0 returning False. On POSIX systems, calling os.kill(0, 0) checks if the calling process group is alive, which would incorrectly report invalid/dummy PID 0 as running.
  2. Unit Tests Added (tests/test_background_jobs.py):
    • test_is_running_invalid_pid: tests that PID 0 and negative PIDs are safely identified as not running.
    • test_launch_creates_state_and_log_files: tests state and log initialization upon job launch.
    • test_poll_running_process: tests poll state when a background process is still active.
    • test_poll_exit_zero: tests exit state resolution and file persistence when the process exits cleanly.
    • test_poll_exit_nonzero: tests exit state resolution when the process fails with non-zero code.
    • test_poll_exit_no_journal: tests fallback to unknown when no exit journal file exists.
    • test_list_jobs_empty & test_list_jobs_mixed: tests listing multiple background jobs in varying states.

Verification

  • Ran pytest tests/test_background_jobs.py (11/11 tests pass in 0.06s).

@knight22-21
knight22-21 merged commit 1cb79f4 into knight22-21:main Oct 22, 2026
5 checks passed
@knight22-21

Copy link
Copy Markdown
Owner

Thanks for the tests, @chiragjangiir! Adding comprehensive lifecycle, polling, and PID validation coverage tests for the background job manager.

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.

No test coverage for background/jobs.py; platform-specific process management logic is entirely untested

2 participants