-
Notifications
You must be signed in to change notification settings - Fork 325
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
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4f30aed
Enclosing run settings arguments to handle whitespace.
1703465
Merge branch 'master' into buildtask
harshjain2 56963d5
Added Tests.
b000a8c
Fixes for test.cmd to work
baeb6bb
Merge branch 'master' into buildtask
harshjain2 4704848
Merge branch 'master' into buildtask
harshjain2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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>(); | ||
|
||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 + "\""; | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
test/Microsoft.TestPlatform.Build.UnitTests/Microsoft.TestPlatform.Build.UnitTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?