Skip to content

Commit

Permalink
Merge pull request dotnet#1028 from mmitche/fix-cmd-exit-codes
Browse files Browse the repository at this point in the history
Fix cmd exit codes
  • Loading branch information
pgavlin committed May 21, 2015
2 parents 8e5e2c6 + c122ee6 commit 8e792a3
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 2,840 deletions.
20 changes: 10 additions & 10 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ goto CheckVS
if defined VS%__VSProductVersion%COMNTOOLS goto CheckVSExistence
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/wiki/Developer-Guide#prerequisites
goto :eof
exit /b 1

:CheckVSExistence
:: Does VS 2013 or VS 2015 really exist?
if exist "!VS%__VSProductVersion%COMNTOOLS!\..\IDE\devenv.exe" goto CheckMSBuild
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/wiki/Developer-Guide#prerequisites
goto :eof
exit /b 1

:CheckMSBuild
:: Note: We've disabled node reuse because it causes file locking issues.
Expand Down Expand Up @@ -142,7 +142,7 @@ of previous version to "%VSINSTALLDIR%" and then resume build.
echo Visual Studio 2013 Express does not include the DIA SDK. ^
You need Visual Studio 2013 Community (free).
echo See: https://github.com/dotnet/coreclr/wiki/Developer-Guide#prerequisites
goto :eof
exit /b 1

:GenVSSolution
:: Regenerate the VS solution
Expand All @@ -153,15 +153,15 @@ popd
:BuildComponents
if exist "%__IntermediatesDir%\install.vcxproj" goto BuildCoreCLR
echo Failed to generate native component build project!
goto :eof
exit /b 1

REM Build CoreCLR
:BuildCoreCLR
set "__CoreCLRBuildLog=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__CoreCLRBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformMScorlibBuild
echo Native component build failed. Refer !__CoreCLRBuildLog! for details.
goto :eof
exit /b 1

:PerformMScorlibBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
Expand All @@ -183,12 +183,12 @@ echo.
set "__MScorlibBuildLog=%__LogsDir%\MScorlib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__MScorlibBuildLog%" /p:OS=%__BuildOS% %__AdditionalMSBuildArgs%
IF NOT ERRORLEVEL 1 (
if defined __MscorlibOnly goto :eof
if defined __MscorlibOnly exit /b 0
goto CrossGenMscorlib
)

echo MScorlib build failed. Refer !__MScorlibBuildLog! for details.
goto :eof
exit /b 1

:CrossGenMscorlib
echo Generating native image of mscorlib for %__BuildOS%.%__BuildArch%.%__BuildType%
Expand All @@ -200,7 +200,7 @@ IF NOT ERRORLEVEL 1 (
)

echo CrossGen mscorlib failed. Refer !__CrossGenMScorlibLog! for details.
goto :eof
exit /b 1

:PerformTestBuild
echo.
Expand All @@ -209,15 +209,15 @@ echo.
call tests\buildtest.cmd
IF NOT ERRORLEVEL 1 goto SuccessfulBuild
echo Test binaries build failed. Refer !__MScorlibBuildLog! for details.
goto :eof
exit /b 1

:SuccessfulBuild
::Build complete
echo Repo successfully built.
echo.
echo Product binaries are available at !__BinDir!
echo Test binaries are available at !__TestBinDir!
goto :eof
exit /b 0

:Usage
echo.
Expand Down
19 changes: 7 additions & 12 deletions tests/buildtest.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "&
:: Check presence of VS
if defined VS%__VSProductVersion%COMNTOOLS goto CheckVSExistence
echo Installation of VS 2013 is a pre-requisite to build this repository.
goto :eof
exit /b 1

:CheckVSExistence
:: Does VS 2013 or VS 2015 really exist?
if exist "!VS%__VSProductVersion%COMNTOOLS!\..\IDE\devenv.exe" goto CheckMSBuild
echo Installation of VS 2013 is a pre-requisite to build this repository.
goto :eof
exit /b 1

:CheckMSBuild
if /i "%__VSVersion%" =="vs2015" goto MSBuild14
Expand All @@ -113,7 +113,7 @@ echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
This is due to bug in VS Intaller. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
at VS install location of previous version. Workaround is to copy DIA SDK folder from VS install location ^
of previous version to "%VSINSTALLDIR%" and then resume build.
goto :eof
exit /b 1

