diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e209015..6155534 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,18 @@ jobs: - run: cargo test --locked - run: cargo install cargo-deny --locked --version 0.20.2 && cargo deny check + macos: + runs-on: macos-15 + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - run: rustup show active-toolchain + - run: cargo fmt --check + - run: cargo clippy --locked --all-targets -- -D warnings + - run: cargo test --locked + windows: runs-on: windows-2025 timeout-minutes: 30 diff --git a/tests/agent_install.rs b/tests/agent_install.rs index e02c9f4..7a691cf 100644 --- a/tests/agent_install.rs +++ b/tests/agent_install.rs @@ -24,8 +24,9 @@ fn command(binary: &Path, home: &Path) -> Command { #[test] fn unattended_registration_preserves_settings_and_uses_the_installed_binary() { let root = TempDir::new().unwrap(); - let home = root.path().join("home"); - let directory = root.path().join("install with spaces 東京"); + let root_path = root.path().canonicalize().unwrap(); + let home = root_path.join("home"); + let directory = root_path.join("install with spaces 東京"); fs::create_dir_all(&home).unwrap(); fs::create_dir_all(&directory).unwrap(); let binary = directory.join(if cfg!(windows) { @@ -75,6 +76,15 @@ fn unattended_registration_preserves_settings_and_uses_the_installed_binary() { server }; assert_eq!(server["command"], executable.to_str().unwrap()); + let configured_cmd = server["command"].as_str().unwrap(); + let check = command(Path::new(configured_cmd), &home) + .arg("--version") + .output() + .unwrap(); + assert!( + check.status.success(), + "configured executable must be runnable at its configured path" + ); assert_eq!( server["args"], json!(["--base-url", "https://proofline.sh", "mcp"]) @@ -91,9 +101,10 @@ fn unattended_registration_preserves_settings_and_uses_the_installed_binary() { #[test] fn install_messages_name_the_configuration_by_its_plain_path() { let root = TempDir::new().unwrap(); + let root_path = root.path().canonicalize().unwrap(); // A space and a backslash would show as escapes in a quoted Debug path; // Windows paths hold backslashes already. - let home = root.path().join(if cfg!(windows) { + let home = root_path.join(if cfg!(windows) { "home with space" } else { "home with \\ space" @@ -194,3 +205,65 @@ fn without_git_registration_names_the_recovery_and_a_repository_still_refuses() assert!(refused.contains("Git working tree") && !refused.contains("install Git")); assert_eq!(fs::read_dir(&home).unwrap().count(), 1); } + +#[cfg(unix)] +#[test] +fn unattended_registration_via_symlink_configures_runnable_binary() { + let root = TempDir::new().unwrap(); + let root_path = root.path().canonicalize().unwrap(); + let home = root_path.join("home"); + let bin_dir = root_path.join("bin"); + fs::create_dir_all(&home).unwrap(); + fs::create_dir_all(&bin_dir).unwrap(); + let binary = bin_dir.join("proofline-target"); + fs::copy(env!("CARGO_BIN_EXE_proofline"), &binary).unwrap(); + let symlink = bin_dir.join("proofline-symlink"); + std::os::unix::fs::symlink(&binary, &symlink).unwrap(); + + let path = home.join(".claude.json"); + let original = json!({"mcpServers": {}}).to_string(); + fs::write(&path, &original).unwrap(); + + let installed = command(&symlink, &home) + .args(["agent", "install", "claude-code", "--yes"]) + .output() + .unwrap(); + assert!( + installed.status.success(), + "{}", + String::from_utf8_lossy(&installed.stderr) + ); + + let bytes = fs::read_to_string(&path).unwrap(); + let mut config: Value = serde_json::from_str(&bytes).unwrap(); + let server = config["mcpServers"] + .as_object_mut() + .unwrap() + .remove("proofline") + .unwrap(); + let configured_cmd = server["command"].as_str().unwrap(); + let configured_path = Path::new(configured_cmd); + #[cfg(target_os = "macos")] + assert_eq!( + configured_path, symlink, + "macOS preserves the invocation path through the symlink" + ); + #[cfg(target_os = "linux")] + assert_eq!( + configured_path, binary, + "Linux resolves the symlink to the target binary" + ); + assert_eq!( + configured_path.canonicalize().unwrap(), + binary.canonicalize().unwrap(), + "symlink invocation must configure a path resolving to the target binary" + ); + let check = command(Path::new(configured_cmd), &home) + .arg("--version") + .output() + .unwrap(); + assert!( + check.status.success(), + "configured executable must be runnable" + ); +}