forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.targets
More file actions
127 lines (100 loc) · 6.65 KB
/
tests.targets
File metadata and controls
127 lines (100 loc) · 6.65 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<Project>
<PropertyGroup>
<TargetOS Condition="'$(TargetOS)' == ''">$(DefaultOSGroup)</TargetOS>
<RunWorkingDirectory>$(OutDir)</RunWorkingDirectory>
<RunScriptInputName Condition="'$(TargetOS)' == 'Windows_NT'">RunnerTemplate.Windows.txt</RunScriptInputName>
<RunScriptInputName Condition="'$(TargetOS)' != 'Windows_NT'">RunnerTemplate.Unix.txt</RunScriptInputName>
<RunScriptInputPath>$(MSBuildThisFileDirectory)$(RunScriptInputName)</RunScriptInputPath>
<RunScriptOutputName Condition="'$(TargetOS)' == 'Windows_NT'">RunTests.cmd</RunScriptOutputName>
<RunScriptOutputName Condition="'$(TargetOS)' != 'Windows_NT'">RunTests.sh</RunScriptOutputName>
<RunScriptOutputPath>$([MSBuild]::NormalizePath('$(OutDir)', '$(RunScriptOutputName)'))</RunScriptOutputPath>
<RunScriptHostDir Condition="'$(TargetOS)' == 'Windows_NT'">%RUNTIME_PATH%\</RunScriptHostDir>
<RunScriptHostDir Condition="'$(TargetOS)' != 'Windows_NT'">$RUNTIME_PATH/</RunScriptHostDir>
<RunScriptHost Condition="'$(TargetOS)' == 'Windows_NT'">$(RunScriptHostDir)dotnet.exe</RunScriptHost>
<RunScriptHost Condition="'$(TargetOS)' != 'Windows_NT'">$(RunScriptHostDir)dotnet</RunScriptHost>
</PropertyGroup>
<!-- Archive test binaries. -->
<Target Name="ArchiveTests"
Condition="'$(ArchiveTests)' == 'true' and '$(IgnoreForCI)' != 'true'"
AfterTargets="PrepareForRun"
DependsOnTargets="GenerateRunScript">
<Error Condition="'$(TestArchiveTestsDir)' == ''" Text="TestArchiveTestsDir property to archive the test folder must be set." />
<MakeDir Directories="$(TestArchiveTestsDir)" />
<ZipDirectory SourceDirectory="$(OutDir)"
DestinationFile="$([MSBuild]::NormalizePath('$(TestArchiveTestsDir)', '$(TestProjectName).zip'))"
Overwrite="true" />
</Target>
<UsingTask TaskName="GenerateRunScript" AssemblyFile="$(InstallerTasksAssemblyPath)"/>
<Target Name="GenerateRunScript">
<PropertyGroup>
<!-- RSP file support. -->
<RunArguments Condition="'$(TargetOS)' == 'Windows_NT'">$(RunArguments) %RSP_FILE%</RunArguments>
<RunArguments Condition="'$(TargetOS)' != 'Windows_NT'">$(RunArguments) $RSP_FILE</RunArguments>
<!-- Escape arguments with user inputs. -->
<RunArguments>$([MSBuild]::Escape('$(RunArguments)'))</RunArguments>
<RunScriptCommand Condition="'$(RunScriptCommand)' == ''">$(RunCommand) $(RunArguments)</RunScriptCommand>
</PropertyGroup>
<!-- Set $(TestDebugger) to eg c:\debuggers\windbg.exe to run tests under a debugger. -->
<PropertyGroup Condition="'$(TestDebugger)' != ''">
<RunScriptCommand Condition="!$(TestDebugger.Contains('devenv'))">$(TestDebugger) $(RunScriptCommand)</RunScriptCommand>
<RunScriptCommand Condition=" $(TestDebugger.Contains('devenv'))">$(TestDebugger) /debugexe $(RunScriptCommand)</RunScriptCommand>
</PropertyGroup>
<ItemGroup>
<!--
If the PreExecutionTestScript property is set, then it should be set to the full path to a script that will be directly incorporated
into the generated runtests script, immediately before the test is run. This can be used to set a number of JIT stress modes,
for example. It is intended that this be as late as possible in the generated script, as close as possible to the running of the
test. That is why this doesn't appear higher in this file. The idea is that if the included script alters managed code behavior, such as
setting various JIT stress modes, we don't want those changes to affect any other managed code invocation (such as test infrastructure
written in managed code).
-->
<RunScriptCommands Condition="'$(PreExecutionTestScript)' != ''" Include="$([System.IO.File]::ReadAllText('$(PreExecutionTestScript)'))" />
<RunScriptCommands Include="$(RunScriptCommand)" />
<!-- Do not put anything between this and the GenerateRunScript invocation. -->
<RunScriptCommands Include="@(PostRunScriptCommands)" />
</ItemGroup>
<GenerateRunScript RunCommands="@(RunScriptCommands)"
TemplatePath="$(RunScriptInputPath)"
OutputPath="$(RunScriptOutputPath)" />
<Exec Condition="'$(TargetOS)' != 'Windows_NT'" Command="chmod +x $(RunScriptOutputPath)" />
</Target>
<Target Name="ValidateTestPlatform">
<ItemGroup>
<UnsupportedPlatformsItems Include="$(UnsupportedPlatforms)" />
</ItemGroup>
<PropertyGroup>
<TestDisabled Condition="'%(UnsupportedPlatformsItems.Identity)' == '$(TargetOS)' or '$(ConfigurationErrorMsg)' != ''">true</TestDisabled>
</PropertyGroup>
<Message Text="ValidateTestPlatform found TargetOS of [$(TargetOS)]." Importance="Low" />
<Message Condition="'%(UnsupportedPlatformsItems.Identity)' == '$(TargetOS)'"
Text="Skipping tests in $(AssemblyName) because it is not supported on $(TargetOS)" />
<Message Condition="'$(ConfigurationErrorMsg)' != ''"
Text="Skipping tests in $(AssemblyName) because there is no configuration compatible with the current BuildConfiguration." />
</Target>
<Target Name="RunTests"
Condition="'$(TestDisabled)' != 'true'"
DependsOnTargets="ValidateTestPlatform">
<Error Condition="!Exists('$(TargetPath)')"
Text="Test assembly couldn't be found. Make sure to build the test project first." />
<PropertyGroup>
<RunTestsCommand>"$(RunScriptOutputPath)" --runtime-path "$(TestHostRootPath.TrimEnd('\/'))"</RunTestsCommand>
<RunTestsCommand Condition="'$(TestRspFile)' != ''">$(RunTestsCommand) --rsp-file "$(TestRspFile)"</RunTestsCommand>
</PropertyGroup>
<!-- Invoke the run script with the test host as the runtime path. -->
<Exec Command="$(RunTestsCommand)"
ContinueOnError="true"
IgnoreStandardErrorWarningFormat="true">
<Output PropertyName="TestRunExitCode" TaskParameter="ExitCode" />
</Exec>
<PropertyGroup>
<TestRunErrorMessage>One or more tests failed while running tests from '$(TestProjectName)'.</TestRunErrorMessage>
<TestRunErrorMessage Condition="Exists('$(TestResultsPath)')">$(TestRunErrorMessage) Please check $(TestResultsPath) for details!</TestRunErrorMessage>
</PropertyGroup>
<Error Condition="'$(TestRunExitCode)' != '0'" Text="$(TestRunErrorMessage)" />
</Target>
<Import Project="$(MSBuildThisFileDirectory)xunit\xunit.targets" Condition="'$(TestFramework)' == 'xunit'" />
<!-- Main test targets -->
<Target Name="Test" DependsOnTargets="GenerateRunScript;RunTests" />
<Target Name="BuildAndTest" DependsOnTargets="Build;Test" />
<Target Name="RebuildAndTest" DependsOnTargets="Rebuild;Test" />
</Project>