Reject unmatched --import/--dll selectors in import_fail_fast (FAIL-FAST-SELECTORS) #941

Open
github-bot wants to merge 2 commits from github-bot/gh-941 into main AGit
Owner

@⁠TheGeogeo on GitHub · 2026-11-24 15:23 UTC · original
TheGeogeo:fix/fail-fast-selectors → main · +63 −5 · 2 files · 2 commits · open

Claimed in the coordination issue as: FAIL-FAST-SELECTORS (#14)

Depends on: #848 (merged). Its test test_cli_dll_all_json_matches_documented_invocation expected exit 0 for --dll other.dll --all --json on an image that does not import that DLL. This change refuses that selector with exit 2, so the second commit (0718a8a9, 9eea92ca before the rebase) updates that one expectation; the test's valid-selector checks are unchanged.

What and why

tools/import_fail_fast.py passed the raw --import / --dll values to fail_fast(). A selector that names nothing in the image printed 0 of 0 import(s) called directly and exited 0, and a typo beside a good selector was dropped without a word. Both read as "no call site stops the title".

tools/import_call_sites.py already handles this, and import_fail_fast.py already imports from it. This change reuses import_selector, dll_selector and unmatched_selectors the same way: a malformed selector is an argparse error (exit 2), and a well-formed selector that matches nothing prints no import matches --import ... / --dll ... to stderr and returns 2 before any output. fail_fast() itself is unchanged (it still returns {} for an absent DLL).

Tested

Head 0718a8a9, rebased on main e18b59a5, same patch as 9eea92ca (git range-diff); it merges cleanly with main 747809e7. Windows 11, Python 3.12.4:

  • python -I -B tests/test_import_fail_fast.py: 14 OK; tests/test_import_call_sites.py: 21 OK. With these tests on the tool of main e48ff037, 4 of the 14 fail.
  • tests/test_docs_cli_flags.py, tests/test_text_write_line_endings.py, tests/test_ctest_registration.py, tests/test_ci_registration.py and tests/test_docs_links.py: OK.
  • tests/test_tool_stdout_encoding.py fails in test_every_main_block_reconfigures_stdout, as on main e18b59a5 alone (three tools this change does not touch).
  • compileall, git diff --check and python -I scripts/check_no_game_data.py on the two files: clean.

Earlier head, on main 66d4f5aa, which contains #848 (9eea92ca; the tool change is the same patch as 2054bc49), on Windows 11, Python 3.12.4: tests/test_import_fail_fast.py 14 OK (1 failure of 14 without the updated expectation), tests/test_import_call_sites.py 21 OK, tests/test_docs_links.py 16 OK; test_docs_cli_flags.py, test_tool_stdout_encoding.py and test_text_write_line_endings.py OK; git diff --check and the no-game-data check clean.

First run, before #848:

Run from the repository root on Windows:

  • python -I -B tests/test_import_fail_fast.py: 12 tests, OK (8 existing, 4 new: malformed selectors, absent selectors, a typo beside a good selector, valid selectors still exit 0).
  • The 3 new tests that check refusals fail against origin/main's tools/import_fail_fast.py (checked in a scratch copy with the new tests, confirmed the old tool file was the one loaded); the fourth (valid selectors) passes on both.
  • python -I -B tests/test_import_call_sites.py: 21 tests, OK.
  • python -m compileall -q tools/import_fail_fast.py tests/test_import_fail_fast.py: no output.
  • git diff --check: clean.
  • python -I scripts/check_no_game_data.py tools/import_fail_fast.py tests/test_import_fail_fast.py: exit 0.
  • Not run: the translator suite, runtime and GPU tests (unrelated).

GPUs tested: n/a

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator rule.)
**@⁠TheGeogeo** on GitHub · 2026-11-24 15:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/941) `TheGeogeo:fix/fail-fast-selectors` → `main` · +63 −5 · 2 files · 2 commits · open Claimed in the coordination issue as: FAIL-FAST-SELECTORS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) Depends on: #848 (merged). Its test `test_cli_dll_all_json_matches_documented_invocation` expected exit 0 for `--dll other.dll --all --json` on an image that does not import that DLL. This change refuses that selector with exit 2, so the second commit (`0718a8a9`, `9eea92ca` before the rebase) updates that one expectation; the test's valid-selector checks are unchanged. ### What and why `tools/import_fail_fast.py` passed the raw `--import` / `--dll` values to `fail_fast()`. A selector that names nothing in the image printed `0 of 0 import(s) called directly` and exited 0, and a typo beside a good selector was dropped without a word. Both read as "no call site stops the title". `tools/import_call_sites.py` already handles this, and `import_fail_fast.py` already imports from it. This change reuses `import_selector`, `dll_selector` and `unmatched_selectors` the same way: a malformed selector is an argparse error (exit 2), and a well-formed selector that matches nothing prints `no import matches --import ...` / `--dll ...` to stderr and returns 2 before any output. `fail_fast()` itself is unchanged (it still returns `{}` for an absent DLL). ### Tested Head `0718a8a9`, rebased on `main` `e18b59a5`, same patch as `9eea92ca` (`git range-diff`); it merges cleanly with `main` `747809e7`. Windows 11, Python 3.12.4: - `python -I -B tests/test_import_fail_fast.py`: 14 OK; `tests/test_import_call_sites.py`: 21 OK. With these tests on the tool of `main` `e48ff037`, 4 of the 14 fail. - `tests/test_docs_cli_flags.py`, `tests/test_text_write_line_endings.py`, `tests/test_ctest_registration.py`, `tests/test_ci_registration.py` and `tests/test_docs_links.py`: OK. - `tests/test_tool_stdout_encoding.py` fails in `test_every_main_block_reconfigures_stdout`, as on `main` `e18b59a5` alone (three tools this change does not touch). - `compileall`, `git diff --check` and `python -I scripts/check_no_game_data.py` on the two files: clean. Earlier head, on `main` `66d4f5aa`, which contains #848 (`9eea92ca`; the tool change is the same patch as `2054bc49`), on Windows 11, Python 3.12.4: `tests/test_import_fail_fast.py` 14 OK (1 failure of 14 without the updated expectation), `tests/test_import_call_sites.py` 21 OK, `tests/test_docs_links.py` 16 OK; `test_docs_cli_flags.py`, `test_tool_stdout_encoding.py` and `test_text_write_line_endings.py` OK; `git diff --check` and the no-game-data check clean. First run, before #848: Run from the repository root on Windows: - `python -I -B tests/test_import_fail_fast.py`: 12 tests, OK (8 existing, 4 new: malformed selectors, absent selectors, a typo beside a good selector, valid selectors still exit 0). - The 3 new tests that check refusals fail against `origin/main`'s `tools/import_fail_fast.py` (checked in a scratch copy with the new tests, confirmed the old tool file was the one loaded); the fourth (valid selectors) passes on both. - `python -I -B tests/test_import_call_sites.py`: 21 tests, OK. - `python -m compileall -q tools/import_fail_fast.py tests/test_import_fail_fast.py`: no output. - `git diff --check`: clean. - `python -I scripts/check_no_game_data.py tools/import_fail_fast.py tests/test_import_fail_fast.py`: exit 0. - Not run: the translator suite, runtime and GPU tests (unrelated). GPUs tested: n/a AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not applicable: no translator rule.)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:29:31 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 15:26 UTC · original · requested changes

