Skip to content

ci_expected_failures: --help works and a bad argument is one error line with exit 2 (EGEN-CIEXPECTED-CLI) - #6320

Open
evilclanker9000 wants to merge 3 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/7-ciexpected-cli
Open

evilclanker9000 wants to merge 3 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/7-ciexpected-cli

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

EGEN-CIEXPECTED-CLI

What changed and why

scripts/ci_expected_failures.py judges a CI run, but it treated its own arguments as trusted:

  • --help (or -h) was counted as a missing argument, so it printed the docstring to stderr and returned 2. It now prints the same text on stdout and returns 0, as the other scripts and tools do.
  • int(argv[1]) and open(argv[0]) were unguarded, so a non-numeric EXIT_STATUS or a FAILED_LIST that does not exist ended in a ValueError/FileNotFoundError traceback with exit 1. Each is now one line on stderr and exit 2, the usage-error code the script already returns for a missing argument.

The command line is unchanged; both workflow steps (.github/workflows/runtime.yml:551 and :574) pass a list and a numeric status as before.

Test

python -I tests/test_ci_expected_failures.py (no game files, no GPU):

  • Before, with scripts/ci_expected_failures.py from 561b65a8: Ran 11 tests ... FAILED (failures=1, errors=2). test_help_prints_the_usage_and_succeeds fails (it returned 2), and the two input-error tests end in the tracebacks (code, lines = judge(failed, int(argv[1]), expected)).
  • After: Ran 11 tests in 0.018s - OK, exit 0.

End to end:

python -I scripts/ci_expected_failures.py --help          # exit 0, the usage on stdout
python -I scripts/ci_expected_failures.py <absent.txt> 8  # exit 2: ci_expected_failures: <absent.txt>: No such file or directory
python -I scripts/ci_expected_failures.py <failed.txt> x  # exit 2: ci_expected_failures: EXIT_STATUS 'x' is not an integer
python -I scripts/ci_expected_failures.py <failed.txt> 7  # unchanged: ::error:: lines, exit 1

python -m compileall -q scripts tests passes.

GPU

No GPU needed.

Notes

  • Exit 2 for both input errors, because that is what the script already returns for a missing argument and what the tools use for a usage or input error. The docstring says so, and docs/testing.md gained one sentence with the command line and that exit code.
  • Kept the hand-rolled argument handling instead of switching to argparse, so main(argv) keeps returning an int (the existing test_missing_arguments_is_a_usage_error calls it that way) and the judged output stays byte-for-byte the same.
  • Three commits: the two input guards, --help, and the docs sentence.

AI-assisted.

…ot a traceback

main() called int(EXIT_STATUS) and open(FAILED_LIST) unguarded, so a workflow step that passed a non-numeric status or a list that does not exist ended in a ValueError/FileNotFoundError traceback (exit 1) instead of naming the argument. Each is now one line on stderr and exit 2, the usage-error code the script already returns for missing arguments.
argv0 of -h/--help was counted as a missing argument, so the script printed its docstring to stderr and returned 2. It now prints the same text on stdout and returns 0, like the other scripts under scripts/ and tools/.
…nput-error exit

The macOS paragraph named scripts/ci_expected_failures.py without its arguments or what it does with a bad one, so a reader had to open the script to learn the list/status order and that an unreadable list is one line, not a traceback.
@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown

Independent verification on Windows 11 (CPython 3.14.0, CPU only, no game files):

  • Negative control reproduction: With scripts/ci_expected_failures.py checked out from origin/main (561b65a):
    \
    FAILED (failures=1, errors=2)
    • ERROR: test_a_list_that_cannot_be_read_is_one_error_line (FileNotFoundError traceback)
    • ERROR: test_a_non_integer_status_is_one_error_line (ValueError traceback)
    • FAIL: test_help_prints_the_usage_and_succeeds (AssertionError: 2 != 0)
      \\
  • With PR 6320: All 11 tests pass (\python -I tests/test_ci_expected_failures.py).
  • \git diff --check origin/main...HEAD\ is clean.
  • \python -m compileall -q scripts tests\ is clean.
  • \python -I tests/test_docs_links.py\ passed (6/6).

LGTM!

AI-assisted.

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.

2 participants