Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ private FeatureFlag() { }

// Added for artifact post-processing, it enable/disable the post processing.
// Added in 17.2-preview 7.0-preview
public const string DISABLE_ARTIFACTS_POSTPROCESSING = VSTEST_ + "_" + nameof(DISABLE_ARTIFACTS_POSTPROCESSING);
public const string DISABLE_ARTIFACTS_POSTPROCESSING = VSTEST_ + nameof(DISABLE_ARTIFACTS_POSTPROCESSING);

// Added for artifact post-processing, it will show old output for dotnet sdk scenario.
// It can be useful if we need to restore old UX in case users are parsing the console output.
// Added in 17.2-preview 7.0-preview
public const string DISABLE_ARTIFACTS_POSTPROCESSING_NEW_SDK_UX = VSTEST_ + "_" + nameof(DISABLE_ARTIFACTS_POSTPROCESSING_NEW_SDK_UX);
public const string DISABLE_ARTIFACTS_POSTPROCESSING_NEW_SDK_UX = VSTEST_ + nameof(DISABLE_ARTIFACTS_POSTPROCESSING_NEW_SDK_UX);
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,18 @@ private bool TryGetExecutablePath(string executableBaseName, out string executab

public bool TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, out string muxerPath)
{
// If current process is the same as the target architecture we return the current process filename.
if (_processHelper.GetCurrentProcessArchitecture() == targetArchitecture)
{
string currentProcessFileName = _processHelper.GetCurrentProcessFileName();
if (Path.GetFileName(currentProcessFileName) != _muxerName)
{
EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Target architecture is the same as the current process architecture '{targetArchitecture}', but the current process is not a muxer: '{currentProcessFileName}'");
}
else
if (Path.GetFileName(currentProcessFileName) == _muxerName)
{
muxerPath = currentProcessFileName;
EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Target architecture is the same as the current process architecture '{targetArchitecture}', and the current process is a muxer, using that: '{muxerPath}'");
return true;
}

EqtTrace.Verbose($"DotnetHostHelper.TryGetDotnetPathByArchitecture: Target architecture is the same as the current process architecture '{targetArchitecture}', but the current process is not a muxer: '{currentProcessFileName}'");
}

// We used similar approach as the runtime resolver.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,37 +196,46 @@ public void DiscoverTestsUsingSourceNavigation(RunnerInfo runnerInfo)
}

[TestMethod]
// flaky on the desktop runner, desktop framework combo
[NetFullTargetFrameworkDataSource(useDesktopRunner: false)]
[NetFullTargetFrameworkDataSource(inProcess: true)]
[NetCoreTargetFrameworkDataSource]
public void CancelTestDiscovery(RunnerInfo runnerInfo)
public async Task CancelTestDiscovery(RunnerInfo runnerInfo)
{
// Setup
var testAssemblies = new List<string>
{
GetAssetFullPath("DiscoveryTestProject.dll"),
GetAssetFullPath("SimpleTestProject.dll"),
GetAssetFullPath("SimpleTestProject2.dll")
};

SetTestEnvironment(_testEnvironment, runnerInfo);
Setup();

var discoveredTests = new List<TestCase>();
var discoveryEvents = new Mock<ITestDiscoveryEventsHandler>();
discoveryEvents.Setup((events) => events.HandleDiscoveredTests(It.IsAny<IEnumerable<TestCase>>())).Callback
((IEnumerable<TestCase> testcases) => discoveredTests.AddRange(testcases));
discoveryEvents.Setup(events => events.HandleDiscoveredTests(It.IsAny<IEnumerable<TestCase>>()))
.Callback((IEnumerable<TestCase> testcases) =>
{
discoveredTests.AddRange(testcases);
_vstestConsoleWrapper.CancelDiscovery();
});
var isTestCancelled = false;
discoveryEvents.Setup(events => events.HandleDiscoveryComplete(It.IsAny<long>(), It.IsAny<IEnumerable<TestCase>>(), It.IsAny<bool>()))
.Callback((long _, IEnumerable<TestCase> testcases, bool isAborted) =>
{
isTestCancelled = isAborted;
if (testcases != null)
{
discoveredTests.AddRange(testcases);
}
});

// Act
var discoveryTask = Task.Run(() => _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), discoveryEvents.Object));

Task.Delay(2000).Wait();
_vstestConsoleWrapper.CancelDiscovery();
discoveryTask.Wait();
await Task.Run(() => _vstestConsoleWrapper.DiscoverTests(testAssemblies, GetDefaultRunSettings(), discoveryEvents.Object));

// Assert.
int discoveredSources = discoveredTests.Select((testcase) => testcase.Source).Distinct().Count();
Assert.AreNotEqual(testAssemblies.Count, discoveredSources, "All test assemblies discovered");
Assert.IsTrue(isTestCancelled);
int discoveredSourcesCount = discoveredTests.Select(testcase => testcase.Source).Distinct().Count();
Assert.AreNotEqual(testAssemblies.Count, discoveredSourcesCount, "All test assemblies discovered");
}

private IList<string> GetTestAssemblies()
Expand Down