Skip to content

Commit 49b2c17

Browse files
authored
Fix no-suitable provider found (#4475)
1 parent 6bce41d commit 49b2c17

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,17 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve
9999
// marked as NotDiscovered.
100100
_dataAggregator.MarkSourcesWithStatus(discoveryCriteria.Sources, DiscoveryStatus.NotDiscovered);
101101

102-
_parallelOperationManager.StartWork(workloads, eventHandler, GetParallelEventHandler, InitializeDiscoverTestsOnConcurrentManager, DiscoverTestsOnConcurrentManager);
102+
if (nonRunnableWorkloads.Count > 0)
103+
{
104+
// We found some sources that don't associate to any runtime provider and so they cannot run.
105+
// Mark the sources as skipped.
106+
107+
_dataAggregator.MarkSourcesWithStatus(nonRunnableWorkloads.SelectMany(w => w.Work.Sources), DiscoveryStatus.SkippedDiscovery);
108+
// TODO: in strict mode keep them as non-discovered, and mark the run as aborted.
109+
// _dataAggregator.MarkAsAborted();
110+
}
111+
112+
_parallelOperationManager.StartWork(runnableWorkloads, eventHandler, GetParallelEventHandler, InitializeDiscoverTestsOnConcurrentManager, DiscoverTestsOnConcurrentManager);
103113
}
104114

105115
private ITestDiscoveryEventsHandler2 GetParallelEventHandler(ITestDiscoveryEventsHandler2 eventHandler, IProxyDiscoveryManager concurrentManager)

src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRunEventsH
115115
// _currentRunDataAggregator.MarkAsAborted();
116116
}
117117

118-
_parallelOperationManager.StartWork(workloads, eventHandler, GetParallelEventHandler, PrepareTestRunOnConcurrentManager, StartTestRunOnConcurrentManager);
118+
_parallelOperationManager.StartWork(runnableWorkloads, eventHandler, GetParallelEventHandler, PrepareTestRunOnConcurrentManager, StartTestRunOnConcurrentManager);
119119

120120
// Why 1? Because this is supposed to be a processId, and that is just the default that was chosen by someone before me,
121121
// and maybe is checked somewhere, but I don't see it checked in our codebase.

test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DiscoveryTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
using Microsoft.TestPlatform.TestUtilities;
1111
using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
12+
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions;
1213
using Microsoft.VisualStudio.TestTools.UnitTesting;
1314

1415
namespace Microsoft.TestPlatform.AcceptanceTests;
@@ -114,4 +115,28 @@ public void TypesToLoadAttributeTests()
114115
CollectionAssert.AreEquivalent(expected, actual, $"Specified types using TypesToLoadAttribute in \"{extension}\" assembly doesn't match the expected.");
115116
}
116117
}
118+
119+
[TestMethod]
120+
[TestCategory("Windows-Review")]
121+
[NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)]
122+
public void DiscoverTestsShouldSucceedWhenAtLeastOneDllFindsRuntimeProvider(RunnerInfo runnerInfo)
123+
{
124+
SetTestEnvironment(_testEnvironment, runnerInfo);
125+
126+
var firstAssetDirectory = Path.GetDirectoryName(GetAssetFullPath("MSTestProject1.dll"))!;
127+
128+
// Include all dlls from the assembly dir, as the default AzDO filter *test*.dll does.
129+
var dlls = Directory.EnumerateFiles(firstAssetDirectory, "*test*.dll").ToArray();
130+
var quotedDlls = string.Join(" ", dlls.Select(a => a.AddDoubleQuote()));
131+
132+
var arguments = PrepareArguments(quotedDlls, GetTestAdapterPath(), string.Empty, framework: string.Empty, _testEnvironment.InIsolationValue, resultsDirectory: TempDirectory.Path);
133+
arguments = string.Concat(arguments, " /listtests");
134+
arguments = string.Concat(arguments, " /logger:\"console;prefix=true\"");
135+
InvokeVsTest(arguments);
136+
137+
var portableAssembly = dlls.Single(a => a.EndsWith("Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll"));
138+
StringAssert.Contains(StdOut, $"Skipping source: {portableAssembly} (.NETPortable,Version=v4.5,Profile=Profile259,");
139+
140+
ExitCodeEquals(0);
141+
}
117142
}

test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ExecutionTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions;
1010

1111
using TestPlatform.TestUtilities;
12+
using System.Linq;
1213

1314
namespace Microsoft.TestPlatform.AcceptanceTests;
1415

@@ -396,4 +397,27 @@ public void ExitCodeShouldNotDependOnFailTreatNoTestsAsErrorFalseValueWhenThereA
396397
// Returning 1 because of failing test in test assembly (SimpleTestProject2.dll)
397398
ExitCodeEquals(1);
398399
}
400+
401+
[TestMethod]
402+
[TestCategory("Windows-Review")]
403+
[NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)]
404+
public void ExecuteTestsShouldSucceedWhenAtLeastOneDllFindsRuntimeProvider(RunnerInfo runnerInfo)
405+
{
406+
SetTestEnvironment(_testEnvironment, runnerInfo);
407+
408+
var firstAssetDirectory = Path.GetDirectoryName(GetAssetFullPath("MSTestProject1.dll"))!;
409+
410+
// Include all dlls from the assembly dir, as the default AzDO filter *test*.dll does.
411+
var dlls = Directory.EnumerateFiles(firstAssetDirectory, "*test*.dll").ToArray();
412+
var quotedDlls = string.Join(" ", dlls.Select(a => a.AddDoubleQuote()));
413+
414+
var arguments = PrepareArguments(quotedDlls, GetTestAdapterPath(), string.Empty, framework: string.Empty, _testEnvironment.InIsolationValue, resultsDirectory: TempDirectory.Path);
415+
arguments = string.Concat(arguments, " /logger:\"console;prefix=true\"");
416+
InvokeVsTest(arguments);
417+
418+
var portableAssembly = dlls.Single(a => a.EndsWith("Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll"));
419+
StringAssert.Contains(StdOut, $"Skipping source: {portableAssembly} (.NETPortable,Version=v4.5,Profile=Profile259,");
420+
421+
ExitCodeEquals(1);
422+
}
399423
}

test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ protected static void ExecuteApplication(string path, string? args, out string s
843843
{
844844
// Ensure async buffers are flushed
845845
process.WaitForExit();
846+
process.WaitForExit(1000);
846847
}
847848

848849
stopwatch.Stop();

0 commit comments

Comments
 (0)