Skip to content

Commit 7890796

Browse files
committed
fix(ci): normalize Windows paths in CodeQL retracing
Signed-off-by: Martin Vogel <[email protected]>
1 parent d2e0036 commit 7890796

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎scripts/ci/codeql-retrace-vendored.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ fi
8080
printf '%s\n' "$changed" |
8181
bash "$ROOT/scripts/ci/select-lanes.sh" --codeql-scope c-cpp |
8282
while IFS= read -r path; do
83+
# Native Windows Python writes CRLF; read removes only the LF.
84+
path="${path%$'\r'}"
8385
entrypoints=()
8486
case "$path" in
8587
internal/cbm/grammar_*.c | internal/cbm/ts_runtime.c)

‎tests/test_select_lanes.sh‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,31 @@ if proc.returncode != 0 or got != ["internal/cbm/grammar_go.c",
275275
"vendored/sqlite3/sqlite3.c"]:
276276
failures.append(f"codeql (c): the retrace helper must list the translation units for "
277277
f"changed vendored code and wrappers, got {got} (exit {proc.returncode})")
278+
# Native Windows Python emits CRLF even when the change list uses LF. Pin
279+
# that producer/consumer boundary on every platform, including direct wrapper
280+
# paths that must survive verbatim rather than being mapped to a family name.
281+
crlf_root = work / "crlf-selector"
282+
crlf_scripts = crlf_root / "scripts" / "ci"
283+
crlf_scripts.mkdir(parents=True)
284+
(crlf_scripts / retrace.name).write_bytes(retrace.read_bytes())
285+
expected_retrace = ["internal/cbm/grammar_go.c", "internal/cbm/grammar_json.c",
286+
"internal/cbm/ts_runtime.c", "vendored/sqlite3/sqlite3.c"]
287+
for path in expected_retrace:
288+
fixture = crlf_root / path
289+
fixture.parent.mkdir(parents=True, exist_ok=True)
290+
fixture.touch()
291+
(crlf_scripts / "select-lanes.sh").write_bytes(
292+
b"#!/usr/bin/env bash\nprintf '%s\\r\\n' "
293+
b"internal/cbm/vendored/grammars/go/parser.c internal/cbm/grammar_json.c "
294+
b"internal/cbm/ts_runtime.c vendored/sqlite3/sqlite3.c\n")
295+
proc = subprocess.run([bash, str(crlf_scripts / retrace.name),
296+
"--changed", str(changed), str(listed)],
297+
capture_output=True, text=True, env=env)
298+
got = listed.read_bytes() if listed.exists() else None
299+
if proc.returncode != 0 or got != ("\n".join(expected_retrace) + "\n").encode("utf-8"):
300+
failures.append(f"codeql CRLF: the retrace helper must preserve every changed "
301+
f"wrapper and write LF entrypoints, got {got!r} (exit {proc.returncode})")
302+
278303
for label, args in (("an unreadable change list", ["--changed", str(work / "missing.txt")]),
279304
("no pull request", [])):
280305
listed.write_text("stale\n", encoding="utf-8")

0 commit comments

Comments
 (0)