mirror of https://github.com/golang/go.git
{all,clean,make,race,run}.bat: remove %GOBUILDEXIT% and %GOBUILDFAIL%
%GOBUILDEXIT% is used to avoid closing the terminal window when the build or the tests fail on a dev machine. It is only set in CI to get a non-zero exit code in case of failure. %GOBUILDFAIL% is used to pass the exit code from a child batch file to the parent batch file. It is set to 1 in the child batch file if the build or the tests fail. These two variables add complexity to the batch files and impose some limitations on how they are implemented. For example, the child files can't use setlocal, as it would make the parent file unable to read the %GOBUILDFAIL% variable. This CL removes these two variables and replaces them with unconditional calls to "exit /b 1" in case of failure, which is more idiomatic and composable. The trick is that the "/b" parameter makes the exit only apply to the current batch file, not the entire shell session (unless the bat file is the root, in which case the parameter is ignored), so the parent batch file can continue executing, potentially checking the errorlevel of the child batch file (which we always set to 1). Change-Id: Ib053fb181ab14d58679551e03485700de77878d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/647115 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
7a2f757c52
commit
09fdcdc97d
12
src/all.bat
12
src/all.bat
|
|
@ -8,15 +8,15 @@ setlocal
|
||||||
|
|
||||||
if exist make.bat goto ok
|
if exist make.bat goto ok
|
||||||
echo all.bat must be run from go\src
|
echo all.bat must be run from go\src
|
||||||
:: cannot exit: would kill parent command interpreter
|
exit /b 1
|
||||||
goto end
|
|
||||||
:ok
|
:ok
|
||||||
|
|
||||||
call .\make.bat --no-banner --no-local
|
call .\make.bat --no-banner --no-local
|
||||||
if %GOBUILDFAIL%==1 goto end
|
if errorlevel 1 goto fail
|
||||||
call .\run.bat --no-rebuild --no-local
|
call .\run.bat --no-rebuild --no-local
|
||||||
if %GOBUILDFAIL%==1 goto end
|
if errorlevel 1 goto fail
|
||||||
"%GOTOOLDIR%/dist" banner
|
"%GOTOOLDIR%/dist" banner
|
||||||
|
goto :eof
|
||||||
|
|
||||||
:end
|
:fail
|
||||||
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
|
exit /b 1
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
set GOBUILDFAIL=0
|
|
||||||
|
|
||||||
go tool dist env -w -p >env.bat
|
go tool dist env -w -p >env.bat
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
call .\env.bat
|
call .\env.bat
|
||||||
|
|
@ -23,10 +21,7 @@ goto fail
|
||||||
"%GOBIN%\go" tool dist clean
|
"%GOBIN%\go" tool dist clean
|
||||||
"%GOBIN%\go" clean -i cmd
|
"%GOBIN%\go" clean -i cmd
|
||||||
|
|
||||||
goto end
|
goto :eof
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
set GOBUILDFAIL=1
|
exit /b 1
|
||||||
|
|
||||||
:end
|
|
||||||
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
|
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,6 @@ if x%4==x--no-local goto nolocal
|
||||||
setlocal
|
setlocal
|
||||||
:nolocal
|
:nolocal
|
||||||
|
|
||||||
set GOBUILDFAIL=0
|
|
||||||
|
|
||||||
if exist make.bat goto ok
|
if exist make.bat goto ok
|
||||||
echo Must run make.bat from Go src directory.
|
echo Must run make.bat from Go src directory.
|
||||||
goto fail
|
goto fail
|
||||||
|
|
@ -180,5 +178,4 @@ echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
|
||||||
echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
|
echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
set GOBUILDFAIL=1
|
exit /b 1
|
||||||
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
|
|
||||||
|
|
|
||||||
17
src/race.bat
17
src/race.bat
|
|
@ -11,8 +11,7 @@ setlocal
|
||||||
|
|
||||||
if exist make.bat goto ok
|
if exist make.bat goto ok
|
||||||
echo race.bat must be run from go\src
|
echo race.bat must be run from go\src
|
||||||
:: cannot exit: would kill parent command interpreter
|
exit /b 1
|
||||||
goto end
|
|
||||||
:ok
|
:ok
|
||||||
|
|
||||||
set GOROOT=%CD%\..
|
set GOROOT=%CD%\..
|
||||||
|
|
@ -29,7 +28,7 @@ goto fail
|
||||||
|
|
||||||
:continue
|
:continue
|
||||||
call .\make.bat --no-banner --no-local
|
call .\make.bat --no-banner --no-local
|
||||||
if %GOBUILDFAIL%==1 goto end
|
if errorlevel 1 goto fail
|
||||||
echo # go install -race std
|
echo # go install -race std
|
||||||
go install -race std
|
go install -race std
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
|
|
@ -37,15 +36,9 @@ if errorlevel 1 goto fail
|
||||||
go tool dist test -race
|
go tool dist test -race
|
||||||
|
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
goto succ
|
echo All tests passed.
|
||||||
|
goto :eof
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
set GOBUILDFAIL=1
|
|
||||||
echo Fail.
|
echo Fail.
|
||||||
goto end
|
exit /b 1
|
||||||
|
|
||||||
:succ
|
|
||||||
echo All tests passed.
|
|
||||||
|
|
||||||
:end
|
|
||||||
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
|
|
||||||
|
|
|
||||||
10
src/run.bat
10
src/run.bat
|
|
@ -16,8 +16,6 @@ if x%2==x--no-local goto nolocal
|
||||||
setlocal
|
setlocal
|
||||||
:nolocal
|
:nolocal
|
||||||
|
|
||||||
set GOBUILDFAIL=0
|
|
||||||
|
|
||||||
set GOENV=off
|
set GOENV=off
|
||||||
..\bin\go tool dist env > env.bat
|
..\bin\go tool dist env > env.bat
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
|
|
@ -29,14 +27,12 @@ set GOPATH=c:\nonexist-gopath
|
||||||
if x%1==x--no-rebuild goto norebuild
|
if x%1==x--no-rebuild goto norebuild
|
||||||
..\bin\go tool dist test --rebuild
|
..\bin\go tool dist test --rebuild
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
goto end
|
goto :eof
|
||||||
|
|
||||||
:norebuild
|
:norebuild
|
||||||
..\bin\go tool dist test
|
..\bin\go tool dist test
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
goto end
|
goto :eof
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
set GOBUILDFAIL=1
|
exit /b 1
|
||||||
|
|
||||||
:end
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue