Skip to content

Commit

Permalink
test platform side fix for issue #192 (#232)
Browse files Browse the repository at this point in the history
* test platform side fix for issue #192

* Fix for issue #202

* Removing unusefull double quotes

* Addressed PR comment

* Renamed the task name
  • Loading branch information
Faizan2304 authored Nov 20, 2016
1 parent da8ce17 commit b7e69ff
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.VSTestTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.BuildLogTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />

<!--
============================================================
Expand All @@ -24,14 +25,7 @@ Copyright (c) .NET Foundation. All rights reserved.
============================================================
-->
<Target Name="VSTest" >
<CallTarget Condition="'$(VSTestNoBuild)' != 'true'" Targets="ShowMsbuildWithParameter" />


<MSBuild Condition="'$(VSTestNoBuild)' != 'true'"
Projects ="$(MSBuildProjectFullPath)"
/>

<Message Condition="'$(VSTestNoBuild)' != 'true'" Text="Done Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" Importance="low" />
<CallTarget Condition="'$(VSTestNoBuild)' != 'true'" Targets="BuildProject" />

<CallTarget Targets="ShowCallOfVSTestTaskWithParameter" />

Expand All @@ -40,18 +34,30 @@ Copyright (c) .NET Foundation. All rights reserved.
VSTestSetting="$(VSTestSetting)"
VSTestTestAdapterPath="$(VSTestTestAdapterPath)"
VSTestFramework="$(TargetFrameworkMoniker)"
VSTestPlatform="$(PlatformTarget)"
VSTestTestCaseFilter="$(VSTestTestCaseFilter)"
VSTestLogger="$(VSTestLogger)"
VSTestListTests="$(VSTestListTests)"
VSTestDiag="$(VSTestDiag)"
/>
</Target>

<Target Name="BuildProject">
<CallTarget Targets="ShowMsbuildWithParameter" />

<Microsoft.TestPlatform.Build.Tasks.BuildLogTask BuildStarted="True" />
<MSBuild Projects ="$(MSBuildProjectFullPath)" />
<Microsoft.TestPlatform.Build.Tasks.BuildLogTask />

<Message Text="Done Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" Importance="low" />
</Target>

<Target Name="ShowMsbuildWithParameter">
<Message Text="Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" Importance="low"/>
<Message Text="Value passed to msbuild are..." Importance="low" />
<Message Text="Configuration = $(Configuration)" Importance="low" />
<Message Text="TargetFramework = $(TargetFramework)" Importance="low" />
<Message Text="Platform = $(PlatformTarget)" Importance="low" />
<Message Text="OutputPath = $(OutputPath)" Importance="low" />
</Target>

Expand All @@ -61,6 +67,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<Message Text="VSTestSetting = $(VSTestSetting)" Importance="low" />
<Message Text="VSTestTestAdapterPath = $(VSTestTestAdapterPath)" Importance="low" />
<Message Text="VSTestFramework = $(TargetFrameworkMoniker)" Importance="low" />
<Message Text="VSTestPlatform = $(PlatformTarget)" Importance="low" />
<Message Text="VSTestTestCaseFilter = $(VSTestTestCaseFilter)" Importance="low" />
<Message Text="VSTestLogger = $(VSTestLogger)" Importance="low" />
<Message Text="VSTestListTests = $(VSTestListTests)" Importance="low" />
Expand Down
35 changes: 35 additions & 0 deletions src/Microsoft.TestPlatform.Build/Tasks/PrintBuildStartEndTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

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

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

public class BuildLogTask : Task
{
public bool BuildStarted
{
get;
set;
}

public override bool Execute()
{
if (BuildStarted)
{
Console.WriteLine("Build started, please wait...");
}
else
{
Console.WriteLine("Build completed.");
Console.WriteLine();
}
return true;
}
}
}
11 changes: 11 additions & 0 deletions src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public string VSTestFramework
set;
}

public string VSTestPlatform
{
get;
set;
}

public string VSTestTestCaseFilter
{
get;
Expand Down Expand Up @@ -95,6 +101,11 @@ private IEnumerable<string> CreateArgument()
allArgs.Add("--framework:" + this.AddDoubleQuotes(this.VSTestFramework));
}

if (!string.IsNullOrEmpty(this.VSTestPlatform))
{
allArgs.Add("--platform:" + this.VSTestPlatform);
}

if (!string.IsNullOrEmpty(this.VSTestTestCaseFilter))
{
allArgs.Add("--testCaseFilter:" + this.AddDoubleQuotes(this.VSTestTestCaseFilter));
Expand Down

0 comments on commit b7e69ff

Please sign in to comment.