diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-14 20:45:50 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-14 20:45:59 +0300 |
| commit | d3be4f8b431587b14975d0e595e4131e3c119bdb (patch) | |
| tree | 80bbbbf6c0ab295acb67cf6bdb05cc75f435e3f5 /tests/cli_wrapper.rs | |
| parent | 54b58bb3452bd493a2881623a01371705ff806f1 (diff) | |
fix: add best-effort windows plugin support
Diffstat (limited to 'tests/cli_wrapper.rs')
| -rw-r--r-- | tests/cli_wrapper.rs | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/tests/cli_wrapper.rs b/tests/cli_wrapper.rs index 0eb1b82d..95d14860 100644 --- a/tests/cli_wrapper.rs +++ b/tests/cli_wrapper.rs @@ -16,6 +16,8 @@ use support::{ unregister_spawned_herdr_pid, }; +const WORKTREE_BOOTSTRAP_MANAGED_COMPONENT: &str = "example.worktree-bootstrap-ef876653ffc3"; + fn unique_test_dir() -> PathBuf { let nanos = SystemTime::now() .duration_since(UNIX_EPOCH) @@ -24,6 +26,18 @@ fn unique_test_dir() -> PathBuf { PathBuf::from(format!("/tmp/hcli-{}-{nanos}", std::process::id())) } +fn managed_github_plugin_dir(config_home: &Path) -> PathBuf { + config_home.join("herdr-dev").join("plugins").join("github") +} + +fn path_missing_or_empty(path: &Path) -> bool { + match fs::read_dir(path) { + Ok(mut entries) => entries.next().is_none(), + Err(err) if err.kind() == std::io::ErrorKind::NotFound => true, + Err(err) => panic!("failed to read {}: {err}", path.display()), + } +} + fn run_git(repo: &Path, args: &[&str]) { let status = Command::new("git") .arg("-C") @@ -3214,14 +3228,9 @@ command = ["sh", "-c", "echo should-not-install"] ); assert!(listed["result"]["plugins"].as_array().unwrap().is_empty()); - let managed_checkout = config_home - .join("herdr-dev") - .join("plugins") - .join("github") - .join("example.build-fail"); assert!( - !managed_checkout.exists(), - "failed build should not create managed checkout" + path_missing_or_empty(&managed_github_plugin_dir(&config_home)), + "failed build should not leave managed checkouts" ); cleanup_test_base(&base); @@ -3406,14 +3415,9 @@ EOF ); assert!(listed["result"]["plugins"].as_array().unwrap().is_empty()); - let managed_checkout = config_home - .join("herdr-dev") - .join("plugins") - .join("github") - .join("example.manifest-mutator"); assert!( - !managed_checkout.exists(), - "manifest mutation should not create managed checkout" + path_missing_or_empty(&managed_github_plugin_dir(&config_home)), + "manifest mutation should not leave managed checkouts" ); cleanup_test_base(&base); @@ -3456,7 +3460,7 @@ command = ["sh", "-c", "echo new"] .join("herdr-dev") .join("plugins") .join("github") - .join("example.worktree-bootstrap"); + .join(WORKTREE_BOOTSTRAP_MANAGED_COMPONENT); fs::create_dir_all(&managed_checkout).unwrap(); fs::write(managed_checkout.join("old-marker"), "old checkout\n").unwrap(); @@ -3586,7 +3590,7 @@ command = ["sh", "-c", "echo install"] .join("herdr-dev") .join("plugins") .join("github") - .join("example.worktree-bootstrap"); + .join(WORKTREE_BOOTSTRAP_MANAGED_COMPONENT); let git_config = base.join("gitconfig"); fs::write( &git_config, @@ -3721,7 +3725,7 @@ command = ["sh", "-c", "echo install"] .join("herdr-dev") .join("plugins") .join("github") - .join("example.worktree-bootstrap"); + .join(WORKTREE_BOOTSTRAP_MANAGED_COMPONENT); let git_config = base.join("gitconfig"); fs::write( &git_config, |
