Merge pull request #10776 from sdmaclea/PR-ARM64-CpBlkUnroll
[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)\net46\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              BuildInParallel="true"
51              Targets="ArchiveBuild" />
52   </Target>
53
54   <!-- Zip Core_Root & Packages payload to send to Helix -->
55
56   <Target Name="ArchiveCoreRoot"
57     Inputs="$(CoreRootDir)"
58     Outputs="$(TestWorkingDir)archive\Core_Root" >
59     <MSBuild Projects="helixprep.proj"
60              Properties="BuildPath=$(CoreRootDir);ProjectName=$(CoreRootName);BuildArchiveDir=$(TestWorkingDir)archive\Core_Root\"
61              Targets="ArchiveBuild" />
62
63     <!-- Make dummy packages.zip to upload to Helix -->
64     <PropertyGroup>
65       <DummyDir>$(TestWorkingDir)\archive\dummy</DummyDir>
66       <DummyPackageDir>$(TestWorkingDir)\archive\packages</DummyPackageDir>
67     </PropertyGroup>
68
69     <MakeDir Directories="$(DummyDir)" />
70     <MakeDir Directories="$(DummyPackageDir)" />
71     <ZipFileCreateFromDirectory SourceDirectory="$(DummyDir)" DestinationArchive="$(DummyPackageDir)\Packages.zip" OverwriteDestination="true" />
72   </Target>
73
74   <!-- Generate wrapper .cmd file for an Xunit wrapper -->
75   <Target Name="GenerateWrapperCmd"
76     Condition="'$(RuntimeID)' == '' ">
77
78     <PropertyGroup>
79       <WrapperCmdContents>
80         <![CDATA[
81 @ECHO OFF
82 setlocal ENABLEDELAYEDEXPANSION
83 pushd %~dp0
84
85 set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD%
86
87 ECHO BEGIN EXECUTION
88 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
89 %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
90
91 echo Finished running tests. Exit code = %ERRORLEVEL%
92 EXIT /B %ERRORLEVEL%
93
94         ]]>
95       </WrapperCmdContents>
96     </PropertyGroup>
97
98     <!-- Write the file -->
99     <WriteLinesToFile
100       File="$(BuildPath)\runtests.cmd"
101       Lines="$(WrapperCmdContents)"
102       Overwrite="true" />
103
104   </Target>
105
106   <Target Name="GenerateWrapperSh"
107     Condition="'$(RuntimeID)' != '' ">
108
109     <!-- Need to force in Unix line endings for Shell script -->
110     <PropertyGroup>
111       <WrapperShContents>#!/bin/sh%0a</WrapperShContents>
112       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents> 
113       <WrapperShContents>$(WrapperShContents)export CORE_ROOT="$HELIX_CORRELATION_PAYLOAD"%0a</WrapperShContents>
114       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
115       <WrapperShContents>$(WrapperShContents)for scriptFilePath in %24(find . -type f -iname '%2A.sh' ! -iname "runtests.sh" | sort)%0a</WrapperShContents>
116       <WrapperShContents>$(WrapperShContents)do%0a</WrapperShContents>
117       <WrapperShContents>$(WrapperShContents) perl -pi -e 's/\r\n|\n|\r/\n/g' "%24scriptFilePath"%0a</WrapperShContents>
118       <WrapperShContents>$(WrapperShContents) chmod +x "%24scriptFilePath"%0a</WrapperShContents>
119       <WrapperShContents>$(WrapperShContents)done%0a</WrapperShContents>
120       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
121       <WrapperShContents>$(WrapperShContents)echo BEGIN EXECUTION%0a</WrapperShContents>
122       <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>
123       <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>
124       <WrapperShContents>$(WrapperShContents)ErrorLevel=%24%3F%0a</WrapperShContents>
125       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
126       <WrapperShContents>$(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a</WrapperShContents>
127       <WrapperShContents>$(WrapperShContents)exit %24ErrorLevel%0a</WrapperShContents>
128
129     </PropertyGroup>
130
131     <!-- Write the file -->
132     <WriteLinesToFile
133       File="$(BuildPath)\runtests.sh"
134       Lines="$(WrapperShContents)"
135       Overwrite="true" />
136
137   </Target>
138
139   <!-- archive the test binaries along with some supporting files -->
140   <Target Name="ArchiveBuild">
141     <PropertyGroup Condition="'$(ProjectName)'==''">
142       <TestProjectName>$(MSBuildProjectName)</TestProjectName>
143     </PropertyGroup>
144
145     <!-- the project json and runner script files need to be included in the archive -->
146     <MakeDir Directories="$(BuildArchiveDir)" />
147     <ZipFileCreateFromDirectory SourceDirectory="$(BuildPath)" DestinationArchive="$(BuildArchiveDir)$(ProjectName).zip" OverwriteDestination="true" />
148   </Target>
149
150   <!-- Default target to run - builds executables & archives everything needed for Helix run -->
151
152   <Target Name="ArchiveAll" >
153     <MSBuild Projects="helixprep.proj"
154              Targets="GenerateWrapperExecutables;ArchiveTests;ArchiveCoreRoot" />
155   </Target>
156
157 </Project>