Moving the Sse max/min tests to use the template.
[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>$(CORE_ROOT)</CoreRootDir>
11     <CoreRootName>Core_Root_$(RuntimeID)</CoreRootName>
12   </PropertyGroup>
13
14   <ItemGroup>
15     <TestCmds Include="$(DiscoveryDirectory)\**\*.cmd" ></TestCmds>
16     <XunitDlls Include="$(DiscoveryDirectory)\**\*.XUnitWrapper.dll" ></XunitDlls>
17     <RequiresSigningFilesToDelete Include="$(DiscoveryDirectory)\**\*.requires_signing" />
18   </ItemGroup>
19
20   <!-- Build the platform-specific wrapper to run an individual xunit wrapper -->
21
22   <Target Name="GenerateWrapperExecutables"
23     Inputs="@(XunitDlls)"
24     Outputs="$(TestWorkingDir)*\runtests.cmd" >
25
26     <MSBuild Projects="helixprep.proj"
27              Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
28              Targets="GenerateWrapperCmd" />
29
30     <MSBuild Projects="helixprep.proj"
31              Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename)%(XunitDlls.Extension)"
32              Targets="GenerateWrapperSh" />
33   </Target>
34
35   <!-- Zip each top-level test folder to send to Helix -->
36
37   <Target Name="ArchiveTests"
38     Inputs="@(XunitDlls)"
39     Outputs="$(TestWorkingDir)archive\**" >
40     
41     <Copy SourceFiles="$(CORE_ROOT)\xunit.console.netcore.exe"
42           DestinationFolder="%(XunitDlls.RootDir)%(XunitDlls.Directory)"
43     />
44     <Message Text="Deleting '.requires_signing' files to avoid file name lengths exceeding MAX_PATH" Importance="Low" />
45     <Delete Files="@(RequiresSigningFilesToDelete)" />
46     <MSBuild Projects="helixprep.proj"
47              Properties="BuildPath=%(XunitDlls.RootDir)%(XunitDlls.Directory);ProjectName=%(XunitDlls.Filename);BuildArchiveDir=$(TestWorkingDir)archive\tests\"
48              BuildInParallel="true"
49              Targets="ArchiveBuild" />
50   </Target>
51
52   <!-- Zip Core_Root & Packages payload to send to Helix -->
53
54   <Target Name="ArchiveCoreRoot"
55     Inputs="$(CoreRootDir)"
56     Outputs="$(TestWorkingDir)archive\Core_Root" >
57     <MSBuild Projects="helixprep.proj"
58              Properties="BuildPath=$(CoreRootDir);ProjectName=$(CoreRootName);BuildArchiveDir=$(TestWorkingDir)archive\Core_Root\"
59              Targets="ArchiveBuild" />
60
61     <!-- Make dummy packages.zip to upload to Helix -->
62     <PropertyGroup>
63       <DummyDir>$(TestWorkingDir)\archive\dummy</DummyDir>
64       <DummyPackageDir>$(TestWorkingDir)\archive\packages</DummyPackageDir>
65     </PropertyGroup>
66
67     <MakeDir Directories="$(DummyDir)" />
68     <MakeDir Directories="$(DummyPackageDir)" />
69     <ZipFileCreateFromDirectory SourceDirectory="$(DummyDir)" DestinationArchive="$(DummyPackageDir)\Packages.zip" OverwriteDestination="true" />
70   </Target>
71
72   <!-- Generate wrapper .cmd file for an Xunit wrapper -->
73   <Target Name="GenerateWrapperCmd"
74     Condition="'$(TargetsWindows)' == 'true' ">
75
76     <PropertyGroup>
77       <CmdCrossgenVar Condition="'$(Crossgen)' == 'true'">set RunCrossGen=true</CmdCrossgenVar>
78       <WrapperCmdContents>
79         <![CDATA[
80 @ECHO OFF
81 setlocal ENABLEDELAYEDEXPANSION
82 pushd %~dp0
83
84 set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD%
85 $(CmdCrossgenVar)
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="'$(TargetsWindows)' != 'true' ">
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="%24HELIX_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
122       <!-- Crossgen FX assemblies, if running R2R tests. 
123       TODO - remove this when we build tests on Linux -->
124       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)export RunCrossGen=true%0a</WrapperShContents>
125       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)overlayDir=%24CORE_ROOT%0a</WrapperShContents>
126       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)if [ ! -f %24overlayDir/crossgenCompleted.mrk ]%3B then%0a</WrapperShContents>
127       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)  filesToPrecompile=%24(find -L %24overlayDir -iname \%2A.dll -not -iname \%2A.ni.dll -not -iname \%2A-ms-win-\%2A -type f )%0a</WrapperShContents>
128       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)  for fileToPrecompile in %24{filesToPrecompile}%0a</WrapperShContents>
129       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)  do%0a</WrapperShContents>
130       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    filename=%24{fileToPrecompile}%0a</WrapperShContents>
131       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    echo Precompiling %24filename%0a</WrapperShContents>
132       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    %24overlayDir/crossgen /Platform_Assemblies_Paths %24overlayDir /in %24filename /out %24overlayDir/temp.ni.dll 1> %24filename.stdout 2>%24filename.stderr%0a</WrapperShContents>
133       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    exitCode=%24%3F%0a</WrapperShContents>
134       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    if [ %24exitCode != 0 ]%3B then%0a</WrapperShContents>
135       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)      if grep -q -e '(COR_E_ASSEMBLYEXPECTED)' %24filename.stderr%3B then%0a</WrapperShContents>
136       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)        printf "\n\t%24filename is not a managed assembly.\n\n"%0a</WrapperShContents>
137       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)      else%0a</WrapperShContents>
138       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)        echo Unable to precompile %24filename.%0a</WrapperShContents>
139       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)      fi%0a</WrapperShContents>
140       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    else%0a</WrapperShContents>
141       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)      rm %24filename%0a</WrapperShContents>
142       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)      mv %24overlayDir/temp.ni.dll %24filename%0a</WrapperShContents>
143       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    fi%0a</WrapperShContents> 
144       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    rm %24filename.stdout%0a</WrapperShContents>
145       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)    rm %24filename.stderr%0a</WrapperShContents>
146       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)  done%0a</WrapperShContents>
147       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)  touch %24overlayDir/crossgenCompleted.mrk%0a</WrapperShContents>
148       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)fi%0a</WrapperShContents>
149       <WrapperShContents Condition="'$(Crossgen)' == 'true'">$(WrapperShContents)%0a</WrapperShContents>
150
151       <WrapperShContents>$(WrapperShContents)echo BEGIN EXECUTION%0a</WrapperShContents>
152       <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>
153       <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>
154       <WrapperShContents>$(WrapperShContents)ErrorLevel=%24%3F%0a</WrapperShContents>
155       <WrapperShContents>$(WrapperShContents)%0a</WrapperShContents>
156       <WrapperShContents>$(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a</WrapperShContents>
157       <WrapperShContents>$(WrapperShContents)exit %24ErrorLevel%0a</WrapperShContents>
158
159     </PropertyGroup>
160
161     <!-- Write the file -->
162     <WriteLinesToFile
163       File="$(BuildPath)\runtests.sh"
164       Lines="$(WrapperShContents)"
165       Overwrite="true" />
166
167   </Target>
168
169   <!-- archive the test binaries along with some supporting files -->
170   <Target Name="ArchiveBuild">
171     <PropertyGroup Condition="'$(ProjectName)'==''">
172       <TestProjectName>$(MSBuildProjectName)</TestProjectName>
173     </PropertyGroup>
174
175     <!-- the project json and runner script files need to be included in the archive -->
176     <MakeDir Directories="$(BuildArchiveDir)" />
177     <ZipFileCreateFromDirectory SourceDirectory="$(BuildPath)" DestinationArchive="$(BuildArchiveDir)$(ProjectName).zip" OverwriteDestination="true" />
178   </Target>
179
180   <!-- Default target to run - builds executables & archives everything needed for Helix run -->
181
182   <Target Name="ArchiveAll" >
183     <MSBuild Projects="helixprep.proj"
184              Targets="GenerateWrapperExecutables;ArchiveTests;ArchiveCoreRoot" />
185   </Target>
186
187 </Project>