From f127b7e4512a848c11c965fa80a2b34df3083b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Desgroppes?= <7901596+rdesgroppes@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:09:50 +0200 Subject: [PATCH] buildifier_test: fix `FINDSTR: Cannot open MANIFEST` This happens on Windows when using `buildifier_test`: ``` INFO: Running command line: 'external\bazel_tools\tools\test\tw.exe' buildifier/test.bat Executing tests from //buildifier:test ----------------------------------------------------------------------------- FINDSTR: Cannot open MANIFEST The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object. At line:1 char:566 + ... (Should-Exclude $_.Path) }; foreach ($File in $Files) { & '' -mode=d ... + ~~ + CategoryInfo : InvalidOperation: (:String) [], RuntimeException + FullyQualifiedErrorId : BadExpression The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command [...] ``` The present change simply consists in giving a second try with `$RUNFILES_MANIFEST_FILE` and failing fast should both be absent. --- buildifier/runner.bat.template | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/buildifier/runner.bat.template b/buildifier/runner.bat.template index 1d359cdc0..b12e501ce 100644 --- a/buildifier/runner.bat.template +++ b/buildifier/runner.bat.template @@ -9,7 +9,15 @@ rem Unquote the arguments set stripped_args=%stripped_args:'=% rem Get the absolute path to the buildifier executable -for /f "tokens=2" %%i in ('findstr /r "\" MANIFEST') do (set buildifier_abs_path=%%i) +if exist MANIFEST ( + set manifest_file=MANIFEST +) else if exist "%RUNFILES_MANIFEST_FILE%" ( + set "manifest_file=%RUNFILES_MANIFEST_FILE:/=\%" +) else ( + >&2 echo Error: manifest file not found + exit /b 1 +) +for /f "tokens=2" %%i in ('findstr /r "\" "%manifest_file%"') do (set buildifier_abs_path=%%i) powershell ^ $Files = Get-ChildItem -LiteralPath '%BUILD_WORKSPACE_DIRECTORY:/=\%' -Recurse -File -ErrorAction SilentlyContinue ^|^