fix(foreign): resolve Windows PATH executables with PATHEXT
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
Linux strict security lane (G-C) / strict isolation escape matrix (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
Linux strict security lane (G-C) / strict isolation escape matrix (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
The built-in Python provider scanned PATH for the extension-less token python3; a Windows PATH contains python3.exe, so a working interpreter was reported as kernel.unavailable and the semantic golden suite failed on windows-latest. Expand candidates with PATHEXT (conservative default) and use the same platform-aware resolver in the conformance test's availability probe. Also make native failures diagnosable: strip ANSI before matching and emit the panic/build context as public check annotations, and run Linux tests through the same annotator. This fixes the Windows native lane and gives the macOS failure the context needed to diagnose it.
This commit is contained in:
1 parent
d441d6f4cc
commit
3a29fce061
5 files changed
+151
-20
No files matched your search
+14
-11
@@ -24,7 +24,17 @@ jobs:
|
||||
- name: Clippy
|
||||
run: cargo clippy --workspace --all-targets -- -D warnings
|
||||
- name: Tests
|
||||
run: cargo test --workspace
|
||||
shell: bash
|
||||
run: |
|
||||
set +e
|
||||
CARGO_TERM_COLOR=never cargo test --workspace 2>&1 | tee workspace-tests.log
|
||||
status=${PIPESTATUS[0]}
|
||||
set -e
|
||||
if [ "$status" -ne 0 ]; then
|
||||
python3 tools/ci/annotate_workspace_tests.py \
|
||||
workspace-tests.log "Linux workspace tests"
|
||||
fi
|
||||
exit "$status"
|
||||
- name: Documentation consistency
|
||||
run: cargo test -p marqdo-cli --test docs_consistency
|
||||
- name: Architecture boundaries
|
||||
@@ -127,19 +137,12 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
set +e
|
||||
cargo test --workspace 2>&1 | tee workspace-tests.log
|
||||
CARGO_TERM_COLOR=never cargo test --workspace 2>&1 | tee workspace-tests.log
|
||||
status=${PIPESTATUS[0]}
|
||||
set -e
|
||||
if [ "$status" -ne 0 ]; then
|
||||
# Surface the failing test/build context as check annotations so a
|
||||
# native-matrix failure is diagnosable without admin log access.
|
||||
{
|
||||
grep -n -A 18 -B 2 "panicked at" workspace-tests.log || true
|
||||
grep -n -A 6 -B 2 "^error" workspace-tests.log || true
|
||||
grep -n "test .* FAILED" workspace-tests.log || true
|
||||
} | head -80 | while IFS= read -r line; do
|
||||
echo "::error title=Workspace tests on ${{ matrix.os }}::$line"
|
||||
done
|
||||
python3 tools/ci/annotate_workspace_tests.py \
|
||||
workspace-tests.log "Workspace tests on ${{ matrix.os }}"
|
||||
fi
|
||||
exit "$status"
|
||||
- name: Portable CLI, analysis and trace smoke
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use marqdo_host::{Capabilities, Host, StdHost};
|
||||
use marqdo_ir::{ModuleId, Program, ResolvedImport};
|
||||
@@ -68,11 +67,10 @@ fn expected_path(fixture: &Path) -> PathBuf {
|
||||
}
|
||||
|
||||
fn python_available() -> bool {
|
||||
Command::new("python3")
|
||||
.arg("--version")
|
||||
.output()
|
||||
.map(|output| output.status.success())
|
||||
.unwrap_or(false)
|
||||
// Ask the same platform-aware resolver the runtime uses. On Windows a
|
||||
// PATH entry is `python3.exe`, not the extension-less `python3` token, so a
|
||||
// raw `Command::new("python3")` probe can disagree with execution.
|
||||
marqdo_foreign::detect("python").is_some()
|
||||
}
|
||||
|
||||
/// Unique scratch directory for the host project root. Program fixtures are
|
||||
|
||||
@@ -864,6 +864,27 @@ fn execute(request: &RunRequest, registry: &KernelRegistry) -> Result<RawRun, Fo
|
||||
})
|
||||
}
|
||||
|
||||
/// Expand a PATH lookup name to the platform's executable file names.
|
||||
///
|
||||
/// Unix uses the name verbatim. Windows applies `PATHEXT` (with a conservative
|
||||
/// default) because a PATH directory contains `python3.exe`, never `python3`.
|
||||
fn executable_candidates(name: &str) -> Vec<std::ffi::OsString> {
|
||||
// Only the Windows branch appends suffixes, so `mut` is unused on Unix.
|
||||
#[allow(unused_mut)]
|
||||
let mut names = vec![std::ffi::OsString::from(name)];
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if Path::new(name).extension().is_none() {
|
||||
let extensions =
|
||||
std::env::var("PATHEXT").unwrap_or_else(|_| ".COM;.EXE;.BAT;.CMD".to_string());
|
||||
for extension in extensions.split(';').filter(|value| !value.is_empty()) {
|
||||
names.push(std::ffi::OsString::from(format!("{name}{extension}")));
|
||||
}
|
||||
}
|
||||
}
|
||||
names
|
||||
}
|
||||
|
||||
fn program_candidates(language: &str) -> &'static [&'static str] {
|
||||
match language {
|
||||
"python" => &["python3", "python"],
|
||||
@@ -973,9 +994,14 @@ fn resolve_program(descriptor: &KernelDescriptor) -> Result<PathBuf, ForeignErro
|
||||
let candidates = program_candidates(&descriptor.provider_id);
|
||||
for name in candidates {
|
||||
for directory in std::env::split_paths(&path_var) {
|
||||
let candidate = directory.join(name);
|
||||
if is_executable_file(&candidate) {
|
||||
return Ok(candidate);
|
||||
// Windows PATH entries contain `python.exe`, not the extension-less
|
||||
// `python3` token `Command::new` accepts. Scanning PATH manually
|
||||
// must apply PATHEXT or a valid interpreter is reported missing.
|
||||
for executable in executable_candidates(name) {
|
||||
let candidate = directory.join(executable);
|
||||
if is_executable_file(&candidate) {
|
||||
return Ok(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1394,6 +1420,23 @@ mod tests {
|
||||
assert_eq!(normalize_language(""), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_lookup_expands_windows_executable_suffixes() {
|
||||
let names = executable_candidates("python3");
|
||||
#[cfg(windows)]
|
||||
{
|
||||
assert!(names.iter().any(|name| {
|
||||
name.to_string_lossy()
|
||||
.to_ascii_lowercase()
|
||||
.ends_with(".exe")
|
||||
}));
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
assert_eq!(names.len(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn request_envelope_is_versioned() {
|
||||
let mut request = RunRequest::new("python", "print(1)");
|
||||
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Emit GitHub check annotations from a cargo-test log.
|
||||
|
||||
Native jobs (Windows/macOS) and the Linux gate tee `cargo test --workspace` to
|
||||
a file. Public check-run annotations are then the only failure detail visible
|
||||
without repository-admin log access. ANSI colour codes are stripped first so
|
||||
anchored patterns still match.
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
MAX_ANNOTATIONS = 60
|
||||
ANSI = re.compile(r"\x1b\[[0-9;]*m")
|
||||
|
||||
|
||||
def escape(text: str) -> str:
|
||||
return text.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")
|
||||
|
||||
|
||||
def interesting_lines(lines: list[str]) -> list[tuple[int, str]]:
|
||||
selected: list[tuple[int, str]] = []
|
||||
seen: set[int] = set()
|
||||
|
||||
def add(index: int) -> None:
|
||||
if 0 <= index < len(lines) and index not in seen:
|
||||
seen.add(index)
|
||||
selected.append((index, lines[index]))
|
||||
|
||||
for index, line in enumerate(lines):
|
||||
if "panicked at" in line:
|
||||
for offset in range(-2, 19):
|
||||
add(index + offset)
|
||||
elif line.startswith("failures:") or line.startswith("---- "):
|
||||
for offset in range(0, 6):
|
||||
add(index + offset)
|
||||
elif re.match(r"^error(\[|:)", line):
|
||||
for offset in range(-1, 7):
|
||||
add(index + offset)
|
||||
elif "test " in line and line.endswith("FAILED"):
|
||||
add(index)
|
||||
return sorted(selected)
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
if len(argv) < 2:
|
||||
print("usage: annotate_workspace_tests.py <log> [title]", file=sys.stderr)
|
||||
return 2
|
||||
log = sys.argv[1]
|
||||
title = sys.argv[2] if len(argv) > 2 else "Workspace tests"
|
||||
try:
|
||||
text = open(log, encoding="utf-8", errors="replace").read()
|
||||
except OSError as error:
|
||||
print(f"::error title={title}::cannot read test log: {error}")
|
||||
return 0
|
||||
lines = ANSI.sub("", text).splitlines()
|
||||
for _, line in interesting_lines(lines)[:MAX_ANNOTATIONS]:
|
||||
print(f"::error title={title}::{escape(line)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main(sys.argv))
|
||||
@@ -0,0 +1,24 @@
|
||||
import importlib.util
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
MODULE = Path(__file__).with_name("annotate_workspace_tests.py")
|
||||
spec = importlib.util.spec_from_file_location("annotate", MODULE)
|
||||
annotate = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(annotate)
|
||||
|
||||
|
||||
class AnnotateTests(unittest.TestCase):
|
||||
def test_strips_ansi_and_keeps_panic_context(self) -> None:
|
||||
text = "\x1b[31mthread 'x' panicked at file.rs:1\x1b[0m\nvalue mismatch\nexpected 1\nactual 2\n"
|
||||
lines = annotate.ANSI.sub("", text).splitlines()
|
||||
selected = [line for _, line in annotate.interesting_lines(lines)]
|
||||
self.assertIn("thread 'x' panicked at file.rs:1", selected)
|
||||
self.assertIn("value mismatch", selected)
|
||||
|
||||
def test_escapes_github_commands(self) -> None:
|
||||
self.assertEqual(annotate.escape("a%b\r\nc"), "a%25b%0D%0Ac")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user