forked from dotnet/coreclr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CLRTest.Execute.targets
109 lines (93 loc) · 4.46 KB
/
CLRTest.Execute.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!--
***********************************************************************************************
CLRTest.Execute.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file contains the logic for providing Execution Script generation.
***********************************************************************************************
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
*******************************************************************************************
PROPERTIES/ITEMS: Used when prepping a test for execution
-->
<!-- Temporary Defaults -->
<PropertyGroup>
<_CLRTestNeedsToRun Condition=" '$(_CLRTestNeedsToRun)' == '' ">true</_CLRTestNeedsToRun>
<_CLRTestBuildsExecutable Condition=" '$(_CLRTestBuildsExecutable)' == '' ">true</_CLRTestBuildsExecutable>
<CLRTestIsHosted Condition=" '$(CLRTestIsHosted)' == '' ">true</CLRTestIsHosted>
<_CLRTestNeedsProjectToRun Condition=" '$(_CLRTestNeedsProjectToRun)' == '' ">false</_CLRTestNeedsProjectToRun>
</PropertyGroup>
<PropertyGroup>
<!-- TODO:1 Get the right guidance for overriding the default -->
<CLRTestExitCode Condition=" '$(CLRTestExitCode)' == '' ">100</CLRTestExitCode>
</PropertyGroup>
<ItemDefinitionGroup>
<CLRTestExecutionScriptArgument>
<HasParam>false</HasParam>
</CLRTestExecutionScriptArgument>
</ItemDefinitionGroup>
<!--
TASK: GenerateParamList
This task takes a list of CLRTestExecutionScriptArgument items and
returns a string fit for the usage help message.
example:
[-arg1 param1] [-arg2] [-arg3 param3]
-->
<UsingTask
TaskName="GenerateParamList"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<ArgumentItems ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true"/>
<ParamList ParameterType="System.String" Output="true"/>
</ParameterGroup>
<Task>
<Reference Include="System.Core"/>
<Using Namespace="System"/>
<Using Namespace="System.Linq"/>
<Code Type="Fragment" Language="cs"><![CDATA[
Func<string, bool> parseBool = s =>
{
bool value;
var success = bool.TryParse(s, out value);
if (success)
return value;
return false;
};
var items = ArgumentItems.Select(i => new { Item=i, HasParam=parseBool(i.GetMetadata("HasParam"))});
var noArg = items.Where(i => !i.HasParam).Select(i => new { Identity=i.Item.ItemSpec});
var haveArg = items.Where(i => i.HasParam).Select(i => new { Identity=i.Item.ItemSpec, Name=i.Item.GetMetadata("ParamName")});
ParamList = haveArg.Aggregate("", (s,i) => string.Format("{0} [-{1} {2}]", s, i.Identity, i.Name)) +
noArg.Aggregate("", (s,i) => string.Format("{0} [-{1}]", s, i.Identity));
]]>
</Code>
</Task>
</UsingTask>
<!--
*******************************************************************************************
TARGET: GenerateExecutionScript
TODO: get rid of this!
The PreCheckin system depends directly on this target (boo). This makes sure the script ends up in the right place.
-->
<Target Name="GenerateExecutionScript"
DependsOnTargets="GenerateExecutionScriptsInternal"/>
<!--
*******************************************************************************************
TARGET: GenerateExecutionScriptsInternal
For tests that "run" we will generate an execution script that wraps any arguments or other
goo. This allows generated .lst files to be very simple and reusable to invoke any "stage"
of test execution.
Notice this is hooked up to run after targets that generate the stores that are marked with GenerateScripts metadata.
Note also that this means it will run after the first of such targets.
-->
<ItemGroup>
<ExecutionScriptKind Include="Batch" />
<ExecutionScriptKind Include="Bash" />
</ItemGroup>
<Import Project="CLRTest.Execute.*.targets" />
<Target Name="GenerateExecutionScriptsInternal"
Condition="$(_CLRTestNeedsToRun) or $(_CLRTestBuildsExecutable)"
DependsOnTargets="Generate@(ExecutionScriptKind, 'ExecutionScript;Generate')ExecutionScript;" />
</Project>