From 95cb1f679631a9524b59dada81bc2f79240bfa3a Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 14 Apr 2026 14:36:34 +0200 Subject: [PATCH] Just: fix Windows issues in codeql_test_run.py - Use posix=False for shlex.split on Windows to prevent backslashes in paths from being interpreted as escape characters - Prefer codeql.exe over the Unix shell wrapper on Windows Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- misc/just/codeql_test_run.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/misc/just/codeql_test_run.py b/misc/just/codeql_test_run.py index 97785739444..b0af2754d0d 100644 --- a/misc/just/codeql_test_run.py +++ b/misc/just/codeql_test_run.py @@ -38,7 +38,7 @@ ENV_RE = re.compile(r"^[A-Z_][A-Z_0-9]*=.*$") def parse_args(args, argv_str): """Parse a space-separated argument string into categorized arguments.""" - for arg in shlex.split(argv_str): + for arg in shlex.split(argv_str, posix=sys.platform != "win32"): if arg.startswith("--codeql="): args["codeql"] = arg.split("=", 1)[1] elif arg in ("+", "--all-checks"): @@ -104,24 +104,23 @@ def main(): # Resolve codeql executable if args["codeql"] in ("built", "build"): codeql = Path(SEMMLE_CODE, "target", "intree", f"codeql-{language}", "codeql") - if not codeql.exists(): - error(f"CodeQL executable not found: {codeql}") - return 1 elif args["codeql"] == "host": codeql = Path("codeql") else: codeql = Path(args["codeql"]) - if not codeql.exists(): - error(f"CodeQL executable not found: {codeql}") - return 1 if codeql.is_dir(): codeql = codeql / "codeql" - if sys.platform == "win32": - codeql = codeql.with_suffix(".exe") - if not codeql.exists(): - error(f"CodeQL executable not found: {codeql}") - return 1 + + # On Windows, prefer codeql.exe over the Unix shell wrapper + if sys.platform == "win32" and codeql.suffix != ".exe": + exe = codeql.with_suffix(".exe") + if exe.exists(): + codeql = exe + + if args["codeql"] != "host" and not codeql.exists(): + error(f"CodeQL executable not found: {codeql}") + return 1 return invoke( [str(codeql), "test", "run", *args["flags"], "--", *args["tests"]],