test(build-context): write fixture content with the newlines the assertions pin - #505
test(build-context): write fixture content with the newlines the assertions pin#505kevin9327 wants to merge 1 commit into
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.
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(-).