fix: normalize runtime workspace bootstrap
This commit is contained in:
parent
b6029220ff
commit
1f69061956
|
|
@ -1,5 +1,8 @@
|
||||||
# Dogfood Workspace Backend configuration.
|
[server]
|
||||||
# Repository URI values are resolved from this workspace config root.
|
|
||||||
|
[data]
|
||||||
|
|
||||||
|
[limits]
|
||||||
|
|
||||||
[[repositories]]
|
[[repositories]]
|
||||||
id = "main"
|
id = "main"
|
||||||
|
|
@ -7,3 +10,8 @@ provider = "git"
|
||||||
uri = "."
|
uri = "."
|
||||||
display_name = "Yoi"
|
display_name = "Yoi"
|
||||||
default_selector = "HEAD"
|
default_selector = "HEAD"
|
||||||
|
|
||||||
|
[[runtimes.remote]]
|
||||||
|
id = "arc"
|
||||||
|
endpoint = "http://127.0.0.1:38800"
|
||||||
|
display_name = "arc"
|
||||||
|
|
|
||||||
|
|
@ -215,12 +215,33 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_store_selection(&mut config.http, store)?;
|
apply_store_selection(&mut config.http, store)?;
|
||||||
|
config.workspace_root = normalize_workspace_path(config.workspace_root)?;
|
||||||
if config.cwd.as_os_str().is_empty() {
|
if config.cwd.as_os_str().is_empty() {
|
||||||
config.cwd = config.workspace_root.clone();
|
config.cwd = config.workspace_root.clone();
|
||||||
|
} else {
|
||||||
|
config.cwd = normalize_child_path(&config.workspace_root, config.cwd);
|
||||||
}
|
}
|
||||||
Ok(Some(config))
|
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> {
|
fn split_flag_value(arg: String) -> Result<(String, Option<String>), ProcessError> {
|
||||||
if !arg.starts_with('-') {
|
if !arg.starts_with('-') {
|
||||||
return Err(ProcessError::usage(format!(
|
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]
|
#[test]
|
||||||
fn parses_memory_runtime_process_config() {
|
fn parses_memory_runtime_process_config() {
|
||||||
let config = parse_args([
|
let config = parse_args([
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user