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:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user