Fix Windows CI: stop TestTempFile from deleting shared temp directory#1746
Merged
tonyqus merged 3 commits intonissl-lab:masterfrom Mar 22, 2026
Merged
Conversation
Windows Defender real-time scanning on GitHub Actions runners grabs
newly created/modified files for inspection, causing intermittent
IOExceptions ("file being used by another process"), ZipExceptions
("EOF in header"), and FileNotFoundExceptions when tests try to
delete or reopen temp files during the scan window.
Exclude TEMP and workspace directories from Defender scanning in
both PR and CI workflows. This is standard practice for .NET OSS
projects running on Windows CI.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Path exclusions reduced failures from 6 to 2 but didn't fully eliminate the race. Disable real-time monitoring instead, which is the approach used by dotnet/runtime and other .NET OSS projects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tory Root cause: TestTempFile.TestCreateTempFile() and TestGetTempFilePath() both recursively delete the shared %TEMP%\poifiles directory to test directory recreation. When dotnet test runs all test projects in parallel, this nukes temp files that SXSSF tests and other tests are actively using, causing random FileNotFoundException, IOException, ZipException, and UnauthorizedAccessException failures. Fix: Remove the destructive directory deletion from TestTempFile. The directory recreation logic is now tested using an isolated subdirectory that won't interfere with other parallel tests. Also reverts the Defender exclusion changes from prior commits, as Windows Defender was not the root cause. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 tasks
Member
|
This issue blocked NPOI test for a long time. Thank you for fixing it! |
Member
|
Unfortunately, there is still some random file occupation. But definitely, better than before |
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
TestTempFile.TestCreateTempFile()andTestGetTempFilePath()both callDirectory.Delete(poifiles, true)in a retry loop, recursively deleting the shared%TEMP%\poifilesdirectory that ALL tests use for temp filesdotnet testruns all test projects in parallel (3 projects × 2 frameworks = 6 concurrent processes), this nukes temp files that SXSSF and other tests are actively writing toWhy different tests fail every run
The
TestTempFilefixture runs inNPOI.TestCases.dllconcurrently withNPOI.OOXML.TestCases.dll. Whichever OOXML test happens to be writing a temp file at the momentTestTempFiledeletes the directory gets a random I/O error:IOException: file being used by another processDirectory.Deleteconflicts with open file handlesFileNotFoundExceptionZipException: EOF in headerUnauthorizedAccessExceptionNullReferenceExceptionTest plan
🤖 Generated with Claude Code