Skip to content

Commit 95cb1f6

Browse files
redsun82Copilot
andcommitted
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>
1 parent 1d31394 commit 95cb1f6

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

misc/just/codeql_test_run.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def error(message):
3838

3939
def parse_args(args, argv_str):
4040
"""Parse a space-separated argument string into categorized arguments."""
41-
for arg in shlex.split(argv_str):
41+
for arg in shlex.split(argv_str, posix=sys.platform != "win32"):
4242
if arg.startswith("--codeql="):
4343
args["codeql"] = arg.split("=", 1)[1]
4444
elif arg in ("+", "--all-checks"):
@@ -104,24 +104,23 @@ def main():
104104
# Resolve codeql executable
105105
if args["codeql"] in ("built", "build"):
106106
codeql = Path(SEMMLE_CODE, "target", "intree", f"codeql-{language}", "codeql")
107-
if not codeql.exists():
108-
error(f"CodeQL executable not found: {codeql}")
109-
return 1
110107
elif args["codeql"] == "host":
111108
codeql = Path("codeql")
112109
else:
113110
codeql = Path(args["codeql"])
114-
if not codeql.exists():
115-
error(f"CodeQL executable not found: {codeql}")
116-
return 1
117111

118112
if codeql.is_dir():
119113
codeql = codeql / "codeql"
120-
if sys.platform == "win32":
121-
codeql = codeql.with_suffix(".exe")
122-
if not codeql.exists():
123-
error(f"CodeQL executable not found: {codeql}")
124-
return 1
114+
115+
# On Windows, prefer codeql.exe over the Unix shell wrapper
116+
if sys.platform == "win32" and codeql.suffix != ".exe":
117+
exe = codeql.with_suffix(".exe")
118+
if exe.exists():
119+
codeql = exe
120+
121+
if args["codeql"] != "host" and not codeql.exists():
122+
error(f"CodeQL executable not found: {codeql}")
123+
return 1
125124

126125
return invoke(
127126
[str(codeql), "test", "run", *args["flags"], "--", *args["tests"]],

0 commit comments

Comments
 (0)