diff --git a/eden/fs/cli_rs/edenfs-commands/Cargo.toml b/eden/fs/cli_rs/edenfs-commands/Cargo.toml index 3a94a85145ce4..9a629cd3763e4 100644 --- a/eden/fs/cli_rs/edenfs-commands/Cargo.toml +++ b/eden/fs/cli_rs/edenfs-commands/Cargo.toml @@ -20,6 +20,7 @@ dunce = "1.0.2" edenfs-client = { version = "0.1.0", path = "../edenfs-client" } edenfs-error = { version = "0.1.0", path = "../edenfs-error" } edenfs-utils = { version = "0.1.0", path = "../edenfs-utils" } +fail = { version = "0.4", features = ["failpoints"] } futures = { version = "0.3.30", features = ["async-await", "compat"] } hex = "0.4.3" hg_util = { package = "sapling-util", version = "0.1.0", path = "../../../scm/lib/util" } diff --git a/eden/fs/cli_rs/edenfs-commands/TARGETS b/eden/fs/cli_rs/edenfs-commands/TARGETS index 1e90402ee268c..1056a6dc149ca 100644 --- a/eden/fs/cli_rs/edenfs-commands/TARGETS +++ b/eden/fs/cli_rs/edenfs-commands/TARGETS @@ -35,6 +35,7 @@ rust_library( "fbsource//third-party/rust:dialoguer", "fbsource//third-party/rust:dirs", "fbsource//third-party/rust:dunce", + "fbsource//third-party/rust:fail", "fbsource//third-party/rust:futures", "fbsource//third-party/rust:hex", "fbsource//third-party/rust:once_cell", diff --git a/eden/fs/cli_rs/edenfs-commands/src/remove.rs b/eden/fs/cli_rs/edenfs-commands/src/remove.rs index a051c82b16544..fcd7de7db8d10 100644 --- a/eden/fs/cli_rs/edenfs-commands/src/remove.rs +++ b/eden/fs/cli_rs/edenfs-commands/src/remove.rs @@ -28,6 +28,7 @@ use edenfs_client::checkout::get_mounts; use edenfs_client::fsutil::forcefully_remove_dir_all; use edenfs_client::EdenFsInstance; use edenfs_utils::bytes_from_path; +use fail::fail_point; use io::IO; use termlogger::TermLogger; use tracing::debug; @@ -333,6 +334,10 @@ async fn validate_state_run(context: &mut RemoveContext) -> Result return Err(anyhow!("Repo {} is still mounted", context)); } + fail_point!("remove:validate", |_| { + Err(anyhow!("failpoint: expected failure")) + }); + // check directory clean up if !context.preserve_mount_point { match context.canonical_path.try_exists() { diff --git a/eden/scm/tests/test-eden-remove.t b/eden/scm/tests/test-eden-remove.t index c38a05077e532..708c17791d4c5 100644 --- a/eden/scm/tests/test-eden-remove.t +++ b/eden/scm/tests/test-eden-remove.t @@ -59,3 +59,13 @@ check to make sure the mount point is cleanly removed $ ls $TESTTMP/wcrepo ls: $TESTTMP/wcrepo: $ENOENT$ [1] + +reclone a repo for testing validation error + $ eden clone --allow-empty-repo $TESTTMP/backingrepo $TESTTMP/wcrepo + Cloning new repository at $TESTTMP/wcrepo... + Success. Checked out commit 00000000 + +remove with failpoint set so the validation step will fail + $ FAILPOINTS=remove:validate=return EDENFSCTL_ONLY_RUST=true eden remove -q -y $TESTTMP/wcrepo/ + Error: failpoint: expected failure + [1]