Reviewed exact head 2054bc4920de49959f10dae7e197903daf58d886. I reproduced the disclosed integration failure: merging #848 (f0c8d747) into this PR is textually clean, but python3 -I tests/test_import_fail_fast.py -v then runs 14 tests and fails test_cli_dll_all_json_matches_documented_invocation: --dll other.dll --all --json returns exit 2 with no import matches --dll other.dll, while #848 asserts exit 0 and an empty imports object. This means the two open PRs cannot both merge unchanged. Please coordinate the intended empty-selector behavior with #848 and update the relevant test/docs or selector policy so the combined head passes. The isolated PR #941 tests may pass, but the combined change currently fails. No game data or GPU used.

**@⁠KernelSmoker** on GitHub · 2026-11-24 15:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/941#pullrequestreview-6042170449) · **requested changes** Reviewed exact head `2054bc4920de49959f10dae7e197903daf58d886`. I reproduced the disclosed integration failure: merging #848 (`f0c8d747`) into this PR is textually clean, but `python3 -I tests/test_import_fail_fast.py -v` then runs 14 tests and fails `test_cli_dll_all_json_matches_documented_invocation`: `--dll other.dll --all --json` returns exit 2 with `no import matches --dll other.dll`, while #848 asserts exit 0 and an empty imports object. This means the two open PRs cannot both merge unchanged. Please coordinate the intended empty-selector behavior with #848 and update the relevant test/docs or selector policy so the combined head passes. The isolated PR #941 tests may pass, but the combined change currently fails. No game data or GPU used.
Author
Owner

