Skip to content

test(data): make the file-source tests Windows-neutral - #677

Merged
adamw7 merged 1 commit into
mainfrom
claude/github-actions-workflow-fix-lrs5cv
Aug 23, 2026
Merged

test(data): make the file-source tests Windows-neutral#677
adamw7 merged 1 commit into
mainfrom
claude/github-actions-workflow-fix-lrs5cv

Conversation

@adamw7

@adamw7 adamw7 commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Fixes the weekly maven-windows.yml run, where tools.data reported 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.csvSourceNamesTheFileItFailedToRead

org.junit.platform.commons.JUnitException: Failed to close extension context
Caused by: java.io.IOException: Failed to delete temp directory ... truncated.csv.gz
  Suppressed: java.nio.file.FileSystemException: ...\truncated.csv.gz:
      The process cannot access the file because it is being used by another process

The test builds a CSVDataSource over 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 @TempDir cleanup fails the test after its assertions have already passed. The source is now closed in a try-with-resources — IterableDataSource extends Closeable, and AbstractFileSource#close releases the handle whether or not open() succeeded.

AllowedPathsTest.acceptsFileNameStartingWithTwoDots

expected: <C:\Users\runneradmin\AppData\Local\Temp\junit-...\..name.csv>
 but was: <C:\Users\RUNNER~1\AppData\Local\Temp\junit-...\..name.csv>

The test expected dotted.toRealPath(), but AllowedPaths#validate documents — and returns — toAbsolutePath().normalize(). The two agree everywhere except Windows, where @TempDir hands back the short 8.3 path that toRealPath() spells out. The assertion now compares against the canonicalisation validate() documents, the way returnsCanonicalisedAbsolutePathWhenUnconfined already does. The containment check was never at fault: checkInsideBaseDir resolves the real path before comparing, so validation itself passed.

Verification

On JDK 25, mvn -B test in data: 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

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
@adamw7
adamw7 merged commit 2f54fbc into main Aug 23, 2026
1 check passed
@adamw7
adamw7 deleted the claude/github-actions-workflow-fix-lrs5cv branch August 23, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant