test: make three fixtures portable so they test the code, not the host platform - #68
Open
Hotragn wants to merge 1 commit into
Open
test: make three fixtures portable so they test the code, not the host platform#68Hotragn wants to merge 1 commit into
Hotragn wants to merge 1 commit into
Conversation
…t platform
Five tests fail on Windows because of how their fixtures build input, not because
of the code under test. In each case the source is already correct.
1. `test_tagging.py` (3 failures). Five page fixtures write content through
`write_text`, which translates "\n" to os.linesep, then assert byte-exact
round-tripping via `read_bytes()`. On Windows the intended "\r\n" lands as
"\r\r\n", which is not a valid frontmatter fence, so the page appears to have
no frontmatter, a second block is prepended and the original is absorbed into
the body. Passing `newline=""` writes what the test actually wrote.
`rewrite_page_topics` is not at fault: it reads bytes, detects the ending and
preserves it.
2. `test_transcript_discovery.py` (1 failure). The Claude fixture hand-builds
JSONL with an f-string, so a Windows path embeds invalid escapes
("cwd":"C:\Users\...") and the line fails to parse, yielding 0 candidates.
Its Codex sibling in the same file already uses `json.dumps` and passes on
Windows for exactly that reason, so this just adopts the established pattern.
`json` was already imported.
3. `test_build_workflow.py` (1 failure). The expected value mixes separators by
interpolating a native path and appending "/almanac/manual", and does not
account for the prompt being JSON-encoded. Building it with `json.dumps` and
pathlib joins compares like with like.
Windows goes from 13 failed / 550 passed to 8 failed / 555 passed. The remaining
8 are the 5 macOS-only `launchd` tests plus 3 covered by AlmanacCode#64 and AlmanacCode#65; with those
merged, the only Windows failures left are the `launchd` ones, which is the point
at which a Windows CI job could be added and mean something. No behaviour change
on macOS or Linux: every edit changes only how a fixture serializes its input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five Windows test failures are caused by how the fixtures build their input, not by the code under test. The source is already correct in all three cases. This makes the fixtures portable so they test the code rather than the host platform.
Windows goes from 13 failed / 550 passed to 8 failed / 555 passed. No behaviour change on macOS or Linux — every edit changes only how a fixture serializes its own input.
Why
1.
test_tagging.py— 3 failures. Five page fixtures write content withwrite_text, which translates\ntoos.linesep, then assert byte-exact round-tripping withread_bytes(). On Windows the intended\r\nlands on disk as\r\r\n, which is not a valid frontmatter fence — so the page looks like it has no frontmatter, a second block gets prepended, and the original is absorbed into the body:Worth stating plainly:
rewrite_page_topicsis not at fault. It reads bytes, detects the line ending, and preserves it — I checked before assuming a source bug.newline=""simply writes what the test meant to write.2.
test_transcript_discovery.py— 1 failure. The Claude fixture hand-builds JSONL with an f-string:f'{{"sessionId":"claude-1","cwd":"{repo}"}}\n'On Windows
repointerpolates asC:\Users\..., so the JSON contains invalid escapes (\U,\A), the line fails to parse, anddiscover()returns 0 candidates.Its Codex sibling in the same file already uses
json.dumpsand passes on Windows for exactly that reason. This just adopts the pattern already established two functions up;jsonwas already imported.3.
test_build_workflow.py— 1 failure. The expected value mixes separators and ignores that the prompt is JSON-encoded:On Windows
reporenders with backslashes, then/almanac/manualis appended with a forward slash, while the prompt contains the JSON-escaped native path. Building the expected value withjson.dumpsand a pathlib join compares like with like.Verification
Also confirmed green on Linux semantics by inspection:
newline=""is a no-op whereos.linesepis already\n, andjson.dumpsof a POSIX path is byte-identical to the previous f-string output.Docs and wiki
Notes for reviewers
launchdtests. That is the point at which addingwindows-latesttoci.ymlproduces a signal instead of noise — which is the substance of the proposal in Proposal: one platform seam plus a CI matrix, so cross-platform PRs become reviewable #67. This PR is useful on its own and does not depend on that discussion going anywhere.test_tagging.py, not the 3 that fail. Lines 47 and 86 pair the same translating write with aread_bytesassertion and pass today only because their assertions happen not to be suffix-exact. Leaving them would be leaving the same bug armed.src/change, deliberately. I checked each source path before touching the test, specifically so this would not turn into a false bug report against working code.frontmatter_rewrite.pyis the model for byte-exact read-modify-write in this codebase.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.