test(data): make the file-source tests Windows-neutral - #677
Merged
Conversation
The weekly maven-windows run failed on two assumptions that only hold on POSIX. AbstractFileSourceTest left the source of a failed read unclosed, and Windows refuses to delete a file a handle still holds, so @tempdir cleanup failed the test; the source is now closed in a try-with-resources. AllowedPathsTest expected validate() to answer a real path, which matches an absolute normalised one everywhere but Windows, where @tempdir hands back the short 8.3 form (RUNNER~1) that toRealPath() spells out; it now compares against the canonicalisation validate() documents. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmRt9ZYYtKg7S2Ebfvih6g
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.
Fixes the weekly
maven-windows.ymlrun, wheretools.datareported 1 failure and 1 error out of 669. Both are POSIX-only assumptions in the tests, which is why every Linux job stays green. The production classes are correct as written; only the tests change.AbstractFileSourceTest.csvSourceNamesTheFileItFailedToReadThe test builds a
CSVDataSourceover a truncated GZip member, asserts the read fails, and never closes it. The descriptor stays open: Linux unlinks an open file happily, Windows refuses, so@TempDircleanup fails the test after its assertions have already passed. The source is now closed in a try-with-resources —IterableDataSource extends Closeable, andAbstractFileSource#closereleases the handle whether or notopen()succeeded.AllowedPathsTest.acceptsFileNameStartingWithTwoDotsThe test expected
dotted.toRealPath(), butAllowedPaths#validatedocuments — and returns —toAbsolutePath().normalize(). The two agree everywhere except Windows, where@TempDirhands back the short 8.3 path thattoRealPath()spells out. The assertion now compares against the canonicalisationvalidate()documents, the wayreturnsCanonicalisedAbsolutePathWhenUnconfinedalready does. The containment check was never at fault:checkInsideBaseDirresolves the real path before comparing, so validation itself passed.Verification
On JDK 25,
mvn -B testindata: Tests run: 669, Failures: 0, Errors: 0 — BUILD SUCCESS. The original red cannot be reproduced on Linux (both failures need Windows file-locking and 8.3 path semantics), so the pairing of cause to fix is read off the stack traces rather than observed failing-then-passing.Generated by Claude Code