Merge pull request #8778 from dnickless/master
[platform/upstream/coreclr.git] / tests / helixprep.proj
1 <Project ToolsVersion="12.0" DefaultTargets="ArchiveAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
3   <UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(ToolsDir)\net45\Microsoft.DotNet.Build.Tasks.dll"/>
4   
5   <Import Project="dir.props" />
6   <Import Project="..\dir.props" />
7
8   <PropertyGroup>
9     <DiscoveryDirectory>$(TestWorkingDir)</DiscoveryDirectory>
10     <CoreRootDir Condition="'$(RuntimeID)' == '' ">$(CORE_ROOT)</CoreRootDir>
11     <CoreRootDir Condition="'$(RuntimeID)' != '' ">$(CORE_OVERLAY)</CoreRootDir>
12     <CoreRootName Condition="'$(RuntimeID)' == '' ">Core_Root_Windows_NT-$(__BuildArch)</CoreRootName>
13     <CoreRootName Condition="'$(RuntimeID)' != '' ">Core_Root_$(RuntimeID)</CoreRootName>
14   </PropertyGroup>
15
16   <ItemGroup>
17     <TestCmds Include="$(DiscoveryDirectory)\**\*.cmd" ></TestCmds>
18     <XunitDlls Include="$(DiscoveryDirectory)\*\*.XUnitWrapper.dll" ></XunitDlls>
19     <RequiresSigningFilesToDelete Include="$(DiscoveryDirectory)\**\*.requires_signing" />
20   </ItemGroup>
21
22   <!-- Build the platform-specific wrapper to run an individual xunit wrapper -->
23
24   <Target Name="GenerateWrapperExecutables"
25     Inputs="@(XunitDlls)"
26     Outputs="$(TestWorkingDir)*\runtests.cmd" >
27
28     <MSBuild Projects="helixprep.proj"
29              Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
30              Targets="GenerateWrapperCmd" />
31
32     <MSBuild Projects="helixprep.proj"
33              Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
34              Targets="GenerateWrapperSh" />
35   </Target>
36
37   <!-- Zip each top-level test folder to send to Helix -->
38
39   <Target Name="ArchiveTests"
40     Inputs="@(XunitDlls)"
41     Outputs="$(TestWorkingDir)archive\**" >
42     
43     <Copy SourceFiles="$(CORE_ROOT)\xunit.console.netcore.exe"
44           DestinationFolder="%(XunitDlls.RootDir)%(XunitDlls.Directory)"
45     />
46     <Message Text="Deleting '.requires_signing' files to avoid file name lengths exceeding MAX_PATH" Importance="Low" />
47     <Delete Files="@(RequiresSigningFilesToDelete)" />
48     <MSBuild Projects="helixprep.proj"
49              Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename);BuildArchiveDir=$(TestWorkingDir)archive\tests\"
50              Targets="ArchiveBuild" />
51   </Target>
52
53   <!-- Zip Core_Root & Packages payload to send to Helix -->
54
55   <Target Name="ArchiveCoreRoot"
56     Inputs="$(CoreRootDir)"
57     Outputs="$(TestWorkingDir)archive\Core_Root" >
58     <MSBuild Projects="helixprep.proj"
59              Properties="BuildPath=$(CoreRootDir);ProjectName=$(CoreRootName);BuildArchiveDir=$(TestWorkingDir)archive\Core_Root\"
60              Targets="ArchiveBuild" />
61
62     <!-- Make dummy packages.zip to upload to Helix -->
63     <PropertyGroup>
64       <DummyDir>$(TestWorkingDir)\archive\dummy</DummyDir>
65       <DummyPackageDir>$(TestWorkingDir)\archive\packages</DummyPackageDir>
66     </PropertyGroup>
67
68     <MakeDir Directories="$(DummyDir)" />
69     <MakeDir Directories="$(DummyPackageDir)" />
70     <ZipFileCreateFromDirectory SourceDirectory="$(DummyDir)" DestinationArchive="$(DummyPackageDir)\Packages.zip" OverwriteDestination="true" />
71   </Target>
72
73   <!-- Generate wrapper .cmd file for an Xunit wrapper -->
74   <Target Name="GenerateWrapperCmd"
75     Condition="'$(RuntimeID)' == '' ">
76
77     <PropertyGroup>
78       <WrapperCmdContents>
79         <![CDATA[
80 @ECHO OFF
81 setlocal ENABLEDELAYEDEXPANSION
82 pushd %~dp0
83
84 set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD%
85
86 ECHO BEGIN EXECUTION
87 ECHO %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing
88 %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing
89
90 echo Finished running tests. Exit code = %ERRORLEVEL%
91 EXIT /B %ERRORLEVEL%
92
93         ]]>
94       </WrapperCmdContents>
95     </PropertyGroup>
96
97     <!-- Write the file -->
98     <WriteLinesToFile
99       File="$(BuildPath)\runtests.cmd"
100       Lines="$(WrapperCmdContents)"
101       Overwrite="true" />
102
103   </Target>
104
105   <Target Name="GenerateWrapperSh"
106     Condition="'$(RuntimeID)' != '' ">
107
108     <!-- Need to force in Unix line endings for Shell script -->
109     <PropertyGroup>
110       <WrapperShContents>#!/bin/sh%0a</WrapperShContents>
111       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents> 
112       <WrapperShContents>$(WrapperShContents)export CORE_ROOT="$HELIX_CORRELATION_PAYLOAD"%0a</WrapperShContents>
113       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
114       <WrapperShContents>$(WrapperShContents)for scriptFilePath in %24(find . -type f -iname '%2A.sh' ! -iname "runtests.sh" | sort)%0a</WrapperShContents>
115       <WrapperShContents>$(WrapperShContents)do%0a</WrapperShContents>
116       <WrapperShContents>$(WrapperShContents) perl -pi -e 's/\r\n|\n|\r/\n/g' "%24scriptFilePath"%0a</WrapperShContents>
117       <WrapperShContents>$(WrapperShContents) chmod +x "%24scriptFilePath"%0a</WrapperShContents>
118       <WrapperShContents>$(WrapperShContents)done%0a</WrapperShContents>
119       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
120       <WrapperShContents>$(WrapperShContents)echo BEGIN EXECUTION%0a</WrapperShContents>
121       <WrapperShContents>$(WrapperShContents)echo "%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a</WrapperShContents>
122       <WrapperShContents>$(WrapperShContents)"%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a</WrapperShContents>
123       <WrapperShContents>$(WrapperShContents)ErrorLevel=%24%3F%0a</WrapperShContents>
124       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
125       <WrapperShContents>$(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a</WrapperShContents>
126       <WrapperShContents>$(WrapperShContents)exit %24ErrorLevel%0a</WrapperShContents>
127
128     </PropertyGroup>
129
130     <!-- Write the file -->
131     <WriteLinesToFile
132       File="$(BuildPath)\runtests.sh"
133       Lines="$(WrapperShContents)"
134       Overwrite="true" />
135
136   </Target>
137
138   <!-- archive the test binaries along with some supporting files -->
139   <Target Name="ArchiveBuild">
140     <PropertyGroup Condition="'$(ProjectName)'==''">
141       <TestProjectName>$(MSBuildProjectName)</TestProjectName>
142     </PropertyGroup>
143
144     <!-- the project json and runner script files need to be included in the archive -->
145     <MakeDir Directories="$(BuildArchiveDir)" />
146     <ZipFileCreateFromDirectory SourceDirectory="$(BuildPath)" DestinationArchive="$(BuildArchiveDir)$(ProjectName).zip" OverwriteDestination="true" />
147   </Target>
148
149   <!-- Default target to run - builds executables & archives everything needed for Helix run -->
150
151   <Target Name="ArchiveAll" >
152     <MSBuild Projects="helixprep.proj"
153              Targets="GenerateWrapperExecutables;ArchiveTests;ArchiveCoreRoot" />
154   </Target>
155
156 </Project>