Skip to content

tools/xcl_compare: refuse an --out that names a folder at main start - #5791

Open
evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/1-xcl-out-folder
Open

evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/1-xcl-out-folder

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

tools/xcl_compare.py writes its report last: after the XCL reference run and the gta6rt run, each a title launch with a 15 s hang timeout and up to eight restarts. A --out that names an existing folder therefore ended a multi-minute run in a raw traceback:

  File "tools/xcl_compare.py", line 270, in run_all
    with open(out, "w", encoding="utf-8", newline="\n") as f:
IsADirectoryError: [Errno 21] Is a directory: '...\\xclout'

Every other report tool in tools/ refuses that in main() (anim_index.py, page_index.py, bink_index.py, ...), before the scan or run starts. This does the same, one line plus the message, and adds the test that pins it.

Test:

python -I tests/test_xcl_compare_out.py

Before the change, with --out naming a folder, main() reached the XCL check and the test failed:

FAIL: test_out_naming_a_folder_is_refused_at_start
AssertionError: 1 != 2 : no built XCL in ...\\xcl: run 'cargo build --release --workspace' there first
Ran 2 tests in 0.245s
FAILED (failures=1)

After the change:

Ran 2 tests in 0.181s

OK

By hand, same command:

python -I tools/xcl_compare.py --xcl <empty folder> --out <existing folder>
xcl_compare.py: error: --out is a folder, not a report file: Z:\\...\\xclout      (exit 2)

No GPU needed: no title runs, no XCL checkout, no game files; the test's --xcl is an empty temp folder.

Notes

  • The guard is placed before the sys.platform check so it answers the same on every platform; the test for a legitimate --out in a missing folder (which run_all still creates) is skipped off Windows because the tool itself is Windows-only.
  • I did not move the out.parent.mkdir(): the report path is resolved inside run_all, where the default lives, and the folder case is now refused before that point.
  • --out naming one of the two transcripts (<work>/xcl_output.txt, <work>/leonida_output.txt) is still not refused; smaller change, and the transcripts are written inside --work unless --out is pointed at one.

Item: EGEN-XCL-OUT-FOLDER

AI-assisted.

The report write is the last thing the tool does, after both title runs, so a --out naming an existing folder ended a multi-minute run in an IsADirectoryError traceback. Every other report tool refuses that in main(); do the same here, before either run starts.
@milas6669

Copy link
Copy Markdown

Tested 2e868482 on Windows 11 (10.0.26200), CPython 3.13, no GPU, no game data: pass.

python -I tests/test_xcl_compare_out.py
Ran 2 tests in 0.174s — OK

Both cases pass here, including the skipUnless(sys.platform == "win32") one that a Linux CI job skips.

Negative control. With main's tools/xcl_compare.py (the guard removed) and this branch's test file, the folder case fails as intended:

FAIL: test_out_naming_a_folder_is_refused_at_start
AssertionError: 1 != 2 : no built XCL in ...\xcl: run 'cargo build --release --workspace' there first

so the test does fail before the change and passes after it, and the guard fires before either title runs. The error line carries the plain path, not a repr'd one, so this is clean on the point that broke four other tools on Windows (#5760).

AI-assisted.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head: 2e86848.

  • python -I -m pytest tests/test_xcl_compare_out.py -q -> 2 passed.
  • Manual CLI: --out <existing folder> -> exit 2, argparse error before either run; --out <missing>/report.json and an existing file -> exit 1 at no built XCL (guard not triggered), so only a real folder is refused.
  • 49 insertions across 2 files; the report write still overwrites an existing file, as before.

Verdict: approve.

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