:GenVSSolution
:: Regenerate the VS solution
Expand All @@ -124,14 +124,14 @@ popd
:BuildComponents
if exist "%__NativeTestIntermediatesDir%\install.vcxproj" goto BuildTestNativeComponents
echo Failed to generate test native component build project!
goto :eof
exit /b 1

REM Build CoreCLR
:BuildTestNativeComponents
%_msbuildexe% "%__NativeTestIntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__TestNativeBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformManagedTestBuild
echo Native component build failed. Refer !__TestNativeBuildLog! for details.
goto :eof
exit /b 1

:PerformManagedTestBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
Expand Down Expand Up @@ -161,19 +161,14 @@ set _buildprefix=
set _buildpostfix=
set _buildappend=
call :build %1

goto :eof
exit /b %ERRORLEVEL%

:build

%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix%
IF ERRORLEVEL 1 echo Test build failed. Refer !__TestManagedBuildLog! for details && exit /b 1
exit /b 0

endlocal



goto :eof
:Usage
echo.
echo Usage:
Expand Down
11 changes: 11 additions & 0 deletions tests/issues.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project DefaultTargets = "GetListOfTestCmds"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<ItemGroup Condition="'$(XunitTestBinBase)' != ''">
<ExcludeList Include="$(XunitTestBinBase)\JIT\Directed\newarr\newarr.cmd" >
<Issue>1036</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)\JIT\Directed\lifetime\lifetime2.cmd" >
<Issue>1037</Issue>
</ExcludeList>
</ItemGroup>
</Project>
40 changes: 17 additions & 23 deletions tests/runtest.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ set __ProjectFilesDir=%~dp0
set __VSVersion=VS2013
set __VSProductVersion=120

:: Default __Exclude to issues.targets
set __Exclude=%~dp0\issues.targets

:Arg_Loop
if "%1" == "" goto ArgsDone
if /i "%1" == "x64" (set __BuildArch=x64&set __MSBuildBuildArch=x64&shift&goto Arg_Loop)
Expand All @@ -29,7 +32,7 @@ shift
:: Check presence of VS
if defined VS%__VSProductVersion%COMNTOOLS goto CheckMSbuild
echo Installation of VS 2013 is a pre-requisite to build this repository.
goto :eof
exit /b 1

:CheckMSBuild
if /i "%__VSVersion%" =="vs2015" goto MSBuild14
Expand Down Expand Up @@ -95,26 +98,16 @@ set _buildprefix=
set _buildpostfix=
set _buildappend=
call :PerformXunitWrapperBuild
IF ERRORLEVEL 1 (
echo XunitWrapperBuild build failed. Refer %__XunitWrapperBuildLog% for details.
exit /b 1
)

IF %BUILDERRORLEVEL% NEQ 0 echo XunitWrapperBuild build failed. Refer %__XunitWrapperBuildLog% for details. && exit /b %BUILDERRORLEVEL%

call :preptests
goto :eof

:PerformXunitWrapperBuild

%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoRun=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__XunitWrapperBuildLog%";Append %1 %_buildappend%%_buildpostfix%

set BUILDERRORLEVEL=%ERRORLEVEL%

goto :eof

:preptests
:: Log build command line
set _buildprefix=echo
set _buildpostfix=^> "%__TestRunBuildLog%"
set _buildappend=^>
call :runtests
call :runtests

:: Build
set _buildprefix=
Expand All @@ -128,20 +121,21 @@ if exist %Core_Root% rd /s /q %Core_Root%
md %Core_Root%
xcopy /s %__BinDir% %Core_Root%
call :runtests

IF %BUILDERRORLEVEL% NEQ 0 (
if ERRORLEVEL 1 (
echo Test Run failed. Refer to the following"
echo Msbuild log: %__TestRunBuildLog%
echo Html report: %__TestRunHtmlLog%
exit /b %BUILDERRORLEVEL%
exit /b 1
)
goto :eof

:runtests
%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoBuild=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestRunBuildLog%";Append %1 %_buildpostfix%
%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoBuild=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestRunBuildLog%";Append %1 %_buildpostfix% /clp:showcommandline
exit /b %ERRORLEVEL%

:PerformXunitWrapperBuild

set BUILDERRORLEVEL=%ERRORLEVEL%
goto :eof
%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoRun=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__XunitWrapperBuildLog%";Append %1 %_buildappend%%_buildpostfix%
exit /b %ERRORLEVEL%

:Usage
echo.
Expand Down
Loading

0 comments on commit 8e792a3

Please sign in to comment.