Repository navigation
test(build-context): write fixture content with the newlines the assertions pin - #505
Conversation
…rtions pin Several cases assert cached content byte for byte, down to a trailing "\n", but build their fixtures with Path.write_text and no newline argument. Text mode translates "\n" to os.linesep, so on Windows the fixture is written with CRLF while the assertion pins LF, and the cases fail on content the test itself wrote. _write_real_oms_signature had the same problem in both directions: it read the pinned signature as text and wrote it back as text, so the copy was newline-translated twice. Copy its bytes instead, which is what a signature fixture needs anyway. Pass newline="\n" on the writes whose content is asserted exactly. Signed-off-by: kevin9327 <[email protected]>
|
Verified on Windows 11. This one fixes four failures outright, and the three test PRs together take the file from 12 failures to 2.
The four this PR turns green, and they pass rather than skip: For context on the other two, since they are hard to see from a Linux runner: #501 accounts for five symlink cases that fail here with The two still failing on the stack are Environment: Windows 11, uv-managed CPython 3.14.0, |
…VIDIA#524 Raise reviewed_pr_through to 527 and reviewed_issue_through to 524 in tools/upstream_baseline.json (commit axis unchanged at 69dcdfb). Every item gets a verdict in docs/DECISIONS.md: NVIDIA#493/NVIDIA#507/NVIDIA#508/NVIDIA#511 verified via git merge-base --is-ancestor as already included through the 2.11.1/2.11.2 sync (including NVIDIA#521, which merged only into the still- open NVIDIA#516 stack, not main); the remaining 27 items stay "wait for upstream merge", none adopted now. Two items get dedicated comparison notes per docs/DIVERGENCE.md's static_runner.py and scripts/compare_scan_accuracy.py rows: NVIDIA#522 uses a different env var name and different default/semantics than this fork's SKILLSPECTOR_MAX_STATIC_SECONDS, so merging it cannot simply delete the divergence row and needs a downstream env var migration first; NVIDIA#490 extends this fork's own upstream PR NVIDIA#486 with a Python 3.14/POSIX edge case the fork's Windows environment does not hit, so NVIDIA#486 is left untouched pending upstream's own resolution. NVIDIA#501-NVIDIA#505 and NVIDIA#518 are also flagged as near-verbatim matches to this fork's existing Windows test divergence rows, worth revisiting for row deletion once merged. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: SanHsien <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Reviewed head 6b04e9136792554bd02f4eaf95388f22dc9eebc6 — APPROVE.
The fixtures now write the exact bytes their assertions pin, and the OMS signature is copied byte-for-byte rather than normalized through text I/O. The changes are scoped to byte-exact test setup and are compatible with the supported Python versions. I found no required changes.
Required checks pass, but GitHub currently reports mergeStateStatus=BEHIND; update against current main and re-run required checks before merging.
Brings the fork up to upstream main c13f70e; the version is still 2.11.2. The fork history was squashed into one commit on 2026-09-13, so it shares no merge-base with upstream and git merge refuses. The range diff was applied with git apply -3 instead. The fork content equals 69dcdfb plus the registered divergences, so conflicts landed only on those seven files; the other 116 applied cleanly. FORK.md now documents this procedure. Divergences, resolved by each row's rule: - static_runner.py takes upstream NVIDIA#522 (SKILLSPECTOR_MAX_STATIC_ANALYSIS_SECONDS_PER_ARTIFACT, default 300s). The fork's SKILLSPECTOR_MAX_STATIC_SECONDS override and its seven tests are removed. Downstream gates must use the upstream name when their pin moves. - test_static_yara.py, test_build_context.py and test_input_handler.py take upstream (NVIDIA#501-NVIDIA#505, NVIDIA#518 fix the same Windows issues); 301 passed on Windows, rows deleted. - test_security_end_to_end.py: upstream's version still fails nine_case on Windows (YARA load and SC8 budgets stay hard-coded), so the relaxation helper is re-applied on top; row kept and rewritten. - .gitignore keeps the fork block; README.md stays Traditional Chinese and the upstream README goes to README.en.md. Two new Windows divergences from new upstream tests: - tests/unit/test_cli.py: a file name containing a backslash is split into two path parts on Windows; skipped by a capability probe added to tests/platform_support.py. - test_json_container_ownership.py: oversized payloads became test ids, which pytest copies into PYTEST_CURRENT_TEST, over Windows' 32,767 character environment limit; short ids added, content unchanged. Triage: 13 of PRs NVIDIA#528-NVIDIA#580 merged into upstream main and arrive here; 29 stay open (including NVIDIA#550, release 2.12.0). Upstream closed this fork's PR NVIDIA#486 on 2026-09-15; NVIDIA#490 builds on it and is open. Verified on Windows in fresh-process batches against this tree: tests/unit 1563 passed, 29 skipped; tests/nodes 3822 passed, 11 skipped, 4 xfailed (plus test_json_container_ownership 71 passed after the id fix); remaining tests 182 passed, 16 skipped; test_security_end_to_end.py 98 passed. ruff check and format clean, check_divergence OK (10 diverging, 10 registered), check_pin_bounds OK. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: SanHsien <[email protected]>
Problem
Five cases in
tests/nodes/test_build_context.pyassert cached content exactly, including thetrailing newline:
but the fixtures are written with
Path.write_textand nonewlineargument:Text mode translates
"\n"toos.linesep, so on Windows the fixture lands on disk as CRLF.build_contextreads it back faithfully and returns CRLF, and the case fails against contentthe test itself wrote. The
raw_file_cacheassertion above makes the intent explicit — it pinsthe bytes — so the fixture, not the product, is what is wrong here.
_write_real_oms_signaturehas the same problem in both directions:read_textapplies universal newlines andwrite_textapplies the reverse translation, so thepinned signature is newline-translated twice on the way to the temporary directory. Its case
then compares the cache against
nested.read_text(...), which normalises again, and the twonever line up.
Fix
_write_real_oms_signaturecopies bytes. That is what a pinned signature fixture needsregardless of platform, and it removes both translations.
newline="\n", so the fixture matches whatthe assertion pins. (
Path.write_texthas acceptednewlinesince 3.10; this projectrequires
>=3.12.)Writes whose content is not asserted verbatim are left alone, so the diff stays at the defect.
On a platform where
os.linesepis already"\n"nothing changes, so CI behaviour isidentical.
Reproduction
Windows 11, Python 3.12.10, against unmodified
main(704bc95):With this change, same command:
What must still hold
tests/nodes/test_build_context.pyin full — five cases move from failing to passing andnothing else changes state:
The seven that remain are unrelated to newline handling and are not touched here.
ruff check tests/—All checks passed!ruff format --check tests/—126 files already formattedDiff is
1 file changed, 9 insertions(+), 6 deletions(-).