chiark / gitweb /
path resolution tests: cd to / for library_load and specs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 3 May 2021 11:47:29 +0000 (12:47 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 3 May 2021 11:48:52 +0000 (12:48 +0100)
This tests that both client and server path resolution works.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs

index 8d82797b2ed1c48839d52cb7929ccbc9aba49bed..f1966f14bddef87ead37bf64c0109008e2154864 100644 (file)
@@ -199,6 +199,17 @@ impl Ctx {
       su_rc: self.su_rc.clone(),
     }
   }
+
+  pub fn chdir_root<F>(&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)]