Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition in SonarScanner.MSBuild.Tasks.IntegrationTest #1985

Open
sebastien-marichal opened this issue Jun 26, 2024 · 0 comments
Open

Comments

@sebastien-marichal
Copy link
Contributor

The Settings_ValidSetup_ForAnalyzedProject unit test sometimes fails because it tries to write the binlog file in parallel.

This is due to the test being a parameterized test and our helper methods that create the temporary folder not taking into account the different parameters.

Here is the log:

  Failed Settings_ValidSetup_ForAnalyzedProject (VB,False,true) [134 ms]
  Error Message:
   Expected boolean to be True, but found False.
  Stack Trace:
     at FluentAssertions.Execution.LateBoundTestFramework.Throw(String message)
   at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
   at FluentAssertions.Primitives.BooleanAssertions`1.Be(Boolean expected, String because, Object[] becauseArgs)
   at SonarScanner.MSBuild.Tasks.IntegrationTest.BuildRunner.BuildTargets(TestContext testContext, String projectFile, Boolean buildShouldSucceed, String[] targets) in C:\sonar-ci\_work\2\s\Tests\SonarScanner.MSBuild.Tasks.IntegrationTest\MSBuildExecution\BuildRunner.cs:line 75
   at SonarScanner.MSBuild.Tasks.IntegrationTest.TargetsTests.RoslynTargetsTests.Execute_Settings_ValidSetup(String msBuildLanguage, Boolean isTestProject, String excludeTestProject, String csRuleSetPath, String vbRulesetPath) in C:\sonar-ci\_work\2\s\Tests\SonarScanner.MSBuild.Tasks.IntegrationTest\TargetsTests\RoslynTargetsTests.cs:line 770
   at SonarScanner.MSBuild.Tasks.IntegrationTest.TargetsTests.RoslynTargetsTests.Settings_ValidSetup_ForAnalyzedProject(String msBuildLanguage, Boolean isTestProject, String excludeTestProjects) in C:\sonar-ci\_work\2\s\Tests\SonarScanner.MSBuild.Tasks.IntegrationTest\TargetsTests\RoslynTargetsTests.cs:line 57

  Standard Output Messages:
 Project Directory: C:\sonar-ci\_work\2\s\TestResults\Deploy_SYSTEM 20240626T083833\38
 08:38:52.969  Executing file C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\msbuild.exe
   Args: C:\sonar-ci\_work\2\s\TestResults\Deploy_SYSTEM 20240626T083833\38\Settings_ValidSetup_ForAnalyzedProject.proj.txt /bl:C:\sonar-ci\_work\2\s\TestResults\Deploy_SYSTEM 20240626T083833\38\build.binlog /t:SonarOverrideRunAnalyzers;OverrideRoslynCodeAnalysisProperties 
   Working directory: 
   Timeout (ms):-1
   Process id: 7832
 08:38:53.032  MSBuild version 17.9.5+33de0b227 for .NET Framework
 08:38:53.032  MSBUILD : Logger error MSB4104: Failed to write to log file "C:\sonar-ci\_work\2\s\TestResults\Deploy_SYSTEM 20240626T083833\38\build.binlog". The process cannot access the file 'C:\sonar-ci\_work\2\s\TestResults\Deploy_SYSTEM 20240626T083833\38\build.binlog' because it is being used by another process.
 08:38:53.079  System.IO.IOException: The process cannot access the file 'C:\sonar-ci\_work\2\s\TestResults\Deploy_SYSTEM 20240626T083833\38\build.binlog' because it is being used by another process.
 08:38:53.079     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
 08:38:53.079     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
 08:38:53.079     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
 08:38:53.079     at System.IO.FileStream..ctor(String path, FileMode mode)
 08:38:53.079     at Microsoft.Build.Logging.BinaryLogger.Initialize(IEventSource eventSource)
 08:38:53.079  Process returned exit code 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant