Skip to content

tests: the two write-failure cases in test_feature_scan need preexec_fn, which Windows does not have - #2667

Merged
aslan2142 merged 3 commits into
ProjectLeonida:mainfrom
fiestorra:fix/feature-scan-posix-only
Dec 1, 2026
Merged

aslan2142 merged 3 commits into
ProjectLeonida:mainfrom
fiestorra:fix/feature-scan-posix-only

Conversation

@fiestorra

@fiestorra fiestorra commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Two tests in tests/test_feature_scan.py fail on Windows and CI cannot see it, because that file runs on Linux there.

Found while verifying #2665 - which is not the cause (the same two fail on main without it, and its only change to the file is a docstring line).

The cause

FeatureScanAtomicOutputTests.run_scan passes

preexec_fn=self.fail_file_writes if fail_writes else None,

and preexec_fn is POSIX-only. The two cases that use it (test_failed_write_keeps_existing_report, test_failed_write_leaves_no_temporary_file) therefore cannot run here at all - they die in subprocess.Popen before the tool is started.

The change

Two decorators, one per case:

@unittest.skipIf(os.name == "nt", "preexec_fn, which these two cases need, is POSIX-only")
before (main b8bd37111, Windows 11, Python 3.13):  2 failed, 14 passed
after:                                            14 passed, 2 skipped

The skip prints its reason, so the suite no longer reports a red that a Windows contributor cannot distinguish from their own breakage. On POSIX nothing changes: the decorator is a no-op there, and the cases run exactly as before.

What this does not do

It does not test the same behaviour on Windows. The intent of those cases - a failed write must leave the previous report intact and no temporary file behind - is real and worth covering; preexec_fn is simply the POSIX way to inject the failure. A portable variant would make the destination unwritable instead (a directory where the file should go is enough), which would exercise the same intent on every platform. I did not write it because it tests a different failure point - after the tool opens its temp file rather than before - and that is a judgement for whoever owns this tool.

A third commit the description above did not mention (463f7593d)

runtime.yml's selectors send each tests/test_*.py through python -I <file> unless it imports pytest or defines HAVE_NUMPY =, and this file does neither. Its __main__ scans globals() for names starting with test_, so FeatureScanAtomicOutputTests never ran in CI at all - which meant the two skips above had no effect there either.

The script path now loads the class explicitly:

python -I tests/test_feature_scan.py  ->  13 top-level tests, then "Ran 3 tests ... OK (skipped=2)", exit 0
python3 -m pytest tests/test_feature_scan.py -q  ->  14 passed, 2 skipped

merzleckeier spotted the gap by reading the call site rather than the diff; the fix is mine, and it is the reason this change now protects something in the job that matters.

The extra commit at the tip (no longer carried)

The branch used to carry a3b5ebea1 (test(semantic): align computed-I/J f16 interp oracle…), added only because semantic-tests was red on main for that oracle and every branch cut from main inherited it. main now has the same edit as c717967d0, so a rebase drops the commit and this pull request no longer touches tests/semantic/test_interp_computed_ij_fallback.py - the diff is only what this change actually needs.

AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change before submission. Where and on what: the measurements above were taken on Windows 11 with MSVC 19.44.35226 on an RTX 4090 (NVIDIA driver 621.24) where a C++ or GPU path is involved; Python and docs cases need none of it.

Written with an AI assistant.

@merzleckeier

Copy link
Copy Markdown
Contributor

Independent Python 3.12 A/B with #2665. I merged #2665 3209231b3 and this PR c6f4b809c into main 0eab02a8b, then restored only tests/test_feature_scan.py from the #2665-only merge for the control. Windows job · Linux job.

  • MEASURED pytest collected 16 tests in both arms. Windows 3.12.10 went from 14 passed and two ValueError failures at Popen(preexec_fn=…) to 14 passed and two explicit skips. Linux 3.12.16 passed all 16 in both arms, including the atomic-write failure checks.
  • READ IN CODE The current CI selectors send this file through python -I <file>, including the Windows standard-library step. Its __main__ invokes only the top-level test_* functions, so the entire FeatureScanAtomicOutputTests class is absent from that invocation. The standalone control printed OK on both operating systems. I also tried loading that class with unittest.defaultTestLoader from __main__ on Linux, and all three class methods ran alongside the existing standalone checks.

Synthetic fixtures only. AI-assisted with OpenAI Codex.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto current main with the one commit main is missing, like my other pull requests:

