fix: normalize runtime workspace bootstrap

This commit is contained in:
2026-07-07 03:27:12 +09:00
parent b6029220ff
commit 1f69061956
2 changed files with 42 additions and 2 deletions
+32
View File
@@ -215,12 +215,33 @@ where
}
apply_store_selection(&mut config.http, store)?;
config.workspace_root = normalize_workspace_path(config.workspace_root)?;
if config.cwd.as_os_str().is_empty() {
config.cwd = config.workspace_root.clone();
} else {
config.cwd = normalize_child_path(&config.workspace_root, config.cwd);
}
Ok(Some(config))
}
fn normalize_workspace_path(path: PathBuf) -> Result<PathBuf, ProcessError> {
let absolute = if path.is_absolute() {
path
} else {
env::current_dir()?.join(path)
};
Ok(absolute.canonicalize().unwrap_or(absolute))
}
fn normalize_child_path(base: &std::path::Path, path: PathBuf) -> PathBuf {
if path.is_absolute() {
path.canonicalize().unwrap_or(path)
} else {
let absolute = base.join(path);
absolute.canonicalize().unwrap_or(absolute)
}
}
fn split_flag_value(arg: String) -> Result<(String, Option<String>), ProcessError> {
if !arg.starts_with('-') {
return Err(ProcessError::usage(format!(
@@ -395,6 +416,17 @@ mod tests {
);
}
#[test]
fn normalizes_relative_workspace_for_worker_spawn() {
let current_dir = env::current_dir().unwrap().canonicalize().unwrap();
let config = parse_args(["--workspace", ".", "--cwd", "."])
.unwrap()
.unwrap();
assert_eq!(config.workspace_root, current_dir);
assert_eq!(config.cwd, current_dir);
}
#[test]
fn parses_memory_runtime_process_config() {
let config = parse_args([