Skip to content

Commit 711f42d

Browse files
authored
pythongh-115556: Remove quotes from command-line arguments in test.bat and rt.bat (python#115557)
This change essentially replaces usage of `%1` with `%~1`, which removes quotes, if any. Without this change, the if statements fail due to the quotes mangling the syntax. Additionally, this change works around comma being treated as a parameter delimiter in test.bat by escaping commas at time of parsing. Tested combinations of rt and regrtest arguments, all seems to work as before but now you can specify commas in arguments like "-uall,extralargefile".
1 parent 74e6f4b commit 711f42d

3 files changed

Lines changed: 29 additions & 21 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
On Windows, commas passed in arguments to ``Tools\buildbot\test.bat`` and
2+
``PCbuild\\rt.bat`` are now properly handled.

PCbuild/rt.bat

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ set regrtestargs=--fast-ci
3838
set exe=
3939

4040
:CheckOpts
41-
if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts
42-
if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts
43-
if "%1"=="-d" (set suffix=_d) & shift & goto CheckOpts
41+
if "%~1"=="-O" (set dashO=-O) & shift & goto CheckOpts
42+
if "%~1"=="-q" (set qmode=yes) & shift & goto CheckOpts
43+
if "%~1"=="-d" (set suffix=_d) & shift & goto CheckOpts
4444
rem HACK: Need some way to infer the version number in this script
45-
if "%1"=="--disable-gil" (set pyname=python3.13t) & shift & goto CheckOpts
46-
if "%1"=="-win32" (set prefix=%pcbuild%win32) & shift & goto CheckOpts
47-
if "%1"=="-x64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
48-
if "%1"=="-amd64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
49-
if "%1"=="-arm64" (set prefix=%pcbuild%arm64) & shift & goto CheckOpts
50-
if "%1"=="-arm32" (set prefix=%pcbuild%arm32) & shift & goto CheckOpts
51-
if "%1"=="-p" (call :SetPlatform %~2) & shift & shift & goto CheckOpts
52-
if NOT "%1"=="" (set regrtestargs=%regrtestargs% %1) & shift & goto CheckOpts
45+
if "%~1"=="--disable-gil" (set pyname=python3.13t) & shift & goto CheckOpts
46+
if "%~1"=="-win32" (set prefix=%pcbuild%win32) & shift & goto CheckOpts
47+
if "%~1"=="-x64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
48+
if "%~1"=="-amd64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
49+
if "%~1"=="-arm64" (set prefix=%pcbuild%arm64) & shift & goto CheckOpts
50+
if "%~1"=="-arm32" (set prefix=%pcbuild%arm32) & shift & goto CheckOpts
51+
if "%~1"=="-p" (call :SetPlatform %~2) & shift & shift & goto CheckOpts
52+
if NOT "%~1"=="" (set regrtestargs=%regrtestargs% %~1) & shift & goto CheckOpts
5353

5454
if not defined prefix set prefix=%pcbuild%amd64
5555
set exe=%prefix%\%pyname%%suffix%.exe

Tools/buildbot/test.bat

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,10 @@ set here=%~dp0
77
set rt_opts=-q -d
88
set regrtest_args=
99
set arm32_ssh=
10+
set cmdline_args=%*
11+
set cmdline_args=%cmdline_args:,=#COMMA#%
1012

11-
:CheckOpts
12-
if "%1"=="-x64" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
13-
if "%1"=="-arm64" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
14-
if "%1"=="-arm32" (set rt_opts=%rt_opts% %1) & (set arm32_ssh=true) & shift & goto CheckOpts
15-
if "%1"=="-d" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
16-
if "%1"=="-O" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
17-
if "%1"=="-q" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
18-
if "%1"=="+d" (set rt_opts=%rt_opts:-d=%) & shift & goto CheckOpts
19-
if "%1"=="+q" (set rt_opts=%rt_opts:-q=%) & shift & goto CheckOpts
20-
if NOT "%1"=="" (set regrtest_args=%regrtest_args% %1) & shift & goto CheckOpts
13+
call:CheckOpts %cmdline_args%
2114

2215
if "%PROCESSOR_ARCHITECTURE%"=="ARM" if "%arm32_ssh%"=="true" goto NativeExecution
2316
if "%arm32_ssh%"=="true" goto :Arm32Ssh
@@ -49,3 +42,16 @@ echo The test worker should have the SSH agent running.
4942
echo Also a key must be created with ssh-keygen and added to both the buildbot worker machine
5043
echo and the ARM32 worker device: see https://docs.microsoft.com/en-us/windows/iot-core/connect-your-device/ssh
5144
exit /b 127
45+
46+
:CheckOpts
47+
set arg="%~1"
48+
if %arg%=="-x64" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
49+
if %arg%=="-arm64" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
50+
if %arg%=="-arm32" (set rt_opts=%rt_opts% %1) & (set arm32_ssh=true) & shift & goto CheckOpts
51+
if %arg%=="-d" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
52+
if %arg%=="-O" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
53+
if %arg%=="-q" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
54+
if %arg%=="+d" (set rt_opts=%rt_opts:-d=%) & shift & goto CheckOpts
55+
if %arg%=="+q" (set rt_opts=%rt_opts:-q=%) & shift & goto CheckOpts
56+
if NOT %arg%=="" (set regrtest_args=%regrtest_args% %arg:#COMMA#=,%) & shift & goto CheckOpts
57+
goto:eof

0 commit comments

Comments
 (0)