Skip to content

Classify a Subprocess Failure by Its Command, Not Its Message Text #3363

Closed

Description

@ptr727

Context

During the promotion of the Windows audit self-test fix, the first narrowing of a skip matched the failing command's stderr for the text "invalid path". Git for Windows printed different wording, so the skip never fired and the Windows job failed. The fix that held named the failing command instead: a control file is added first with the failure fatal everywhere, then the probe's own file is added alone, and only that one add may skip.

Proposal

Add a rule to CODESTYLE.md General: classify a subprocess failure by which command failed and its exit status, never by matching its message text, because that text varies by tool version and locale. Where one command can fail for an expected reason and an unexpected one, split it so that each failure has its own command.

Constructed Example

subprocess.run(["git", "add", "--", "control.txt"], cwd=repo, check=True)
try:
    subprocess.run(["git", "add", "--", probe_name], cwd=repo, check=True)
except subprocess.CalledProcessError:
    skip("this host's git cannot add the probe name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions