Make the public data-use copy test pass in the public mirror - #1458
aniruddhaadak80 wants to merge 2 commits into
Conversation
34aca6b to
776e78c
Compare
|
Good instinct and solid execution for a narrow problem: Two things worth reconsidering before this gets ported:
The PR is well-scoped (one file, test-only) and the before/after numbers are concrete and checkable. Worth a maintainer's look, possibly with the |
Follow-up to review: the CRLF is not committed. Every one of these files is stored as LF in the repository; the CRLF only appears in the working tree, where core.autocrlf=true rewrites LF as CRLF on checkout. That is why the failure diff shows zero changed lines while the assertion still fails, and why fixing it in the reader treats a checkout artifact as a permanent fact about the file. Pinning these to eol=lf makes the working tree agree with the repository on every platform, which is the durable fix. Scoped to just the five asserted paths on purpose: a repo-wide `* text=auto eol=lf` would renormalise everything and bury this in unrelated diff noise. The reader normalisation stays as a guard so the assertion still means "the copy matches" even on a checkout that ignores this file.
|
Both points addressed, and the first one turned out to have a different cause than assumed. 1. Worth correcting one detail, because it changes what the fix has to be: README.md is not committed as CRLF. Every one of these files is stored as LF in the repository. The CRLF only ever appears in the working tree, where So I kept the reader normalisation as well, so the assertion keeps meaning "the copy matches" even on a checkout that ignores the attribute. 2. The skip condition is per row, not per suite: If Bun's |
common/src/__tests__/freebuff-public-data-use-copy.test.tscannot pass in thisrepository. On current
main(2d10aaa8d) it reports 1 pass, 5 fail. This PRmakes it 4 pass, 3 skip, 0 fail, test-only, in one file.
Why it fails
Two independent causes, both specific to this repository being a public export of
a private source tree.
1. Line endings decide the comparison (2 failures).
README.mdandfreebuff/cli/release/README.mdfailed with a diff of- Expected - 0/+ Received + 0— zero changed lines, i.e. an invisible difference. The cause isone stray
\rper line:The blob in git is CRLF, there is no
.gitattributespinning either style, andrenderFreebuffDataUseFaqMarkdown()produces an LF-only template literal. So theblock in the file cannot equal the generated copy byte-for-byte on any platform —
this is not a Windows checkout artifact, and the block has 8 CR for its 8 LF. The
assertion was testing whoever last saved the file, not the copy it is named for.
2. Three cases read files this repository does not ship (3 failures). Plain
ENOENT:CONTRIBUTING.mddescribes this repository as a public mirror, andpr-hygiene.ymllistsweb/among the paths that "are not part of thisrepository". Those cases can never pass here, so they fail rather than skip.
What this changes
readRepoFilenormalizes CRLF (and stray lone CR) to LF, so the assertioncompares the copy's words.
test.eachtable becomes per-casetest.skipIf(!isInThisTree(path)), usingthe
test.skipIfconvention already present in this repo. In the private tree,where
web/andlanding-lab/do exist, all five cases run unchanged; if theexport ever grows to include them, the cases reactivate on their own with no
edit here.
line endings do not decide whether the copy matches, locks thenormalization. It is not a tautology: with a no-op normalizer,
normalizeLineEndings(copy.replace(/\n/g, '\r\n'))returns the CRLF string andfails against the LF-only renderer.
How it was tested
main@2d10aaa8d)The two README cases are the regression lock — verified failing on unmodified
mainbefore the change, passing after. Surrounding suites on the same base,unaffected by this diff:
Notes for the reviewer
README.mdandfreebuff/cli/release/README.mdto LF would also make the test pass, but that isa ~117-line whitespace change to two docs files and it would recur for the next
person who saves with CRLF. Happy to switch to that approach if you would rather
the bytes be canonical — it is a one-line change to this PR.
Public CI(.github/workflows/ci.yml) installs,builds the SDK, builds the binary and smoke-tests it. It never runs
bun test, soa red suite in the exported tree is invisible to CI. I am not proposing a CI
change here, but this is the second file I found in the same situation and it may
be worth a separate look at whether
common/tests should run in public CI.common/src/__tests__/free-agents.test.tshas the same cause 2, for threeprompt-opening cases reading
freebuff/web/convex/...and twofreebuff-desktop/...files. I kept that out of this diff to keep it to onething; happy to send it as a follow-up.
web/,freebuff/web/,packages/internal/,packages/billing/,packages/bigquery/orpackages/build-tools/path is modified.