feat: Add integration test suite for v1.1.0 commands

Adds WEEVIL_HOME-based test isolation so cargo test never touches
the real system. All commands run against a fresh TempDir per test.

Environment tests cover doctor, uninstall, new, and setup across
every combination of missing/present dependencies. Project lifecycle
tests cover creation, config persistence, upgrade, and build scripts.

Full round-trip lifecycle test: new → gradlew test → gradlew
compileJava → uninstall → doctor (unhealthy) → setup → doctor
(healthy). Confirms skeleton projects build and pass tests out of
the box, and that uninstall leaves user projects untouched.

34 tests, zero warnings.
This commit is contained in:
Eric Ratliff
2026-01-31 13:44:27 -06:00
parent 78abe1d65c
commit d2cc62e32f
11 changed files with 647 additions and 169 deletions

View File

@@ -101,7 +101,9 @@ pub fn uninstall_dependencies(dry_run: bool, targets: Option<Vec<usize>>) -> Res
/// Full uninstall — removes the entire .weevil directory
fn full_uninstall(sdk_config: &SdkConfig, dry_run: bool) -> Result<()> {
if !sdk_config.cache_dir.exists() {
let all_targets = scan_targets(sdk_config);
if all_targets.is_empty() {
println!("{}", "No Weevil-managed components found.".bright_green());
println!();
return Ok(());
@@ -110,7 +112,6 @@ fn full_uninstall(sdk_config: &SdkConfig, dry_run: bool) -> Result<()> {
let size = dir_size(&sdk_config.cache_dir);
if dry_run {
let all_targets = scan_targets(sdk_config);
println!("{}", "── Dry Run ─────────────────────────────────────────────────".bright_yellow().bold());
println!();

View File

@@ -15,15 +15,26 @@ pub struct SdkConfig {
impl SdkConfig {
pub fn new() -> Result<Self> {
let home = dirs::home_dir()
.context("Could not determine home directory")?;
// Allow tests (or power users) to override the cache directory.
// When WEEVIL_HOME is set, we also skip the system Android SDK
// search so tests are fully isolated.
let (cache_dir, android_sdk_path) = if let Ok(weevil_home) = std::env::var("WEEVIL_HOME") {
let cache = PathBuf::from(weevil_home);
let android = cache.join("android-sdk");
(cache, android)
} else {
let home = dirs::home_dir()
.context("Could not determine home directory")?;
let cache = home.join(".weevil");
let android = Self::find_android_sdk().unwrap_or_else(|| cache.join("android-sdk"));
(cache, android)
};
let cache_dir = home.join(".weevil");
fs::create_dir_all(&cache_dir)?;
Ok(Self {
ftc_sdk_path: cache_dir.join("ftc-sdk"),
android_sdk_path: Self::find_android_sdk().unwrap_or_else(|| cache_dir.join("android-sdk")),
android_sdk_path,
cache_dir,
})
}