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

Enclosing run settings arguments to handle whitespace. #312

Merged
merged 6 commits into from
Jan 6, 2017
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
33 changes: 24 additions & 9 deletions TestPlatform.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26014.0
VisualStudioVersion = 15.0.26009.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED0C35EB-7F31-4841-A24F-8EB708FFA959}"
EndProject
Expand Down Expand Up @@ -122,6 +122,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Prot
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleTestProject3", "test\TestAssets\SimpleTestProject3\SimpleTestProject3.csproj", "{82E75225-FA92-4F87-909D-039D62F96BFF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Build.UnitTests", "test\Microsoft.TestPlatform.Build.UnitTests\Microsoft.TestPlatform.Build.UnitTests.csproj", "{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -182,16 +184,16 @@ Global
{2820F090-3F3D-4DA2-8CBA-B8273D695333}.Release|x86.Build.0 = Release|x86
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x64.ActiveCfg = Debug|x64
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x64.Build.0 = Debug|x64
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x86.ActiveCfg = Debug|x86
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x86.Build.0 = Debug|x86
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x64.ActiveCfg = Debug|Any CPU
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change required?

{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x64.Build.0 = Debug|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x86.ActiveCfg = Debug|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Debug|x86.Build.0 = Debug|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|Any CPU.Build.0 = Release|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x64.ActiveCfg = Release|x64
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x64.Build.0 = Release|x64
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x86.ActiveCfg = Release|x86
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x86.Build.0 = Release|x86
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x64.ActiveCfg = Release|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x64.Build.0 = Release|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x86.ActiveCfg = Release|Any CPU
{6F5EC38C-4A11-40D3-827C-F607B90BEFF0}.Release|x86.Build.0 = Release|Any CPU
{E19B5128-3469-492E-82E1-725631C4A68C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E19B5128-3469-492E-82E1-725631C4A68C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E19B5128-3469-492E-82E1-725631C4A68C}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -672,6 +674,18 @@ Global
{82E75225-FA92-4F87-909D-039D62F96BFF}.Release|x64.Build.0 = Release|Any CPU
{82E75225-FA92-4F87-909D-039D62F96BFF}.Release|x86.ActiveCfg = Release|Any CPU
{82E75225-FA92-4F87-909D-039D62F96BFF}.Release|x86.Build.0 = Release|Any CPU
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Debug|x64.ActiveCfg = Debug|x64
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Debug|x64.Build.0 = Debug|x64
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Debug|x86.ActiveCfg = Debug|x86
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Debug|x86.Build.0 = Debug|x86
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Release|Any CPU.Build.0 = Release|Any CPU
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Release|x64.ActiveCfg = Release|x64
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Release|x64.Build.0 = Release|x64
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Release|x86.ActiveCfg = Release|x86
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -728,5 +742,6 @@ Global
{D62D754C-8F0A-406F-8BA7-E96C6FFA7C7C} = {8DA7CBD9-F17E-41B6-90C4-CFF55848A25A}
{97DD9467-B011-4736-AAC4-2C21BF554349} = {B9AB7A3D-4F63-48D2-86C0-70F52F6509AB}
{82E75225-FA92-4F87-909D-039D62F96BFF} = {8DA7CBD9-F17E-41B6-90C4-CFF55848A25A}
{EFA38DEF-C2BB-42AE-8B68-B31D79F3107E} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Build/Friends.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Runtime.CompilerServices;

#region Test Assemblies

[assembly: InternalsVisibleTo("Microsoft.TestPlatform.Build.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]

#endregion
26 changes: 15 additions & 11 deletions src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

namespace Microsoft.TestPlatform.Build.Tasks
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
using System.IO;
using System.Diagnostics;

using Trace;

public class VSTestTask : Task, ICancelableTask
Expand Down Expand Up @@ -96,12 +97,7 @@ public void Cancel()
vsTestForwardingApp.Cancel();
}

private string AddDoubleQuotes(string x)
{
return "\"" + x + "\"";
}

private IEnumerable<string> CreateArgument()
internal IEnumerable<string> CreateArgument()
{
var allArgs = new List<string>();

Expand Down Expand Up @@ -165,13 +161,21 @@ private IEnumerable<string> CreateArgument()
}
}

if (this.VSTestCLIRunSettings!=null && this.VSTestCLIRunSettings.Length>0)
if (this.VSTestCLIRunSettings != null && this.VSTestCLIRunSettings.Length > 0)
{
allArgs.Add("--");
allArgs.AddRange(this.VSTestCLIRunSettings);
foreach (var arg in this.VSTestCLIRunSettings)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need test coverage?

{
allArgs.Add(this.AddDoubleQuotes(arg));
}
}

return allArgs;
}

private string AddDoubleQuotes(string x)
{
return "\"" + x + "\"";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TestPlatformRoot Condition="$(TestPlatformRoot) == ''">$(MSBuildThisFileDirectory)../../</TestPlatformRoot>
<TestProject>true</TestProject>
</PropertyGroup>
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<OutputType Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">Exe</OutputType>
<TargetFrameworks>netcoreapp1.0;net46</TargetFrameworks>
<AssemblyName>Microsoft.TestPlatform.Build.UnitTests</AssemblyName>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
<EmbeddedResource Include="compiler\resources\**\*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.Build\Microsoft.TestPlatform.Build.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework">
<Version>15.1.0-preview-000458-02</Version>
</PackageReference>
<PackageReference Include="Microsoft.Build.Utilities.Core">
<Version>15.1.0-preview-000458-02</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System.Runtime" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(TestPlatformRoot)scripts\build\TestPlatform.targets" />
</Project>
11 changes: 11 additions & 0 deletions test/Microsoft.TestPlatform.Build.UnitTests/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.

namespace Microsoft.TestPlatform.Build.UnitTests
{
public static class Program
{
public static void Main(string[] args)
{
}
}
}
33 changes: 33 additions & 0 deletions test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft. All rights reserved.

namespace Microsoft.TestPlatform.Build.UnitTests
{
using System.Linq;

using Microsoft.TestPlatform.Build.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class VsTestTaskTests
{
[TestMethod]
public void CreateArgumentShouldAddDoubleQuotesForCLIRunSettings()
{
const string arg1 = "RunConfiguration.ResultsDirectory=Path having Space";
const string arg2 = "MSTest.DeploymentEnabled";
var vstestTask = new VSTestTask { VSTestCLIRunSettings = new string[2] };
vstestTask.VSTestCLIRunSettings[0] = arg1;
vstestTask.VSTestCLIRunSettings[1] = arg2;

// Add values for required properties.
vstestTask.TestFileFullPath = "abc";
vstestTask.VSTestFramework = "abc";

var result = vstestTask.CreateArgument().ToArray();

// First, second and third args would be --framework:abc, testfilepath and -- respectively.
Assert.AreEqual($"\"{arg1}\"", result[3]);
Assert.AreEqual($"\"{arg2}\"", result[4]);
}
}
}