a3b5ebea1  (TEST-INTERP-COMPUTED-IJ-FALLBACK-RTZ, the commit #2633 carries)

semantic-tests was the only failing check here and it fails on main, for the interp oracle - so a branch cut from main inherits it and cannot show a result of its own. Nothing about this change touches the translator.

Verified after the rebase, on this branch:

python3 -m pytest tests/test_feature_scan.py tests/semantic/test_interp_computed_ij_fallback.py -q
  -> 23 passed, 2 skipped, 13 subtests

If #2633 merges first this second commit becomes a duplicate and can be dropped; if this lands first, #2633 becomes a no-op.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Your "READ IN CODE" point turned out to be the most useful line in the review, and it needed a third commit: 463f7593d.

You noted that the CI selectors send this file through python -I <file>, and that its __main__ only invokes the top-level test_* functions, so FeatureScanAtomicOutputTests is absent from that invocation. That means the two skips this PR adds never took effect in CI - they only mattered for a pytest run, which is what a contributor does locally and what CI does not.

So the script run now loads the class explicitly:

class_result = unittest.TextTestRunner(verbosity=0).run(
    unittest.defaultTestLoader.loadTestsFromTestCase(FeatureScanAtomicOutputTests))
class_failed = len(class_result.failures) + len(class_result.errors)
ok = not failures and not raised and not class_failed

Measured here, in both invocation paths:

python -I tests/test_feature_scan.py     -> 13 top-level tests, then "Ran 3 tests ... OK (skipped=2)", exit 0
python3 -m pytest tests/test_feature_scan.py -q   -> 14 passed, 2 skipped

So the class runs in the script path now, with its two Windows skips doing what the PR says, and the three Linux cases passing as your defaultTestLoader experiment predicted.

What this says about the PR as a whole: it was fixing a failure that CI could not see and doing so in an invocation CI does not use. Thank you for reading the call site rather than just the diff - the change is now worth something where it matters.

Written with an AI assistant.

…s not have

They fail on Windows today, and CI cannot see it because that file runs on Linux
there: FeatureScanAtomicOutputTests' two "failed write" cases pass
preexec_fn=fail_file_writes to subprocess, which is POSIX-only.

Measured on main b8bd371, Windows 11, Python 3.13: 2 failed, 14 passed before;
14 passed, 2 skipped after, with the reason printed. On POSIX nothing changes.

Written with an AI assistant.
The `__main__` scan collects the `test_*` globals, so the class's three methods
never ran in the plain-script invocation CI uses - which means the two skips this
PR adds never took effect there either. The class is loaded explicitly now.

Measured here: the script run goes from 13 top-level tests to those plus
"Ran 3 tests ... OK (skipped=2)", and pytest still reports 14 passed, 2 skipped.

Written with an AI assistant.
@fiestorra
fiestorra force-pushed the fix/feature-scan-posix-only branch from 463f759 to 0d94741 Compare November 30, 2026 13:55
@fiestorra

Copy link
Copy Markdown
Contributor Author

Re-verified after the rebase onto main 20fe0c754, on this machine (Windows 11, MSVC 19.44.35226): the diff no longer carries the interp-oracle commit (main has it as c717967d0), and what is left still passes.

python3 -m pytest tests/test_feature_scan.py -q
14 passed, 2 skipped in 2.63s

What I did not test: the rest of the change, and anything the rebase did not touch. This confirms the rebase kept the change working, not that the change is correct - that is what the review and the CI are for.

Written with an AI assistant.

@aegish-zagi

Copy link
Copy Markdown
Contributor

VERIFY-2667 — PASS

  • PR: tests: the two write-failure cases in test_feature_scan need preexec_fn, which Windows does not have #2667 | head 0d94741 | merge state vs main b17b22d: CLEAN (scratch merge, no conflicts)
  • Tests run (PR head merged with current main): python -I tests/test_feature_scan.py — OK (0 failed checks, 0 failed tests), exit 0; python -m unittest discover -s tests -p test_feature_scan.py — the FeatureScanAtomicOutputTests class (3 tests, including the two write-failure cases) passes.
  • Red-on-main vs green-on-PR: the red here is a silent skip, not an exit code. On plain main the same script run also prints OK, but main's main block never loads FeatureScanAtomicOutputTests (grep: no class run in the script entry point), so the class's 3 cases — including test_failed_write_keeps_existing_report and test_failed_write_leaves_no_temporary_file — do not execute at all in the CI script run. The PR adds that class run to the script entry point and counts its failures into the exit code; measured above, the class now executes and passes. The two skipIf(os.name == 'nt') decorators are inert on this Linux host (both cases ran) and correct by inspection: preexec_fn is POSIX-only.
  • Diff audit: 1 file, tests only, +9/-1 lines of substance (plus the entry-point block). No production code, no game data.
  • Platform: Linux, Python 3.12, Profile Z (no GPU)
  • AI-assisted: yes (Muse Wonder, Muse by Meta)

@KelboLive

Copy link
Copy Markdown

Independent check on Windows (not the author), at e5c849280.

  • python -I tests/test_feature_scan.py: 3 tests, OK, 2 skipped. The skips are the intended ones: both cases declare preexec_fn ... is POSIX-only.
  • The remaining test runs its write-failure checks: broken report, bare-assert propagation, per-check counts — all PASS (0 failed checks, 0 failed tests).

So the PR does exactly what it says on Windows: gates the two POSIX-only cases instead of failing them. Coverage of the two write-failure paths is not exercised on this OS (they need fork/preexec), which is worth knowing but is the documented reason.

Environment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10.

AI-assisted: yes (opencode).

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Skipping the two POSIX-only preexec_fn write-failure tests on Windows and running FeatureScanAtomicOutputTests in tests/test_feature_scan.py's __main__ block fixes both Windows compatibility and silent skipping under python -I. Clean-room verified, 5/5 CI green, and independently verified. Merging.

(AI-assisted review.)

@aslan2142
aslan2142 merged commit 8e8e5b3 into ProjectLeonida:main Dec 1, 2026
5 checks passed
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.

5 participants