Repository navigation
Ensure green test runs in VS #8329
Description
Activity
- addedneeds-triageHave yet to determine what bucket this goes in.Have yet to determine what bucket this goes in.
on Jan 20, 2023 #8328 as inspiration for proper conditional skipping of tests
Running unit tests in VS leads to some test failures
Just wanted to mention that some of these issues reproduce on the command line as well. For example,
dotnet testinsrc\Build.OM.UnitTestson Windows happily runs Unix-only test cases such asLogUnixWarningUponBuildingProjectWithDriveEnumeration.LogUnixWarningUponBuildingProjectWithDriveEnumeration
It seems Visual Studio ignores those attributes
[PlatformSpecific(TestPlatforms.AnyUnix)], whereas CI build filter tests based on them. I had the same situation withBuildEnvironmentHelper_Teststoday.Visual Studio shows them as
failing

but they are still run.I'm not sure whether this is a problem in how VS handling traits, or this is expected UX in VS, imo custom theory / fact attributes seems better solution as they work in VS and cmd and CI equally.
Not related to VS Run, but when running test of x64:
.\build.cmd -test -ci /p:Platform="x64
Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.UndeclaredReferenceEnforcementShouldNormalizeFilePathstook more than 1:30, after i killed the job.#8348 solves # 2, 3 and 4 in the list, and likely other cases as well. The Unix only cases will be skipped in VS now, as the tests running on unsupported framework. This should reduce number of red tests in VS.
Reacted by Jan Krivanek- added a commit that references this issue
on Feb 8, 2023 Tests which are still failing:
Microsoft.Build.Utilities.UnitTests (net7.0): 1 test Microsoft.Build.UnitTests.PrintLineDebugger_Tests.ArtifactsDirectoryLooksGood Microsoft.Build.Utilities.UnitTests (net472): 1 test Microsoft.Build.UnitTests.PrintLineDebugger_Tests.ArtifactsDirectoryLooksGood Microsoft.Build.Tasks.UnitTests (net7.0): 13 tests + 1 hangs Microsoft.Build.UnitTests.CreateItem_Tests.RecursiveDirOutOfProc - hangs Microsoft.Build.UnitTests.PrintLineDebugger_Tests.ArtifactsDirectoryLooksGood Microsoft.Build.UnitTests.MSBuildTask_Tests.ProjectItemSpecTooLong Microsoft.Build.UnitTests.CreateItem_Tests.LogWindowsWarningUponItemCreationWithDriveEnumeration (3 sets) Microsoft.Build.UnitTests.CreateItem_Tests.LogWindowsWarningUponCreateItemExecution (3 sets) Microsoft.Build.Tasks.UnitTests.RoslynCodeTaskFactory_Tests.RoslynCodeTaskFactory_ReuseCompilation Microsoft.Build.Tasks.UnitTests.ResourceManagement_Tests (4 tests) Microsoft.Build.Tasks.UnitTests (net472): 8 tests Microsoft.Build.UnitTests.PrintLineDebugger_Tests.ArtifactsDirectoryLooksGood Microsoft.Build.UnitTests.MSBuildTask_Tests.ProjectItemSpecTooLong Microsoft.Build.UnitTests.CreateItem_Tests.LogWindowsWarningUponItemCreationWithDriveEnumeration (3 sets) Microsoft.Build.UnitTests.CreateItem_Tests.LogWindowsWarningUponCreateItemExecution (3 sets) Microsoft.Build.Engine.UnitTests (net7.0): 55 tests Microsoft.Build.Engine.UnitTests.EvaluationProfiler_Tests (12 tests) - also took 60 minutes Microsoft.Build.Engine.UnitTests.BackEnd.TaskHostFactory_Tests (all tests) - 2 tests - took 10 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.RunningProxyBuildsOnOutOfProcNodesShouldIssueWarning - 2 sets took 10 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.ProxyCacheHitsOnPreviousCacheMissesShouldWork - took 40 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.ProjectCacheByVsScenarioWorks - took 40 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.ProjectCacheByBuildParametersAndGraphBuildWorks - took 30 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.ProjectCacheByBuildParametersAndBottomUpBuildWorks - took 35.1 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.ParallelStressTestForVsScenario - 2 sets - took 160.1 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.ParallelStressTest (1 data set) - took 20 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.CacheShouldNotGetQueriedForNestedBuildRequests - took 5 minutes Microsoft.Build.Engine.UnitTests.ProjectCache.ProjectCacheTests.CacheShouldBeQueriedInParallelDuringGraphBuilds - 1 set - took 10 minutes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.UndeclaredReferenceEnforcementShouldNormalizeFilePaths - 70 minutes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.UndeclaredReferenceEnforcementShouldFailOnUndeclaredReference - 2 sets - 10 minutes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.UndeclaredReferenceEnforcementShouldFailOnPreviouslyBuiltButUndeclaredReferences - 5 minutes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.SkippedTargetsShouldNotTriggerCacheMissEnforcement Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.IsolationRelatedMessagesShouldNotBePresentInNonIsolatedBuilds Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.IsolationRelatedMessageShouldBePresentInIsolatedBuildsWithMessaging - 5 mintes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.EnforcementsCanBeSkipped - 4 sets - 20 minutes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.CacheEnforcementShouldFailWhenReferenceWasNotPreviouslyBuiltWithoutContinueOnError Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.CacheEnforcementShouldAcceptPreviouslyBuiltReferences - 2 sets - 10 minutes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.CacheAndUndeclaredReferenceEnforcementShouldAcceptSelfReferences - 2 sets - 10 minutes Microsoft.Build.Graph.UnitTests.IsolateProjectsTests.CacheAndUndeclaredReferenceEnforcementShouldAcceptCallTarget Microsoft.Build.UnitTests.EscapingInProjects_Tests.SimpleScenarios.SemicolonInPropertyPassedIntoStringParam_UsingTaskHost Microsoft.Build.UnitTests.EscapingInProjects_Tests.SimpleScenarios.ItemTransformContainingSemicolon_InTaskHost Microsoft.Build.UnitTests.EscapingInProjects_Tests.SimpleScenarios.EscapedWildcardsShouldNotBeExpanded_InTaskHost Microsoft.Build.UnitTests.PrintLineDebugger_Tests.ArtifactsDirectoryLooksGood Microsoft.Build.UnitTests.MSBuildTask_Tests.ProjectItemSpecTooLong Microsoft.Build.UnitTests.FileMatcherTest.DriveEnumeratingWildcardIsLoggedOnWindows (4 sets) Microsoft.Build.UnitTests.BackEnd.TaskHost_Tests.TasksGetNoGlobalPropertiesIfNoneSpecified Microsoft.Build.UnitTests.BackEnd.TaskHost_Tests.TasksCanGetGlobalProperties Microsoft.Build.UnitTests.BackEnd.SdkResultOutOfProc_Tests.RunOutOfProcBuild - 5 minutes Microsoft.Build.UnitTests.BackEnd.SdkResultOutOfProc_Tests.RunOutOfProcBuildWithTwoProjects - 5 minutes Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.VerifyMultipleRequestForSameProjectWithErrors_Simple Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.VerifyMultipleRequestForSameProjectWithErrors_OnErrorChain Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.VerifyMultipleRequestForSameProjectWithErrors_ErrorAndContinue Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.VerifyMultipleRequestForSameProjectWithErrors_DifferentEntrypoints Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.TestSimultaneousSubmissionsWithLegacyThreadingData_P2P_MP - do not run in VS Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.TaskInputLoggingIsExposedToTasks (2 data sets) Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.SimpleP2PBuildOutOfProc Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.SimpleP2PBuildInProc Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.SimpleBuildWithFailure Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.SimpleBuildOutOfProcess Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.ShouldBuildMutatedProjectInstanceWhoseProjectWasPreviouslyBuiltAsAP2PDependency Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.SequentialBuildsOfTheSameProjectAllowed Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.SequentialBuild Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.RequestedResultsAreSatisfied Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.Regress265010 Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.Regress251333 Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.Regress239661 Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.ProjectInstanceTransfersToOOPNode Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.OverlappingBuildSubmissions Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.OutOfProcProjectInstanceBasedBuildDoesNotReloadFromDisk(2 data sets) Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.OutOfProcFileBasedP2PBuildSucceeds Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.OutOfProcEvaluationIdsUnique Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.MultiProcReentrantProjectWithCallTargetDoesNotFail Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.MsBuildForwardAllPropertiesFromChildLaunchChildNode Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.GraphBuildFail Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.ForwardNoPropertiesLaunchChildNodeDefault Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.ForwardNoPropertiesLaunchChildNode Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.FailedAfterTargetInP2PShouldCauseOverallBuildFailure_MultipleEntrypoints(1 data set) Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.ExplicitInprocAffinityGetsOverruledByDisableInprocNode Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.DisableInProcNode Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.CancelledBuildWithDelay40 Microsoft.Build.UnitTests.BackEnd.BuildManager_Tests.CacheLifetime Microsoft.Build.Engine.UnitTests (net472): 12 tests Microsoft.Build.UnitTests.PrintLineDebugger_Tests.ArtifactsDirectoryLooksGood Microsoft.Build.UnitTests.MSBuildTask_Tests.ProjectItemSpecTooLong Microsoft.Build.UnitTests.FileUtilities_Tests.FileOrDirectoryExistsNoThrowTooLongWithDotsRelative Microsoft.Build.UnitTests.FileUtilities_Tests.FileOrDirectoryExistsNoThrowTooLongWithDots Microsoft.Build.UnitTests.FileUtilities_Tests.FileExistsNoThrowTooLongWithDotsRelative Microsoft.Build.UnitTests.FileUtilities_Tests.FileExistsNoThrowTooLongWithDots Microsoft.Build.UnitTests.FileUtilities_Tests.DirectoryExistsNoThrowTooLongWithDotsRelative Microsoft.Build.UnitTests.FileMatcherTest.DriveEnumeratingWildcardIsLoggedOnWindows (4 sets) Microsoft.Build.Engine.UnitTests.BuildEnvironmentHelper_Tests.BuildEnvironmentFindsAmd64RunningInAmd64 Microsoft.Build.Engine.OM.UnitTests (net7.0): 4 tests Microsoft.Build.UnitTests.OM.Instance.ProjectItemInstance_Tests.LogWindowsWarningUponBuildingProjectWithDriveEnumeration (4 sets) Microsoft.Build.Engine.OM.UnitTests (net472): 4 tests Microsoft.Build.UnitTests.OM.Instance.ProjectItemInstance_Tests.LogWindowsWarningUponBuildingProjectWithDriveEnumeration (4 sets) Microsoft.Build.CommandLine.UnitTests (net472): 1 test Microsoft.Build.Engine.UnitTests.MSBuildServer_Tests.MSBuildServerTestRelated issue: #8457
- addedArea: Our Own BuildProblems affecting the build or build infrastructure of the MSBuild repo itself.Problems affecting the build or build infrastructure of the MSBuild repo itself.Priority:3Work that is nice to haveWork that is nice to haveand removedneeds-triageHave yet to determine what bucket this goes in.Have yet to determine what bucket this goes in.
on Aug 15, 2023 - added a commit that references this issue
on Oct 10, 2023 - added a commit that references this issue
on Oct 16, 2023 - added a commit that references this issue
on Oct 17, 2023 - marked Many tests fail when run from Visual Studio #11445 as a duplicate of this issue
on Feb 18, 2025
Issue Description
Running unit tests in VS leads to some test failures - this should not be a case. VS-centric developer workflow should not be neglected
Classes of problems to tackle:
ExecMSBuildfail on core: Unit test failures when run from VS #8313BuildEnvironmentHelper_Testsfail on core (extra RID in path) - Replacing traits used to skip certain test cases with customTheoryandFactattributes #8348TestPlatforms.AnyUnixrun on Windows (and can fail). Can we use Need ability to skip test programmatically xunit/xunit#2073 here? - Replacing traits used to skip certain test cases with customTheoryandFactattributes #8348SkipOnTargetFrameworkrun on excluded FW (and can fail) Can we use Need ability to skip test programmatically xunit/xunit#2073 here? - Replacing traits used to skip certain test cases with customTheoryandFactattributes #8348RetainsLastStringWithGivenHashCode: Fix .NET 3.5 InternableString.GetHashCode to match the full implementation #8340ProjectItemSpecTooLong(might be env setup on my machine) - related? MSBuild task tests fail when long-paths enabled #4247ProjectGetterResultsInWindowsDriveEnumerationWarningon Win (might be path specific?) - fixed by Allow MSBuild tests to access root of drive #7330LogWarningUponProjectInstanceCreationFromDriveEnumeratingContent&LogWindowsWarningUponProjectInstanceCreationFromDriveEnumeratingContent(env specific?) - Allow MSBuild tests to access root of drive #7330EvaluationProfiler_Tests(all) - no repro. (might have been caused by the bug in not unsetting the reverted change waves in tests)LogWindowsWarningUponBuildingProjectWithDriveEnumeration- likely just needs application of the following fix: Add ability to create temp mapped drive for integration tests #8366