fix(foreign): resolve Windows PATH executables with PATHEXT
ci/woodpecker/push/woodpecker Pipeline was successful
Linux strict security lane (G-C) / strict isolation escape matrix (push) Canceled after 0s
CI / fmt + clippy + test (Linux x86_64) (push) Canceled after 0s
CI / schema instance validation + consumers (push) Canceled after 0s
CI / runtime contract (macos-latest) (push) Canceled after 0s
CI / runtime contract (windows-latest) (push) Canceled after 0s
CI / release evidence manifest (push) Canceled after 0s
CI / release candidate artifact (macos-latest) (push) Canceled after 0s
CI / release candidate artifact (ubuntu-latest) (push) Canceled after 0s

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:
cflmy committed 2026-11-21 18:22:22 +08:00
1 parent d441d6f4cc
commit 3a29fce061
5 files changed
+151 -20

No files matched your search

+4 -6
View File
@@ -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
+46 -3
View File
@@ -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)");