Description
Following the review and merge of PR #171 (which resolved the command injection vulnerabilities and added type safety, timeout, and exit code checking to run_cmd), there are a few remaining tasks to ensure robustness and code cleanliness.
Remaining Tasks
-
Add Unit Tests for run_cmd in scripts/get_pr_status.py
- Create a test file
tests/test_get_pr_status.py to cover run_cmd behavior.
- Verify that
run_cmd correctly strips whitespace from output.
- Verify that non-zero exit codes raise
subprocess.CalledProcessError.
- Verify that executing commands that hang triggers a
subprocess.TimeoutExpired exception.
-
Evaluate/Implement get_pr_status.py Logic
- Currently,
scripts/get_pr_status.py only contains the helper run_cmd function but has no other implementation or entrypoint.
- We need to determine if
get_pr_status.py should be expanded with actual PR query logic (e.g. using gh CLI commands to check PR review status, unresolved comments, or check statuses) or if the helper should be moved to a shared utility/removed if obsolete.
Example Code for Unit Tests
import pytest
import subprocess
from scripts.get_pr_status import run_cmd
def test_run_cmd_success():
output = run_cmd(["echo", "hello"])
assert output == "hello"
def test_run_cmd_error():
with pytest.raises(subprocess.CalledProcessError):
run_cmd(["false"])
def test_run_cmd_timeout():
with pytest.raises(subprocess.TimeoutExpired):
run_cmd(["sleep", "31"])
Description
Following the review and merge of PR #171 (which resolved the command injection vulnerabilities and added type safety, timeout, and exit code checking to
run_cmd), there are a few remaining tasks to ensure robustness and code cleanliness.Remaining Tasks
Add Unit Tests for
run_cmdinscripts/get_pr_status.pytests/test_get_pr_status.pyto coverrun_cmdbehavior.run_cmdcorrectly strips whitespace from output.subprocess.CalledProcessError.subprocess.TimeoutExpiredexception.Evaluate/Implement
get_pr_status.pyLogicscripts/get_pr_status.pyonly contains the helperrun_cmdfunction but has no other implementation or entrypoint.get_pr_status.pyshould be expanded with actual PR query logic (e.g. usingghCLI commands to check PR review status, unresolved comments, or check statuses) or if the helper should be moved to a shared utility/removed if obsolete.Example Code for Unit Tests