Skip to content

Commit

Permalink
Replacing calls to BuildMultipleAssemblyPath when passing only one so…
Browse files Browse the repository at this point in the history
…urce in acceptance tests (#4358)

* issue 3510

replacing calls to BuildMultipleAssemblyPath by GetASsetFullPath when passing only one source

* Add quotes

---------

Co-authored-by: David Mueller IWS <david.iws.mueller@getinge.com>
Co-authored-by: Jakub Jareš <me@jakubjares.com>
  • Loading branch information
3 people committed Apr 4, 2023
1 parent facbe98 commit 81e1e74
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void BlameDataCollectorShouldOutputDumpFile(RunnerInfo runnerInfo)
{

SetTestEnvironment(_testEnvironment, runnerInfo);
var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue);
arguments = string.Concat(arguments, $" /Blame:CollectDump");
arguments = string.Concat(arguments, $" /ResultsDirectory:{TempDirectory.Path}");
Expand All @@ -89,7 +89,7 @@ public void BlameDataCollectorShouldNotOutputDumpFileWhenNoCrashOccurs(RunnerInf
{

SetTestEnvironment(_testEnvironment, runnerInfo);
var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue);
arguments = string.Concat(arguments, $" /Blame:CollectDump");
arguments = string.Concat(arguments, $" /ResultsDirectory:{TempDirectory.Path}");
Expand All @@ -113,7 +113,7 @@ public void BlameDataCollectorShouldOutputDumpFileWhenNoCrashOccursButCollectAlw
{

SetTestEnvironment(_testEnvironment, runnerInfo);
var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, string.Empty, runnerInfo.InIsolationValue);
arguments = string.Concat(arguments, $" /Blame:CollectDump;CollectAlways=True");
arguments = string.Concat(arguments, $" /ResultsDirectory:{TempDirectory.Path}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void ExecuteTestsWithDataCollection(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll");
string runSettings = GetRunsettingsFilePath(TempDirectory.Path);
string diagFileName = Path.Combine(TempDirectory.Path, "diaglog.txt");
var extensionsPath = Path.GetDirectoryName(GetTestDllForFramework("OutOfProcDataCollector.dll", runnerInfo.RunnerFramework));
Expand All @@ -51,7 +51,7 @@ public void ExecuteTestsWithDataCollectionUsingCollectArgument(RunnerInfo runner
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll");
string diagFileName = Path.Combine(TempDirectory.Path, "diaglog.txt");
var extensionsPath = Path.GetDirectoryName(GetTestDllForFramework("OutOfProcDataCollector.dll", runnerInfo.RunnerFramework));

Expand Down Expand Up @@ -101,8 +101,8 @@ public void DataCollectorAttachmentProcessor(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPath = BuildMultipleAssemblyPath("SimpleTestProject.dll");
var secondAssemblyPath = BuildMultipleAssemblyPath("SimpleTestProject2.dll");
var assemblyPath = GetAssetFullPath("SimpleTestProject.dll");
var secondAssemblyPath = GetAssetFullPath("SimpleTestProject2.dll");
string runSettings = GetRunsettingsFilePath(TempDirectory.Path);
string diagFileName = Path.Combine(TempDirectory.Path, "diaglog.txt");
var extensionsPath = Path.GetDirectoryName(GetTestDllForFramework("AttachmentProcessorDataCollector.dll", "netstandard2.0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void RunCoverletCoverage()

string coverletAdapterPath = Path.GetDirectoryName(Directory.GetFiles(_testEnvironment.GetNugetPackage("coverlet.collector"), "coverlet.collector.dll", SearchOption.AllDirectories).Single())!;
string logId = Guid.NewGuid().ToString("N");
string assemblyPath = BuildMultipleAssemblyPath("CoverletCoverageTestProject.dll").Trim('\"');
string assemblyPath = GetAssetFullPath("CoverletCoverageTestProject.dll").Trim('\"');
string logPath = Path.Combine(Path.GetDirectoryName(assemblyPath)!, $"coverletcoverage.{logId}.log");
string logPathDirectory = Path.GetDirectoryName(logPath)!;
string argument = $"--collect:{"XPlat Code Coverage".AddDoubleQuote()} {PrepareArguments(assemblyPath, coverletAdapterPath, "", ".NETCoreApp,Version=v2.1", resultsDirectory: resultsDir.Path)} --diag:{logPath.AddDoubleQuote()}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void RunningTestWithAFailingDebugAssertDoesNotCrashTheHostingProcess(Runn
// is to not crash the process when we are running in debug, and debugger is attached
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPath = BuildMultipleAssemblyPath("CrashingOnDebugAssertTestProject.dll");
var assemblyPath = GetAssetFullPath("CrashingOnDebugAssertTestProject.dll");
var arguments = PrepareArguments(assemblyPath, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
InvokeVsTest(arguments);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void RunDotnetTestWithDll(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPath = BuildMultipleAssemblyPath("SimpleTestProject.dll");
var assemblyPath = GetAssetFullPath("SimpleTestProject.dll");
InvokeDotnetTest($@"{assemblyPath} --logger:""Console;Verbosity=normal""");

// ensure our dev version is used
Expand Down Expand Up @@ -71,7 +71,7 @@ public void RunDotnetTestWithDllPassInlineSettings(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPath = BuildMultipleAssemblyPath("ParametrizedTestProject.dll");
var assemblyPath = GetAssetFullPath("ParametrizedTestProject.dll");
InvokeDotnetTest($@"{assemblyPath} --logger:""Console;Verbosity=normal"" -- TestRunParameters.Parameter(name=\""weburl\"", value=\""http://localhost//def\"")");

ValidateSummaryStatus(1, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public void RunMultipleTestAssembliesWithoutTestAdapterPath(RunnerInfo runnerInf
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject.dll");
var assemblyPath = GetAssetFullPath("SimpleTestProject.dll");
var xunitAssemblyPath = _testEnvironment.GetTestAsset("XUTestProject.dll");

assemblyPaths = string.Join(" ", assemblyPaths, xunitAssemblyPath.AddDoubleQuote());
InvokeVsTestForExecution(assemblyPaths, testAdapterPath: string.Empty, FrameworkArgValue, string.Empty);
assemblyPath = string.Join(" ", assemblyPath.AddDoubleQuote(), xunitAssemblyPath.AddDoubleQuote());
InvokeVsTestForExecution(assemblyPath, testAdapterPath: string.Empty, FrameworkArgValue, string.Empty);

ValidateSummaryStatus(2, 2, 1);
ExitCodeEquals(1); // failing tests
Expand Down Expand Up @@ -143,7 +143,7 @@ public void TestSessionTimeOutTests(RunnerInfo runnerInfo)
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths =
BuildMultipleAssemblyPath("SimpleTestProject3.dll");
GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /TestCaseFilter:TestSessionTimeoutTest");

Expand All @@ -163,7 +163,7 @@ public void TestPlatformShouldBeCompatibleWithOldTestHost(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SampleProjectWithOldTestHost.dll");
var assemblyPaths = GetAssetFullPath("SampleProjectWithOldTestHost.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

InvokeVsTest(arguments);
Expand All @@ -179,7 +179,7 @@ public void WorkingDirectoryIsSourceDirectory(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /tests:WorkingDirectoryTest");

Expand All @@ -206,7 +206,7 @@ public void StackOverflowExceptionShouldBeLoggedToConsoleAndDiagLogFile(RunnerIn
var diagLogFilePath = Path.Combine(TempDirectory.Path, $"std_error_log_{Guid.NewGuid()}.txt");
File.Delete(diagLogFilePath);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /testcasefilter:ExitWithStackoverFlow");
arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}");
Expand Down Expand Up @@ -236,7 +236,7 @@ public void UnhandleExceptionExceptionShouldBeLoggedToDiagLogFile(RunnerInfo run
File.Delete(diagLogFilePath);

var assemblyPaths =
BuildMultipleAssemblyPath("SimpleTestProject3.dll");
GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /testcasefilter:ExitwithUnhandleException");
arguments = string.Concat(arguments, $" /diag:{diagLogFilePath}");
Expand Down Expand Up @@ -282,7 +282,7 @@ public void NoIncompatibleSourcesWarningShouldBeDisplayedInTheConsoleWhenGivenSi

var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.6.2 framework and X86 platform. SimpleTestProjectx86 would use Framework .NETFramework,Version=v4.6.2 and Platform X86";
var assemblyPaths =
BuildMultipleAssemblyPath("SimpleTestProjectx86.dll");
GetAssetFullPath("SimpleTestProjectx86.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

InvokeVsTest(arguments + " /diag:logs\\");
Expand All @@ -302,7 +302,7 @@ public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsoleOnlyWhenRunni

var expectedWarningContains = @"Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.6.2 framework and X86 platform. SimpleTestProject2.dll would use Framework .NETFramework,Version=v4.6.2 and Platform X64";
var assemblyPaths =
BuildMultipleAssemblyPath("SimpleTestProject2.dll");
GetAssetFullPath("SimpleTestProject2.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

InvokeVsTest(arguments);
Expand Down Expand Up @@ -330,7 +330,7 @@ public void ExitCodeShouldReturnOneWhenTreatNoTestsAsErrorParameterSetToTrueAndN
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll");

var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

Expand All @@ -350,7 +350,7 @@ public void ExitCodeShouldReturnZeroWhenTreatNoTestsAsErrorParameterSetToFalseAn
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

// Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed
Expand All @@ -369,7 +369,7 @@ public void ExitCodeShouldNotDependOnTreatNoTestsAsErrorTrueValueWhenThereAreAny
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll");

var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

Expand All @@ -387,7 +387,7 @@ public void ExitCodeShouldNotDependOnFailTreatNoTestsAsErrorFalseValueWhenThereA
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject2.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject2.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void UITestShouldPassIfApartmentStateIsSTA(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths = BuildMultipleAssemblyPath("SimpleTestProject3.dll");
var assemblyPaths = GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /testcasefilter:UITestMethod");
InvokeVsTest(arguments);
Expand All @@ -30,7 +30,7 @@ public void WarningShouldBeShownWhenValueIsSTAForNetCore(RunnerInfo runnerInfo)
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths =
BuildMultipleAssemblyPath("SimpleTestProject2.dll");
GetAssetFullPath("SimpleTestProject2.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /testcasefilter:PassingTest2 -- RunConfiguration.ExecutionThreadApartmentState=STA");
InvokeVsTest(arguments);
Expand All @@ -45,7 +45,7 @@ public void UITestShouldFailWhenDefaultApartmentStateIsMTA(RunnerInfo runnerInfo
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths =
BuildMultipleAssemblyPath("SimpleTestProject3.dll");
GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /testcasefilter:UITestMethod -- RunConfiguration.ExecutionThreadApartmentState=MTA");
InvokeVsTest(arguments);
Expand All @@ -60,7 +60,7 @@ public void CancelTestExectionShouldWorkWhenApartmentStateIsSTA(RunnerInfo runne
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPaths =
BuildMultipleAssemblyPath("SimpleTestProject3.dll");
GetAssetFullPath("SimpleTestProject3.dll");
var arguments = PrepareArguments(assemblyPaths, GetTestAdapterPath(), string.Empty, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
arguments = string.Concat(arguments, " /tests:UITestWithSleep1,UITestMethod -- RunConfiguration.ExecutionThreadApartmentState=STA RunConfiguration.TestSessionTimeout=2000");
InvokeVsTest(arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void TestRunInATesthostThatTargetsTheirChosenNETFramework(RunnerInfo runn
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPath = BuildMultipleAssemblyPath("MultitargetedNetFrameworkProject.dll");
var assemblyPath = GetAssetFullPath("MultitargetedNetFrameworkProject.dll");
var arguments = PrepareArguments(assemblyPath, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);

// Tell the test project which target framework we are expecting it to run as.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void RunsToCompletionWhenJapaneseResourcesAreLookedUpForMSCorLib(RunnerIn
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var assemblyPath = BuildMultipleAssemblyPath("RecursiveResourceLookupCrash.dll");
var assemblyPath = GetAssetFullPath("RecursiveResourceLookupCrash.dll");
var arguments = PrepareArguments(assemblyPath, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
InvokeVsTest(arguments);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void RunningApplicationThatIsBuiltAsSelfContainedWillNotFailToFindHostpol
SetTestEnvironment(_testEnvironment, runnerInfo);

// the app is published to win10-x64 because of the runtime identifier in the project
var assemblyPath = BuildMultipleAssemblyPath($@"win10-x64{Path.DirectorySeparatorChar}SelfContainedAppTestProject.dll");
var assemblyPath = GetAssetFullPath($@"win10-x64{Path.DirectorySeparatorChar}SelfContainedAppTestProject.dll");
var arguments = PrepareArguments(assemblyPath, null, null, FrameworkArgValue, runnerInfo.InIsolationValue, resultsDirectory: TempDirectory.Path);
InvokeVsTest(arguments);

Expand Down

0 comments on commit 81e1e74

Please sign in to comment.