mirror of
https://github.com/instructkr/claw-code.git
synced 2026-11-18 00:00:00 +08:00
fix(windows): fix native runtime compatibility and enable workspace t… (#3378)
* fix(windows): fix native runtime compatibility and enable workspace tests Fix shell discovery, hook quoting, native path handling and OAuth randomness on Windows, make the test fixtures portable, and run the full workspace test suite in the Windows CI job. * test(plugins): make lifecycle fixtures Windows-compatible * fix(windows): address workspace test failures --------- Co-authored-by: clawdbot <clawdbot@ultraworkers.dev>
This commit is contained in:
1 parent
ca48ec7500
commit
407a6c62f8
31 files changed
+873
-371
No files matched your search
@@ -1443,7 +1443,6 @@ mod tests {
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs;
|
||||
use std::io::ErrorKind;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
@@ -1466,6 +1465,9 @@ mod tests {
|
||||
};
|
||||
use crate::McpLifecyclePhase;
|
||||
|
||||
// Fixtures are interpreter inputs, not directly executable Unix scripts.
|
||||
const TEST_PYTHON: &str = if cfg!(windows) { "python" } else { "python3" };
|
||||
|
||||
fn temp_dir() -> PathBuf {
|
||||
static NEXT_TEMP_DIR_ID: AtomicU64 = AtomicU64::new(0);
|
||||
let nanos = SystemTime::now()
|
||||
@@ -1479,15 +1481,19 @@ mod tests {
|
||||
fn write_echo_script() -> PathBuf {
|
||||
let root = temp_dir();
|
||||
fs::create_dir_all(&root).expect("temp dir");
|
||||
let script_path = root.join("echo-mcp.sh");
|
||||
fs::write(
|
||||
&script_path,
|
||||
"#!/bin/sh\nprintf 'READY:%s\\n' \"$MCP_TEST_TOKEN\"\nIFS= read -r line\nprintf 'ECHO:%s\\n' \"$line\"\n",
|
||||
)
|
||||
.expect("write script");
|
||||
let mut permissions = fs::metadata(&script_path).expect("metadata").permissions();
|
||||
permissions.set_mode(0o755);
|
||||
fs::set_permissions(&script_path, permissions).expect("chmod");
|
||||
let script_path = root.join("echo-mcp.py");
|
||||
let script = [
|
||||
"import os, sys",
|
||||
r"ready = ('READY:' + os.environ['MCP_TEST_TOKEN'] + '\n').encode()",
|
||||
"sys.stdout.buffer.write(ready)",
|
||||
"sys.stdout.buffer.flush()",
|
||||
"line = sys.stdin.buffer.readline()",
|
||||
r"sys.stdout.buffer.write(b'ECHO:' + line.rstrip(b'\r\n') + b'\n')",
|
||||
"sys.stdout.buffer.flush()",
|
||||
"",
|
||||
]
|
||||
.join("\n");
|
||||
fs::write(&script_path, script).expect("write script");
|
||||
script_path
|
||||
}
|
||||
|
||||
@@ -1531,9 +1537,6 @@ mod tests {
|
||||
]
|
||||
.join("\n");
|
||||
fs::write(&script_path, script).expect("write script");
|
||||
let mut permissions = fs::metadata(&script_path).expect("metadata").permissions();
|
||||
permissions.set_mode(0o755);
|
||||
fs::set_permissions(&script_path, permissions).expect("chmod");
|
||||
script_path
|
||||
}
|
||||
|
||||
@@ -1665,9 +1668,6 @@ mod tests {
|
||||
]
|
||||
.join("\n");
|
||||
fs::write(&script_path, script).expect("write script");
|
||||
let mut permissions = fs::metadata(&script_path).expect("metadata").permissions();
|
||||
permissions.set_mode(0o755);
|
||||
fs::set_permissions(&script_path, permissions).expect("chmod");
|
||||
script_path
|
||||
}
|
||||
|
||||
@@ -1790,9 +1790,6 @@ mod tests {
|
||||
]
|
||||
.join("\n");
|
||||
fs::write(&script_path, script).expect("write script");
|
||||
let mut permissions = fs::metadata(&script_path).expect("metadata").permissions();
|
||||
permissions.set_mode(0o755);
|
||||
fs::set_permissions(&script_path, permissions).expect("chmod");
|
||||
script_path
|
||||
}
|
||||
|
||||
@@ -1801,7 +1798,7 @@ mod tests {
|
||||
required: false,
|
||||
scope: ConfigSource::Local,
|
||||
config: McpServerConfig::Stdio(McpStdioServerConfig {
|
||||
command: "/bin/sh".to_string(),
|
||||
command: TEST_PYTHON.to_string(),
|
||||
args: vec![script_path.to_string_lossy().into_owned()],
|
||||
env: BTreeMap::from([("MCP_TEST_TOKEN".to_string(), "secret-value".to_string())]),
|
||||
tool_call_timeout_ms: None,
|
||||
@@ -1819,7 +1816,7 @@ mod tests {
|
||||
env: BTreeMap<String, String>,
|
||||
) -> crate::mcp_client::McpStdioTransport {
|
||||
crate::mcp_client::McpStdioTransport {
|
||||
command: "python3".to_string(),
|
||||
command: TEST_PYTHON.to_string(),
|
||||
args: vec![script_path.to_string_lossy().into_owned()],
|
||||
env,
|
||||
tool_call_timeout_ms: None,
|
||||
@@ -1869,7 +1866,7 @@ mod tests {
|
||||
required: false,
|
||||
scope: ConfigSource::Local,
|
||||
config: McpServerConfig::Stdio(McpStdioServerConfig {
|
||||
command: "python3".to_string(),
|
||||
command: TEST_PYTHON.to_string(),
|
||||
args: vec![script_path.to_string_lossy().into_owned()],
|
||||
env,
|
||||
tool_call_timeout_ms: None,
|
||||
@@ -2089,7 +2086,7 @@ mod tests {
|
||||
runtime.block_on(async {
|
||||
let script_path = write_echo_script();
|
||||
let transport = crate::mcp_client::McpStdioTransport {
|
||||
command: "/bin/sh".to_string(),
|
||||
command: TEST_PYTHON.to_string(),
|
||||
args: vec![script_path.to_string_lossy().into_owned()],
|
||||
env: BTreeMap::from([("MCP_TEST_TOKEN".to_string(), "direct-secret".to_string())]),
|
||||
tool_call_timeout_ms: None,
|
||||
@@ -2349,7 +2346,7 @@ mod tests {
|
||||
required: false,
|
||||
scope: ConfigSource::Local,
|
||||
config: McpServerConfig::Stdio(McpStdioServerConfig {
|
||||
command: "python3".to_string(),
|
||||
command: TEST_PYTHON.to_string(),
|
||||
args: vec![script_path.to_string_lossy().into_owned()],
|
||||
env: BTreeMap::from([(
|
||||
"MCP_TOOL_CALL_DELAY_MS".to_string(),
|
||||
@@ -2403,7 +2400,7 @@ mod tests {
|
||||
required: false,
|
||||
scope: ConfigSource::Local,
|
||||
config: McpServerConfig::Stdio(McpStdioServerConfig {
|
||||
command: "python3".to_string(),
|
||||
command: TEST_PYTHON.to_string(),
|
||||
args: vec![script_path.to_string_lossy().into_owned()],
|
||||
env: BTreeMap::from([(
|
||||
"MCP_INVALID_TOOL_CALL_RESPONSE".to_string(),
|
||||
@@ -2714,9 +2711,6 @@ mod tests {
|
||||
]
|
||||
.join("\n");
|
||||
fs::write(&script_path, script).expect("write script");
|
||||
let mut permissions = fs::metadata(&script_path).expect("metadata").permissions();
|
||||
permissions.set_mode(0o755);
|
||||
fs::set_permissions(&script_path, permissions).expect("chmod");
|
||||
script_path
|
||||
}
|
||||
|
||||
@@ -2742,8 +2736,8 @@ mod tests {
|
||||
required: true,
|
||||
scope: ConfigSource::Local,
|
||||
config: McpServerConfig::Stdio(McpStdioServerConfig {
|
||||
command: broken_script_path.display().to_string(),
|
||||
args: Vec::new(),
|
||||
command: TEST_PYTHON.to_string(),
|
||||
args: vec![broken_script_path.to_string_lossy().into_owned()],
|
||||
env: BTreeMap::new(),
|
||||
tool_call_timeout_ms: None,
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user