Kept the owner's structure and wording in README.md, install.sh and summit-cli; carried over the verify run's fixes that his rewrite did not already make: install --no-deps, cargo's real target dir, dry-run venv path, XWayland detection through the X server's client pids, the replay default for a new user (also on the remote-play and capture-card launches), unbuffered engine output, doctor's hedged wording. Report: docs/agent-reports/reconcile.md. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
96 lines
4.2 KiB
Rust
96 lines
4.2 KiB
Rust
//! `install.sh --dry-run` as a new user would run it: a prefix in their own home must need no sudo, `--no-deps`
|
|
//! must not touch the system package manager, and the dry run must show the venv where the real run makes it.
|
|
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
fn script() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../install.sh")
|
|
}
|
|
|
|
fn dry_run(prefix: &std::path::Path, extra: &[&str]) -> String {
|
|
let out = Command::new("sh")
|
|
.arg(script())
|
|
.arg("--dry-run")
|
|
.args(extra)
|
|
.env("SUMMIT_PREFIX", prefix)
|
|
.env("SUMMIT_SRC_DIR", PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../.."))
|
|
.output()
|
|
.expect("run install.sh");
|
|
assert!(out.status.success(), "install.sh failed: {}", String::from_utf8_lossy(&out.stderr));
|
|
String::from_utf8_lossy(&out.stdout).into_owned()
|
|
}
|
|
|
|
#[test]
|
|
fn user_prefix_needs_no_sudo() {
|
|
let dir = std::env::temp_dir().join(format!("summit-install-test-{}", std::process::id()));
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
let prefix = dir.join("prefix");
|
|
let out = dry_run(&prefix, &["--no-deps"]);
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
assert!(!out.contains("sudo"), "a prefix the user can write needs no sudo:\n{out}");
|
|
assert!(out.contains("install -Dm755"), "{out}");
|
|
}
|
|
|
|
#[test]
|
|
fn no_deps_skips_the_package_manager() {
|
|
let dir = std::env::temp_dir().join(format!("summit-install-test-nd-{}", std::process::id()));
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
let out = dry_run(&dir.join("p"), &["--no-deps"]);
|
|
let with = dry_run(&dir.join("p"), &[]);
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
for pm in ["pacman", "apt-get", "dnf", "zypper"] {
|
|
assert!(!out.contains(pm), "--no-deps must not call {pm}:\n{out}");
|
|
}
|
|
assert!(out.contains("--no-deps"), "{out}");
|
|
// Without it the installer still installs the system packages (on a known distro).
|
|
assert!(with.contains("Installing build and runtime dependencies") || with.contains("skipping package manager"), "{with}");
|
|
}
|
|
|
|
#[test]
|
|
fn dry_run_shows_the_venv_in_the_install_prefix() {
|
|
let dir = std::env::temp_dir().join(format!("summit-install-test-venv-{}", std::process::id()));
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
let prefix = dir.join("p");
|
|
let out = dry_run(&prefix, &["--no-deps"]);
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
let want = format!("uv venv --clear --python 3.12 {}/share/summit/engine/.venv", prefix.display());
|
|
assert!(out.contains(&want), "expected `{want}` in:\n{out}");
|
|
}
|
|
|
|
#[test]
|
|
fn installs_the_binaries_from_where_cargo_puts_them() {
|
|
// A user with CARGO_TARGET_DIR set has no $SRC/target: the first real run on the owner's desktop died on
|
|
// `install: cannot stat .../src/target/release/summit`.
|
|
let dir = std::env::temp_dir().join(format!("summit-install-test-tgt-{}", std::process::id()));
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
let out = Command::new("sh")
|
|
.arg(script())
|
|
.args(["--dry-run", "--no-deps"])
|
|
.env("SUMMIT_PREFIX", dir.join("p"))
|
|
.env("SUMMIT_SRC_DIR", PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../.."))
|
|
.env("CARGO_TARGET_DIR", "/somewhere/else/target")
|
|
.output()
|
|
.unwrap();
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
let out = String::from_utf8_lossy(&out.stdout);
|
|
assert!(out.contains("install -Dm755 /somewhere/else/target/release/summit "), "{out}");
|
|
}
|
|
|
|
#[test]
|
|
fn running_the_installer_again_keeps_the_venv() {
|
|
// `uv venv` fails on an existing venv ("A virtual environment already exists"): the second run, to update, died there.
|
|
let dir = std::env::temp_dir().join(format!("summit-install-test-again-{}", std::process::id()));
|
|
let prefix = dir.join("p");
|
|
let py = prefix.join("share/summit/engine/.venv/bin/python");
|
|
std::fs::create_dir_all(py.parent().unwrap()).unwrap();
|
|
std::fs::write(&py, "#!/bin/sh\n").unwrap();
|
|
use std::os::unix::fs::PermissionsExt;
|
|
std::fs::set_permissions(&py, std::fs::Permissions::from_mode(0o755)).unwrap();
|
|
let out = dry_run(&prefix, &["--no-deps"]);
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
assert!(!out.contains("uv venv"), "{out}");
|
|
assert!(out.contains("keeping the existing venv"), "{out}");
|
|
assert!(out.contains("uv pip install"), "{out}");
|
|
}
|