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

Open
opened 2026-11-26 20:19:41 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/941
Author: @TheGeogeo
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/fail-fast-selectors


📝 Commits (2)

  • a8e334e Reject unmatched --import/--dll selectors in import_fail_fast
  • 0718a8a tests: expect an unmatched --dll to be refused in the documented JSON case (FAIL-FAST-SELECTORS)

📊 Changes

2 files changed (+63 additions, -5 deletions)

View changed files

📝 tests/test_import_fail_fast.py (+54 -2)
📝 tools/import_fail_fast.py (+9 -3)

📄 Description

Claimed in the coordination issue as: FAIL-FAST-SELECTORS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135906432)

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.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/941 **Author:** [@TheGeogeo](https://github.com/TheGeogeo) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/fail-fast-selectors` --- ### 📝 Commits (2) - [`a8e334e`](https://github.com/ubiquitarianism/leonida/commit/a8e334e3776ba4244bb873c5eeb3c39db1b11853) Reject unmatched --import/--dll selectors in import_fail_fast - [`0718a8a`](https://github.com/ubiquitarianism/leonida/commit/0718a8a9acccfd19d8ade2b539c973ede0394e35) tests: expect an unmatched --dll to be refused in the documented JSON case (FAIL-FAST-SELECTORS) ### 📊 Changes **2 files changed** (+63 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_import_fail_fast.py` (+54 -2) 📝 `tools/import_fail_fast.py` (+9 -3) </details> ### 📄 Description Claimed in the coordination issue as: FAIL-FAST-SELECTORS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135906432) 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.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#978
No description provided.