Fix to add error checks for crossgen compilation
authorGaurav Khanna <gkhanna@microsoft.com>
Mon, 28 Mar 2016 17:54:20 +0000 (10:54 -0700)
committerGaurav Khanna <gkhanna@microsoft.com>
Mon, 4 Apr 2016 14:43:27 +0000 (07:43 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/be17b1f867a15164911503850f562739fabbaf9f

src/coreclr/tests/src/CLRTest.Execute.Bash.targets
src/coreclr/tests/src/CLRTest.Execute.Batch.targets

index 08fe480..d4bef47 100644 (file)
@@ -19,9 +19,9 @@ WARNING:   When setting properties based on their current state (for example:
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 
   <ItemGroup>
-    <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="complus_zaprequire=2" />
-    <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="complus_zaprequireexcludelist=corerun" />
-    <CLRTestBashEnvironmentVariable Condition="'$(GCStressLevel)' != '' and '$(GCStressLevel)' != '0'" Include="complus_gcstress=$(GCStressLevel)" />
+    <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="export complus_zaprequire=2" />
+    <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="export complus_zaprequireexcludelist=corerun" />
+    <CLRTestBashEnvironmentVariable Condition="'$(GCStressLevel)' != '' and '$(GCStressLevel)' != '0'" Include="export complus_gcstress=$(GCStressLevel)" />
   </ItemGroup>
 
     <!--
@@ -38,7 +38,13 @@ WARNING:   When setting properties based on their current state (for example:
       <CrossgenBashScript Condition="'$(CLRTestKind)' == 'RunOnly'">
         <![CDATA[
 if [ ! -f $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/").Replace(".exe", ".ni.exe")) ]; then
-  "$CORE_ROOT/crossgen.exe" /Platform_Assemblies_Paths $CORE_ROOT%3B. $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/"))
+  "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3A$PWD $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/"))
+  __cgExitCode=$?
+  if [ ! $__cgExitCode == 0 ]
+  then
+    echo Crossgen failed with exitcode: $__cgExitCode
+    exit 1
+  fi
 fi
         ]]>
       </CrossgenBashScript>
@@ -46,7 +52,14 @@ fi
       <CrossgenBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun'">
         <![CDATA[
 if [ ! -f $(MSBuildProjectName).ni.exe ]; then
-  "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3B$PWD $(MSBuildProjectName).exe
+  echo "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3A$PWD $(MSBuildProjectName).exe
+  "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3A$PWD $(MSBuildProjectName).exe
+  __cgExitCode=$?
+  if [ ! $__cgExitCode == 0 ]
+  then
+    echo Crossgen failed with exitcode: $__cgExitCode
+    exit 1
+  fi
 fi        
         ]]>        
       </CrossgenBashScript>
index 4d0f695..03fb5b7 100644 (file)
@@ -36,12 +36,25 @@ WARNING:   When setting properties based on their current state (for example:
 <!-- CrossGen will create output if it needs to crossgen. Otherwise there will be silence. -->
       <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'RunOnly'">
         <![CDATA[
-if not exist "$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace(".exe", ".ni.exe"))""%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B. $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)))        
+if not exist "$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace(".exe", ".ni.exe"))" (
+"%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)))
+IF NOT "!ERRORLEVEL!"=="0" (
+    ECHO Crossgen failed with exitcode - !ERRORLEVEL!
+    Exit /b 1
+    )
+)        
         ]]>
       </CrossgenBatchScript>
       <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'BuildAndRun'">
         <![CDATA[
-if not exist "$(MSBuildProjectName).ni.exe" "%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $(MSBuildProjectName).exe      
+if not exist "$(MSBuildProjectName).ni.exe" (
+    echo "%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $(MSBuildProjectName).exe
+    "%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $(MSBuildProjectName).exe
+    IF NOT "!ERRORLEVEL!"=="0" (
+    ECHO Crossgen failed with exitcode - !ERRORLEVEL!
+    Exit /b 1
+    )
+  )      
         ]]>
       </CrossgenBatchScript>
     </PropertyGroup>