mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
{all,clean,make,race,run}.bat: use || instead of "if errorlevel 1"
"if errorlevel 1" is and old construct that returns true if the errorlevel is greater than or equal to 1. There are better alternatives since Windows NT. For example, the || operator runs the RHS operand if the preceding command failed, determined by checking that the errorlevel is different from 0. This approach is more robust -it also works with negative errorlevels- and is less verbose. Change-Id: I2070d654d8f9dd41a6cd586ba5ad5f4fea0638ed Reviewed-on: https://go-review.googlesource.com/c/go/+/647136 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
302bf36314
commit
580a383103
@ -11,10 +11,8 @@ echo all.bat must be run from go\src
|
||||
exit /b 1
|
||||
:ok
|
||||
|
||||
call .\make.bat --no-banner --no-local
|
||||
if errorlevel 1 goto fail
|
||||
call .\run.bat --no-rebuild
|
||||
if errorlevel 1 goto fail
|
||||
call .\make.bat --no-banner --no-local || goto fail
|
||||
call .\run.bat --no-rebuild || goto fail
|
||||
"%GOTOOLDIR%/dist" banner
|
||||
goto :eof
|
||||
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
setlocal
|
||||
|
||||
go tool dist env -w -p >env.bat
|
||||
if errorlevel 1 goto fail
|
||||
go tool dist env -w -p >env.bat || goto fail
|
||||
call .\env.bat
|
||||
del env.bat
|
||||
echo.
|
||||
|
@ -101,11 +101,9 @@ echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%)
|
||||
if x%vflag==x-v echo cmd/dist
|
||||
set GOROOT=%GOROOT_BOOTSTRAP%
|
||||
set GOBIN=
|
||||
"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist
|
||||
"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist || goto fail
|
||||
endlocal
|
||||
if errorlevel 1 goto fail
|
||||
.\cmd\dist\dist.exe env -w -p >env.bat
|
||||
if errorlevel 1 goto fail
|
||||
.\cmd\dist\dist.exe env -w -p >env.bat || goto fail
|
||||
call .\env.bat
|
||||
del env.bat
|
||||
if x%vflag==x-v echo.
|
||||
@ -148,8 +146,7 @@ if x%4==x--distpack set bootstrapflags=%bootstrapflags% -distpack
|
||||
:: Run dist bootstrap to complete make.bash.
|
||||
:: Bootstrap installs a proper cmd/dist, built with the new toolchain.
|
||||
:: Throw ours, built with the bootstrap toolchain, away after bootstrap.
|
||||
.\cmd\dist\dist.exe bootstrap -a %vflag% %bootstrapflags%
|
||||
if errorlevel 1 goto fail
|
||||
.\cmd\dist\dist.exe bootstrap -a %vflag% %bootstrapflags% || goto fail
|
||||
del .\cmd\dist\dist.exe
|
||||
goto :eof
|
||||
|
||||
|
16
src/race.bat
16
src/race.bat
@ -15,10 +15,8 @@ exit /b 1
|
||||
:ok
|
||||
|
||||
set GOROOT=%CD%\..
|
||||
call .\make.bat --dist-tool >NUL
|
||||
if errorlevel 1 goto fail
|
||||
.\cmd\dist\dist.exe env -w -p >env.bat
|
||||
if errorlevel 1 goto fail
|
||||
call .\make.bat --dist-tool >NUL || goto fail
|
||||
.\cmd\dist\dist.exe env -w -p >env.bat || goto fail
|
||||
call .\env.bat
|
||||
del env.bat
|
||||
|
||||
@ -27,15 +25,11 @@ echo Race detector is only supported on windows/amd64.
|
||||
goto fail
|
||||
|
||||
:continue
|
||||
call .\make.bat --no-banner --no-local
|
||||
if errorlevel 1 goto fail
|
||||
call .\make.bat --no-banner --no-local || goto fail
|
||||
echo # go install -race std
|
||||
go install -race std
|
||||
if errorlevel 1 goto fail
|
||||
go install -race std || goto fail
|
||||
go tool dist test -race || goto fail
|
||||
|
||||
go tool dist test -race
|
||||
|
||||
if errorlevel 1 goto fail
|
||||
echo All tests passed.
|
||||
goto :eof
|
||||
|
||||
|
@ -12,14 +12,12 @@ goto fail
|
||||
setlocal
|
||||
|
||||
set GOENV=off
|
||||
..\bin\go tool dist env > env.bat
|
||||
if errorlevel 1 goto fail
|
||||
..\bin\go tool dist env > env.bat || goto fail
|
||||
call .\env.bat
|
||||
del env.bat
|
||||
|
||||
set GOPATH=c:\nonexist-gopath
|
||||
..\bin\go tool dist test --rebuild %*
|
||||
if errorlevel 1 goto fail
|
||||
..\bin\go tool dist test --rebuild %* || goto fail
|
||||
goto :eof
|
||||
|
||||
:fail
|
||||
|
Loading…
x
Reference in New Issue
Block a user