]> Cypherpunks repositories - gostls13.git/commitdiff
{all,clean,make,race,run}.bat: remove %GOBUILDEXIT% and %GOBUILDFAIL%
authorqmuntal <quimmuntal@gmail.com>
Thu, 6 Feb 2025 08:07:08 +0000 (09:07 +0100)
committerGopher Robot <gobot@golang.org>
Fri, 7 Feb 2025 16:33:18 +0000 (08:33 -0800)
%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>
src/all.bat
src/clean.bat
src/make.bat
src/race.bat
src/run.bat

index d5abec141f31aa277ebdc151ef9830c1c20fd82e..016987f86ecb35899b76b02b23e6aab93bf9e469 100644 (file)
@@ -8,15 +8,15 @@ setlocal
 \r
 if exist make.bat goto ok\r
 echo all.bat must be run from go\src\r
-:: cannot exit: would kill parent command interpreter\r
-goto end\r
+exit /b 1\r
 :ok\r
 \r
 call .\make.bat --no-banner --no-local\r
-if %GOBUILDFAIL%==1 goto end\r
+if errorlevel 1 goto fail\r
 call .\run.bat --no-rebuild --no-local\r
-if %GOBUILDFAIL%==1 goto end\r
+if errorlevel 1 goto fail\r
 "%GOTOOLDIR%/dist" banner\r
+goto :eof\r
 \r
-:end\r
-if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%\r
+:fail\r
+exit /b 1\r
index 6688b41e5e2c9d416235659a73f2aa0345ce1131..ceba3a56cf44e89a4a5ca31332bc4420e1d0b441 100644 (file)
@@ -6,8 +6,6 @@
 \r
 setlocal\r
 \r
-set GOBUILDFAIL=0\r
-\r
 go tool dist env -w -p >env.bat\r
 if errorlevel 1 goto fail\r
 call .\env.bat\r
@@ -23,10 +21,7 @@ goto fail
 "%GOBIN%\go" tool dist clean\r
 "%GOBIN%\go" clean -i cmd\r
 \r
-goto end\r
+goto :eof\r
 \r
 :fail\r
-set GOBUILDFAIL=1\r
-\r
-:end\r
-if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%\r
+exit /b 1\r
index 3b5a4663dce342986aa19900a1acbe0bed1a83df..3a72a59470e565d8242e0e50eb0193927be29003 100644 (file)
@@ -47,8 +47,6 @@ if x%4==x--no-local goto nolocal
 setlocal\r
 :nolocal\r
 \r
-set GOBUILDFAIL=0\r
-\r
 if exist make.bat goto ok\r
 echo Must run make.bat from Go src directory.\r
 goto fail\r
@@ -180,5 +178,4 @@ echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
 echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.\r
 \r
 :fail\r
-set GOBUILDFAIL=1\r
-if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%\r
+exit /b 1\r
index d395e19f9741ddc2f8343ef932cdaf9bd6a59312..64510b60129e9d9893ef025c3d5548790d595325 100644 (file)
@@ -11,8 +11,7 @@ setlocal
 \r
 if exist make.bat goto ok\r
 echo race.bat must be run from go\src\r
-:: cannot exit: would kill parent command interpreter\r
-goto end\r
+exit /b 1\r
 :ok\r
 \r
 set GOROOT=%CD%\..\r
@@ -29,7 +28,7 @@ goto fail
 \r
 :continue\r
 call .\make.bat --no-banner --no-local\r
-if %GOBUILDFAIL%==1 goto end\r
+if errorlevel 1 goto fail\r
 echo # go install -race std\r
 go install -race std\r
 if errorlevel 1 goto fail\r
@@ -37,15 +36,9 @@ if errorlevel 1 goto fail
 go tool dist test -race\r
 \r
 if errorlevel 1 goto fail\r
-goto succ\r
+echo All tests passed.\r
+goto :eof\r
 \r
 :fail\r
-set GOBUILDFAIL=1\r
 echo Fail.\r
-goto end\r
-\r
-:succ\r
-echo All tests passed.\r
-\r
-:end\r
-if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%\r
+exit /b 1\r
index 35c8ead8cb22473e96605ceb9474cb661c705d34..8815a1109f1ab4f8057615ceaa14d696f65ebc08 100644 (file)
@@ -16,8 +16,6 @@ if x%2==x--no-local goto nolocal
 setlocal\r
 :nolocal\r
 \r
-set GOBUILDFAIL=0\r
-\r
 set GOENV=off\r
 ..\bin\go tool dist env > env.bat\r
 if errorlevel 1 goto fail\r
@@ -29,14 +27,12 @@ set GOPATH=c:\nonexist-gopath
 if x%1==x--no-rebuild goto norebuild\r
 ..\bin\go tool dist test --rebuild\r
 if errorlevel 1 goto fail\r
-goto end\r
+goto :eof\r
 \r
 :norebuild\r
 ..\bin\go tool dist test\r
 if errorlevel 1 goto fail\r
-goto end\r
+goto :eof\r
 \r
 :fail\r
-set GOBUILDFAIL=1\r
-\r
-:end\r
+exit /b 1\r