use std::fs;
use std::path::Path;
use std::process::Command;
#[test]
fn test_basic_build_succeeds() {
let output = Command::new("cargo")
.args(["build", "--release"])
.output()
.expect("Failed to execute cargo build");
assert!(
output.status.success(),
"Basic build should succeed. stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
let binary_path = "target/release/codex-memory";
assert!(
Path::new(binary_path).exists(),
"Binary should exist at {}",
binary_path
);
}
#[test]
fn test_build_with_no_default_features() {
let output = Command::new("cargo")
.args(["build", "--release", "--no-default-features"])
.output()
.expect("Failed to execute cargo build with no default features");
assert!(
output.status.success(),
"Build with no default features should succeed. stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
}
#[test]
fn test_check_passes_without_features() {
let output = Command::new("cargo")
.args(["check"])
.output()
.expect("Failed to execute cargo check");
assert!(
output.status.success(),
"Cargo check without features should pass. stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
}
#[test]
fn test_installation() {
let output = Command::new("cargo")
.args(["install", "--path", ".", "--force"])
.output()
.expect("Failed to execute cargo install");
assert!(
output.status.success(),
"Installation should succeed. stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
}
#[test]
fn test_binary_name_consistency() {
let cargo_toml = fs::read_to_string("Cargo.toml").expect("Should be able to read Cargo.toml");
assert!(
cargo_toml.contains("name = \"codex-memory\""),
"Package name should be codex-memory"
);
let binary_path = "target/release/codex-memory";
assert!(
Path::new(binary_path).exists(),
"Binary should be named codex-memory"
);
}