From: Ian Jackson Date: Mon, 3 May 2021 11:47:29 +0000 (+0100) Subject: path resolution tests: cd to / for library_load and specs X-Git-Tag: otter-0.6.0~455 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f230da44541724544146f9bf0f967210a9816343;p=otter.git path resolution tests: cd to / for library_load and specs This tests that both client and server path resolution works. Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 8d82797b..f1966f14 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -199,6 +199,17 @@ impl Ctx { su_rc: self.su_rc.clone(), } } + + pub fn chdir_root(&mut self, f: F) + where F: FnOnce(&mut Self) -> Result<(),AE> + { + let tmp = &(*self.su_rc).borrow().ds.abstmp.clone(); + env::set_current_dir("/").expect("cd /"); + self.rctx = ResolveContext::RelativeTo(tmp.clone()); + f(self).expect("run test"); + env::set_current_dir(&tmp).expect("cd back"); + self.rctx = default(); + } } mod pi { @@ -683,9 +694,9 @@ impl Ctx { #[throws(AE)] fn tests(mut c: Ctx) { - test!(c, "library-load", c.library_load()?); - test!(c, "hidden-hand", c.hidden_hand()?); - test!(c, "specs", c.specs()?); + test!(c, "library-load", c.chdir_root(|c| c.library_load() )); + test!(c, "hidden-hand", c.hidden_hand() ?); + test!(c, "specs", c.chdir_root(|c| c.specs() )); } #[throws(AE)]