Skip to content

Commit

Permalink
added executable as placeholder (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
csoltenborn committed Jan 12, 2016
1 parent 7064a8c commit 8974e3d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions GoogleTestExtension/GoogleTestAdapter.VS/TestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void RunTests(IEnumerable<string> executables, IRunContext runContext, IF
try
{
InitTestEnvironment(runContext.RunSettings, frameworkHandle);
IEnumerable<GoogleTestAdapter.Model.TestCase> allTestCasesInExecutables =
IEnumerable<Model.TestCase> allTestCasesInExecutables =
GetAllTestCasesInExecutables(executables);

DoRunTests(allTestCasesInExecutables, allTestCasesInExecutables, runContext, frameworkHandle);
Expand All @@ -53,10 +53,10 @@ public void RunTests(IEnumerable<TestCase> vsTestCasesToRun, IRunContext runCont
try
{
InitTestEnvironment(runContext.RunSettings, frameworkHandle);
IEnumerable<GoogleTestAdapter.Model.TestCase> allTestCasesInExecutables =
IEnumerable<Model.TestCase> allTestCasesInExecutables =
GetAllTestCasesInExecutables(vsTestCasesToRun.Select(tc => tc.Source).Distinct());

IEnumerable<GoogleTestAdapter.Model.TestCase> testCasesToRun = vsTestCasesToRun.Select(DataConversionExtensions.ToTestCase);
IEnumerable<Model.TestCase> testCasesToRun = vsTestCasesToRun.Select(DataConversionExtensions.ToTestCase);
DoRunTests(allTestCasesInExecutables, testCasesToRun, runContext, frameworkHandle);
}
catch (Exception e)
Expand Down
27 changes: 16 additions & 11 deletions GoogleTestExtension/GoogleTestAdapter/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ private string ReplacePlaceholders(string theString, string solutionDirectory, s
return "";
}

string result = theString.Replace(Options.TestDirPlaceholder, testDirectory);
result = result.Replace(Options.ThreadIdPlaceholder, threadId.ToString());
result = result.Replace(Options.SolutionDirPlaceholder, solutionDirectory);
string result = theString.Replace(TestDirPlaceholder, testDirectory);
result = result.Replace(ThreadIdPlaceholder, threadId.ToString());
result = result.Replace(SolutionDirPlaceholder, solutionDirectory);
return result;
}

Expand All @@ -71,14 +71,19 @@ private string ReplacePlaceholders(string theString, string solutionDirectory, s
public const string PageParallelizationName = "Parallelization";
public const string PageAdvancedName = "Advanced";

public const string SolutionDirPlaceholder = "$(SolutionDir)";
private const string SolutionDirPlaceholder = "$(SolutionDir)";
public const string TestDirPlaceholder = "$(TestDir)";
public const string ThreadIdPlaceholder = "$(ThreadId)";
public const string ExecutablePlaceholder = "$(Executable)";

private const string DescriptionOfPlaceholders =
TestDirPlaceholder + " - path of a directory which can be used by the tests\n" +
ThreadIdPlaceholder + " - id of thread executing the current tests\n" +
SolutionDirPlaceholder + " - directory of the solution";
private const string DescriptionOfPlaceholdersForBatches =
TestDirPlaceholder + " - path of a directory which can be used by the tests" +
ThreadIdPlaceholder + "\n - id of thread executing the current tests" +
SolutionDirPlaceholder + "\n - directory of the solution";

private const string DescriptionOfPlaceholdersForExecutables =
DescriptionOfPlaceholdersForBatches +
ExecutablePlaceholder + "\n - executable containing the tests";

#region GeneralOptionsPage

Expand Down Expand Up @@ -212,7 +217,7 @@ public virtual List<RegexTraitPair> TraitsRegexesAfter
public const string OptionAdditionalTestExecutionParamsDefaultValue = "";
public const string OptionAdditionalTestExecutionParamsDescription =
"Additional parameters for Google Test executable. Placeholders:\n"
+ DescriptionOfPlaceholders;
+ DescriptionOfPlaceholdersForExecutables;

public virtual string AdditionalTestExecutionParam => XmlOptions.AdditionalTestExecutionParam ?? OptionAdditionalTestExecutionParamsDefaultValue;

Expand Down Expand Up @@ -251,7 +256,7 @@ public virtual int MaxNrOfThreads
public const string OptionBatchForTestSetupDefaultValue = "";
public const string OptionBatchForTestSetupDescription =
"Batch file to be executed before test execution. If tests are executed in parallel, the batch file will be executed once per thread. Placeholders:\n"
+ DescriptionOfPlaceholders;
+ DescriptionOfPlaceholdersForBatches;

public virtual string BatchForTestSetup => XmlOptions.BatchForTestSetup ?? OptionBatchForTestSetupDefaultValue;

Expand All @@ -260,7 +265,7 @@ public virtual int MaxNrOfThreads
public const string OptionBatchForTestTeardownDefaultValue = "";
public const string OptionBatchForTestTeardownDescription =
"Batch file to be executed after test execution. If tests are executed in parallel, the batch file will be executed once per thread. Placeholders:\n"
+ DescriptionOfPlaceholders;
+ DescriptionOfPlaceholdersForBatches;

public virtual string BatchForTestTeardown => XmlOptions.BatchForTestTeardown ?? OptionBatchForTestTeardownDefaultValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void RunTests(IEnumerable<TestCase> allTestCases, IEnumerable<TestCase> t
TestCase[] allTestCasesAsArray = allTestCases as TestCase[] ?? allTestCases.ToArray();
foreach (string executable in groupedTestCases.Keys)
{
string finalParameters = userParameters.Replace(Options.ExecutablePlaceholder, executable);
if (Canceled)
{
break;
Expand All @@ -43,7 +44,7 @@ public void RunTests(IEnumerable<TestCase> allTestCases, IEnumerable<TestCase> t
executable,
allTestCasesAsArray.Where(tc => tc.Source == executable),
groupedTestCases[executable],
userParameters,
finalParameters,
isBeingDebugged,
debuggedLauncher);
}
Expand Down

0 comments on commit 8974e3d

Please sign in to comment.