From 4cf6ef92c6629e514c4308848926d258c0ee9d12 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 7 Jan 2020 12:14:25 +0100 Subject: [PATCH] Require test framework assemblies crossgen to succeed (#1305) * Require test framework assemblies crossgen to succeed The test framework crossgen in build-test.cmd failures were ignored before. Change that to require the crossgen of all the framework assemblies to succeed. I've also added a progress and status details to the output. Equivalent changes were made to the Unix build-test.sh. --- src/coreclr/build-test.cmd | 46 ++++++++++++++++++++++++++++++++++------------ src/coreclr/build-test.sh | 35 +++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/coreclr/build-test.cmd b/src/coreclr/build-test.cmd index ac459c7..62b3f3c 100644 --- a/src/coreclr/build-test.cmd +++ b/src/coreclr/build-test.cmd @@ -32,6 +32,7 @@ set "__ProjectDir=%~dp0" :: remove trailing slash if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%" set "__RepoRootDir=%__ProjectDir%\..\.." +for %%i in ("%__RepoRootDir%") do SET "__RepoRootDir=%%~fi" set "__TestDir=%__ProjectDir%\tests" set "__ProjectFilesDir=%__TestDir%" @@ -518,6 +519,10 @@ if defined __DoCrossgen ( if "%__TargetsWindows%" == "1" ( echo %__MsgPrefix%Running crossgen on framework assemblies in CORE_ROOT: %CORE_ROOT% call :PrecompileFX + if ERRORLEVEL 1 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: crossgen precompilation of framework assemblies failed + exit /b 1 + ) ) else ( echo "%__MsgPrefix%Crossgen only supported on Windows, for now" ) @@ -528,6 +533,10 @@ if defined __DoCrossgen2 ( if "%__BuildArch%" == "x64" ( echo %__MsgPrefix%Running crossgen2 on framework assemblies in CORE_ROOT: %CORE_ROOT% call :PrecompileFX + if ERRORLEVEL 1 ( + echo %__ErrMsgPrefix%%__MsgPrefix%Error: crossgen2 precompilation of framework assemblies failed + exit /b 1 + ) ) else ( echo "%__MsgPrefix%Crossgen2 only supported on x64, for now" ) @@ -600,8 +609,25 @@ may help to copy its "DIA SDK" folder into "%VSINSTALLDIR%" manually, then try a exit /b 1 :PrecompileFX -for %%F in (%CORE_ROOT%\*.dll) do call :PrecompileAssembly "%%F" %%~nF%%~xF -exit /b 0 +set __TotalPrecompiled=0 +set __FailedToPrecompile=0 +set __FailedAssemblies= +for %%F in ("%CORE_ROOT%\System.*.dll";"%CORE_ROOT%\Microsoft.*.dll") do ( + if not "%%~nxF"=="Microsoft.CodeAnalysis.VisualBasic.dll" ( + if not "%%~nxF"=="Microsoft.CodeAnalysis.CSharp.dll" ( + if not "%%~nxF"=="Microsoft.CodeAnalysis.dll" ( + if not "%%~nxF"=="System.Runtime.WindowsRuntime.dll" ( + call :PrecompileAssembly "%%F" %%~nxF __TotalPrecompiled __FailedToPrecompile __FailedAssemblies + echo Processed: !__TotalPrecompiled!, failed !__FailedToPrecompile! + ))))) +) + +if !__FailedToPrecompile! NEQ 0 ( + echo Failed assemblies: + FOR %%G IN (!__FailedAssemblies!) do echo %%G +) + +exit /b !__FailedToPrecompile! REM Compile the managed assemblies in Core_ROOT before running the tests :PrecompileAssembly @@ -609,14 +635,6 @@ REM Compile the managed assemblies in Core_ROOT before running the tests set AssemblyPath=%1 set AssemblyName=%2 -REM Don't precompile xunit.* files -echo "%AssemblyName%" | findstr /b "xunit." >nul && ( - exit /b 0 -) - -REM Skip the Win32 API dll's -if /i "%AssemblyName:~0,4%"=="api-" exit /b 0 - set __CrossgenExe="%CORE_ROOT%\crossgen.exe" if /i "%__BuildArch%" == "arm" ( set __CrossgenExe="%CORE_ROOT%\x86\crossgen.exe" ) if /i "%__BuildArch%" == "arm64" ( set __CrossgenExe="%CORE_ROOT%\x64\crossgen.exe" ) @@ -634,20 +652,24 @@ set __CrossgenCmd= if defined __DoCrossgen ( set __CrossgenCmd=!__CrossgenExe! /Platform_Assemblies_Paths "!CORE_ROOT!" /in !AssemblyPath! /out !__CrossgenOutputFile! ) else ( - set __CrossgenCmd=!__CrossgenExe! -r:"!CORE_ROOT!\System.*.dll" -r:"!CORE_ROOT!\Microsoft.*.dll" -r:"!CORE_ROOT!\mscorlib.dll" -O --inputbubble --out:!__CrossgenOutputFile! !AssemblyPath! + set __CrossgenCmd=!__CrossgenExe! -r:"!CORE_ROOT!\System.*.dll" -r:"!CORE_ROOT!\Microsoft.*.dll" -r:"!CORE_ROOT!\mscorlib.dll" -r:"!CORE_ROOT!\netstandard.dll" -O --inputbubble --out:!__CrossgenOutputFile! !AssemblyPath! ) echo %__CrossgenCmd% %__CrossgenCmd% set /a __exitCode = !errorlevel! +set /a "%~3+=1" + if "%__exitCode%" == "-2146230517" ( echo %AssemblyPath% is not a managed assembly. exit /b 0 ) if %__exitCode% neq 0 ( - echo Unable to precompile %AssemblyPath%, Exit Code is %__exitCode% + echo Unable to precompile %AssemblyPath%, exit code is %__exitCode% + set /a "%~4+=1" + set "%~5=!%~5!,!AssemblyName!" exit /b 0 ) diff --git a/src/coreclr/build-test.sh b/src/coreclr/build-test.sh index 39c4f5a..cbc6ce7 100755 --- a/src/coreclr/build-test.sh +++ b/src/coreclr/build-test.sh @@ -155,27 +155,26 @@ precompile_coreroot_fx() mkdir ${outputDir} - skipCrossGenFiles+=('System.Private.CoreLib.dll') - skipCrossGenFiles+=('System.Runtime.Serialization.Formatters.dll') skipCrossGenFiles+=('Microsoft.CodeAnalysis.CSharp.dll') skipCrossGenFiles+=('Microsoft.CodeAnalysis.dll') skipCrossGenFiles+=('Microsoft.CodeAnalysis.VisualBasic.dll') - skipCrossGenFiles+=('CommandLine.dll') - for reference in ${overlayDir}/*.dll - do + for reference in ${overlayDir}/*.dll; do crossgen2References+=" -r:${reference}" done fi echo "${__MsgPrefix}Running ${compilerName} on framework assemblies in CORE_ROOT: '${CORE_ROOT}'" - filesToPrecompile=$(find -L $overlayDir -maxdepth 1 -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -not -iname xunit.\* -type f) - for fileToPrecompile in ${filesToPrecompile} - do + local totalPrecompiled=0 + local failedToPrecompile=0 + declare -a failedAssemblies + + filesToPrecompile=$(find -L $overlayDir -maxdepth 1 -iname Microsoft.\*.dll -o -iname System.\*.dll -type f) + for fileToPrecompile in ${filesToPrecompile}; do local filename=${fileToPrecompile} if is_skip_crossgen_test "$(basename $filename)"; then - continue + continue fi echo Precompiling $filename @@ -193,14 +192,18 @@ precompile_coreroot_fx() if grep -q -e '0x80131018' $filename.stderr; then printf "\n\t$filename is not a managed assembly.\n\n" else - echo Unable to precompile $filename. + echo Unable to precompile $filename, exit code is $exitCode. cat $filename.stdout cat $filename.stderr - exit $exitCode + failedAssemblies+=($(basename -- "$filename")) + failedToPrecompile=$((failedToPrecompile+1)) fi else rm $filename.{stdout,stderr} fi + + totalPrecompiled=$((totalPrecompiled+1)) + echo Processed: $totalPrecompiled, failed $failedToPrecompile done if [[ $__DoCrossgen2 != 0 ]]; then @@ -208,6 +211,15 @@ precompile_coreroot_fx() mv -f ${outputDir}/* ${overlayDir}/ rm -r ${outputDir} fi + + if [[ $failedToPrecompile != 0 ]]; then + echo Failed assemblies: + for assembly in "${failedAssemblies[@]}"; do + echo " $assembly" + done + + exit 1 + fi } declare -a skipCrossGenFiles @@ -740,4 +752,3 @@ else echo "To run single test use the following command:" echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}" fi - -- 2.7.4