$OpenBSD: patch-src_librustdoc_test_rs,v 1.14 2018/02/23 16:38:16 landry Exp $
fallback to LOCALBASE as default sysroot.
Index: src/librustdoc/test.rs
--- src/librustdoc/test.rs.orig
+++ src/librustdoc/test.rs
@@ -66,7 +66,10 @@ pub fn run(input_path: &Path,
 
     let sessopts = config::Options {
         maybe_sysroot: maybe_sysroot.clone().or_else(
-            || Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
+            || match option_env!("LOCALBASE") {
+                Some(dir) => return Some(PathBuf::from(dir)),
+                None => panic!("can't determine value for sysroot"),
+            }),
         search_paths: libs.clone(),
         crate_types: vec![config::CrateTypeDylib],
         externs: externs.clone(),
@@ -195,7 +198,10 @@ fn run_test(test: &str, cratename: &str, filename: &Fi
 
     let sessopts = config::Options {
         maybe_sysroot: maybe_sysroot.or_else(
-            || Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
+            || match option_env!("LOCALBASE") {
+                Some(dir) => return Some(PathBuf::from(dir)),
+                None => panic!("can't determine value for sysroot"),
+            }),
         search_paths: libs,
         crate_types: vec![config::CrateTypeExecutable],
         output_types: outputs,