@⁠TheGeogeo on GitHub · 2026-11-24 20:52 UTC · original

#848 is on main now, so this branch is rebased on 66d4f5aa and the conflict from the review is resolved in 9eea92ca.

  • The selector policy stays: a selector that matches nothing is refused with exit 2, as in import_call_sites.py.
  • test_cli_dll_all_json_matches_documented_invocation now expects that refusal for --dll other.dll --all --json. Its valid-selector checks are unchanged, and docs/exe_fail_fast.md only documents a selector that matches.
  • On Windows 11, Python 3.12.4: tests/test_import_fail_fast.py has 1 failure of 14 without this commit and 14 OK with it. tests/test_import_call_sites.py 21 OK, tests/test_docs_links.py 16 OK, test_docs_cli_flags.py OK, data guard and git diff --check clean.

AI-assisted: yes (Claude Code).

**@⁠TheGeogeo** on GitHub · 2026-11-24 20:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/941#issuecomment-7144175655) #848 is on `main` now, so this branch is rebased on `66d4f5aa` and the conflict from the [review](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/941) is resolved in `9eea92ca`. - The selector policy stays: a selector that matches nothing is refused with exit 2, as in `import_call_sites.py`. - `test_cli_dll_all_json_matches_documented_invocation` now expects that refusal for `--dll other.dll --all --json`. Its valid-selector checks are unchanged, and `docs/exe_fail_fast.md` only documents a selector that matches. - On Windows 11, Python 3.12.4: `tests/test_import_fail_fast.py` has 1 failure of 14 without this commit and 14 OK with it. `tests/test_import_call_sites.py` 21 OK, `tests/test_docs_links.py` 16 OK, `test_docs_cli_flags.py` OK, data guard and `git diff --check` clean. AI-assisted: yes (Claude Code).
Author
Owner

@⁠TheGeogeo on GitHub · 2026-11-25 19:50 UTC · original

Rebased from 9eea92ca to 0718a8a9 on main e18b59a5, same patch (git range-diff): the two commits are unchanged. The old base was why test_ctest_registration.py failed in this pull request's CI (vk_host_region_import_test.cpp:341); it passes on the new base.

Windows 11, Python 3.12.4: test_import_fail_fast.py 14, test_import_call_sites.py 21, test_ctest_registration.py 5, test_ci_registration.py 16 and test_docs_links.py 16 pass, test_docs_cli_flags.py and test_text_write_line_endings.py too. test_tool_stdout_encoding.py fails on main alone as well (three tools this change does not touch), so the stdlib jobs may stay red for that. The changes requested in the 2026-11-24 review on 2054bc49 were already addressed in 9eea92ca (now 0718a8a9).

AI-assisted: yes (Claude Code)

**@⁠TheGeogeo** on GitHub · 2026-11-25 19:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/941#issuecomment-7172829363) Rebased from `9eea92ca` to `0718a8a9` on `main` `e18b59a5`, same patch (`git range-diff`): the two commits are unchanged. The old base was why `test_ctest_registration.py` failed in this pull request's CI (`vk_host_region_import_test.cpp:341`); it passes on the new base. Windows 11, Python 3.12.4: `test_import_fail_fast.py` 14, `test_import_call_sites.py` 21, `test_ctest_registration.py` 5, `test_ci_registration.py` 16 and `test_docs_links.py` 16 pass, `test_docs_cli_flags.py` and `test_text_write_line_endings.py` too. `test_tool_stdout_encoding.py` fails on `main` alone as well (three tools this change does not touch), so the stdlib jobs may stay red for that. The changes requested in the 2026-11-24 review on `2054bc49` were already addressed in `9eea92ca` (now `0718a8a9`). AI-assisted: yes (Claude Code)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/941/head:github-bot/gh-941'
git switch 'github-bot/gh-941'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-941'
git switch 'github-bot/gh-941'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-941'
git switch 'github-bot/gh-941'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-941'
git switch 'main'
git merge --squash 'github-bot/gh-941'
git switch 'main'
git merge --ff-only 'github-bot/gh-941'
git switch 'main'
git merge 'github-bot/gh-941'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.