Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TraceDataCollectorDirectoryPath parameter to VSTestTask #1601

Merged
merged 5 commits into from
May 16, 2018
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 @@ -46,6 +46,7 @@ Copyright (c) .NET Foundation. All rights reserved.
VSTestVerbosity="$(VSTestVerbosity)"
VSTestCollect="$(VSTestCollect)"
VSTestBlame="$(VSTestBlame)"
VSTestTraceDataCollectorDirectoryPath="$(TraceDataCollectorDirectoryPath)"
/>
</Target>

Expand Down Expand Up @@ -85,6 +86,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<Message Text="VSTestVerbosity = $(VSTestVerbosity)" Importance="low" />
<Message Text="VSTestCollect = $(VSTestCollect)" Importance="low" />
<Message Text="VSTestBlame = $(VSTestBlame)" Importance="low" />
<Message Text="VSTestTraceDataCollectorDirectoryPath = $(TraceDataCollectorDirectoryPath)" Importance="low" />
</Target>

</Project>
29 changes: 29 additions & 0 deletions src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public string VSTestBlame
set;
}

public string VSTestTraceDataCollectorDirectoryPath
{
get;
set;
}

public override bool Execute()
{
var traceEnabledValue = Environment.GetEnvironmentVariable("VSTEST_BUILD_TRACE");
Expand All @@ -132,11 +138,14 @@ public void Cancel()
internal IEnumerable<string> CreateArgument()
{
var isConsoleLoggerEnabled = true;
var isCollectCodeCoverageEnabled = false;
var isRunSettingsEnabled = false;
var allArgs = new List<string>();

// TODO log arguments in task
if (!string.IsNullOrEmpty(this.VSTestSetting))
{
isRunSettingsEnabled = true;
allArgs.Add("--settings:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestSetting));
}

Expand Down Expand Up @@ -233,10 +242,30 @@ internal IEnumerable<string> CreateArgument()
{
foreach (var arg in this.VSTestCollect)
{
if (arg.Equals("Code Coverage", StringComparison.OrdinalIgnoreCase))
{
isCollectCodeCoverageEnabled = true;
}
allArgs.Add("--collect:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg));
}
}

if (isCollectCodeCoverageEnabled || isRunSettingsEnabled)
{

// Pass TraceDataCollector path to vstest.console as TestAdapterPath if --collect "Code Coverage"
// or --settings (User can enable code coverage from runsettings) option given.
// Not parsing the runsettings for two reason:
// 1. To keep no knowledge of runsettings structure in VSTestTask.
// 2. Impact of adding adapter path always is minimal. (worst case: loads additional data collector assembly in datacollector process.)
// This is required due to currently trace datacollector not ships with dotnet sdk, can be remove once we have
// go code coverage x-plat.
if (!string.IsNullOrEmpty(this.VSTestTraceDataCollectorDirectoryPath))
{
allArgs.Add("--testAdapterPath:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestTraceDataCollectorDirectoryPath));
}
}

if (!string.IsNullOrEmpty(this.VSTestBlame))
{
allArgs.Add("--Blame");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<OutputType Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">Exe</OutputType>
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
<AssemblyName>Microsoft.TestPlatform.Build.UnitTests</AssemblyName>
<WarningsAsErrors>true</WarningsAsErrors>
<EnableCodeAnalysis>true</EnableCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.Build\Microsoft.TestPlatform.Build.csproj">
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.TestPlatform.Build.UnitTests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

namespace Microsoft.TestPlatform.Build.UnitTests
{
{
public static class Program
{
public static void Main(string[] args)
Expand Down
Loading