microsoft / devhome

The new Dev Home experience for Windows!
https://aka.ms/devhomedocs
MIT License
3.65k stars 327 forks source link

GitCommandRunnerTests throw file in use exception during Class Initialization #3892

Open ssparach opened 2 months ago

ssparach commented 2 months ago

Dev Home version

Any latest version

Windows build number

No response

Other software

No response

Steps to reproduce the bug

Run FileExplorerGitIntegration.UnitTest. On the first run, GitCommandRunnerTests fail with the below:

TestBasicInvokeGitFunctionality
  Source: GitCommandRunnerTests.cs line 74
  Duration: < 1 ms

 Message: 
   Class Initialization method FileExplorerGitIntegration.UnitTest.GitCommandRunnerTests.ClassInitialize threw exception. System.IO.IOException: The process cannot access the file 'pack-fac19906ba9a2181e9b1cde3dcb317f0b52acb31.pack' because it is being used by another process..

 Stack Trace: 
   FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
   FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
   GitCommandRunnerTests.ClassInitialize(TestContext context) line 44
   RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Subsequent runs of the GitCommandRunnerTests are passing.

Expected result

Tests are less noisy and do not fail with file in use errors

Actual result

TestInvokeGitFunctionalityForRawStatus  Source: GitCommandRunnerTests.cs line 89  Duration: < 1 ms

Message:  Class Initialization method FileExplorerGitIntegration.UnitTest.GitCommandRunnerTests.ClassInitialize threw exception. System.IO.IOException: The process cannot access the file 'pack-fac19906ba9a2181e9b1cde3dcb317f0b52acb31.pack' because it is being used by another process..

Stack Trace:  FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel) FileSystem.RemoveDirectory(String fullPath, Boolean recursive) GitCommandRunnerTests.ClassInitialize(TestContext context) line 44 RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Included System Information

No response

Included Extensions Information

No response