diff --git a/radicle-cli/tests/commands.rs b/radicle-cli/tests/commands.rs index ac9bff51..04dc5d0c 100644 --- a/radicle-cli/tests/commands.rs +++ b/radicle-cli/tests/commands.rs @@ -9,7 +9,8 @@ use framework::TestFormula; /// Run a CLI test file. fn test( - path: impl AsRef, + test: impl AsRef, + cwd: impl AsRef, profile: Option<&Profile>, ) -> Result<(), Box> { let base = Path::new(env!("CARGO_MANIFEST_DIR")); @@ -24,7 +25,8 @@ fn test( .env("RAD_PASSPHRASE", "radicle") .env("RAD_HOME", home.to_string_lossy()) .env("RAD_DEBUG", "1") - .file(base.join(path))? + .cwd(cwd) + .file(base.join(test))? .run()?; Ok(()) @@ -40,7 +42,7 @@ fn profile(home: &Path) -> Profile { #[test] fn rad_auth() { - test("examples/rad-auth.md", None).unwrap(); + test("examples/rad-auth.md", Path::new("."), None).unwrap(); } #[test] @@ -51,12 +53,11 @@ fn rad_issue() { // Setup a test repository. fixtures::repository(working.path()); - // Navigate to repository. - env::set_current_dir(working.path()).unwrap(); + // Set a fixed commit time. env::set_var(radicle_cob::git::RAD_COMMIT_TIME, "1671125284"); - test("examples/rad-init.md", Some(&profile)).unwrap(); - test("examples/rad-issue.md", Some(&profile)).unwrap(); + test("examples/rad-init.md", working.path(), Some(&profile)).unwrap(); + test("examples/rad-issue.md", working.path(), Some(&profile)).unwrap(); } #[test] @@ -67,10 +68,8 @@ fn rad_init() { // Setup a test repository. fixtures::repository(working.path()); - // Navigate to repository. - env::set_current_dir(working.path()).unwrap(); - test("examples/rad-init.md", Some(&profile)).unwrap(); + test("examples/rad-init.md", working.path(), Some(&profile)).unwrap(); } #[test] @@ -81,9 +80,7 @@ fn rad_delegate() { // Setup a test repository. fixtures::repository(working.path()); - // Navigate to repository. - env::set_current_dir(working.path()).unwrap(); - test("examples/rad-init.md", Some(&profile)).unwrap(); - test("examples/rad-delegate.md", Some(&profile)).unwrap(); + test("examples/rad-init.md", working.path(), Some(&profile)).unwrap(); + test("examples/rad-delegate.md", working.path(), Some(&profile)).unwrap(); } diff --git a/radicle-cli/tests/framework/mod.rs b/radicle-cli/tests/framework/mod.rs index 368cf015..68a75ec3 100644 --- a/radicle-cli/tests/framework/mod.rs +++ b/radicle-cli/tests/framework/mod.rs @@ -139,6 +139,7 @@ impl TestFormula { Command::new(program) .envs(self.env.clone()) + .current_dir(&self.cwd) .args(&assertion.args) .with_assert(assert.clone()) .assert()