Fixing rustdoc stage1.

See #13983 and #14000.

Fix was originally authored by alexcrichton and then rebased a couple
times by pnkfelix, most recently atop PR 13954.

----

Regarding the change to librustdoc/lib.rs, to do `map_err` before
unwrapping a `TqskResult`: I do not understand how master is passing
without this change or something like it, since `Box<Any:Send>` does
not implement `Show`.  (Is this something that is only a problem for
the snapshot stage0 compiler?)  Still, the change I have put in here
(which was added as part of a rebase after alex's review) seems
harmless to me to apply to rustdoc at all stages, since a call to
`unwrap` is just going to `fail!` on the err case anyway.
This commit is contained in:
Felix S. Klock II
2014-05-15 19:28:46 +02:00
parent 63287eef27
commit eb6856c307
5 changed files with 100 additions and 63 deletions

View File

@@ -15,6 +15,7 @@ use std::io::{Command, TempDir};
use std::os;
use std::str;
use std::strbuf::StrBuf;
use std::unstable::dynamic_lib::DynamicLibrary;
use collections::{HashSet, HashMap};
use testing;
@@ -150,12 +151,37 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool,
let outdir = TempDir::new("rustdoctest").expect("rustdoc needs a tempdir");
let out = Some(outdir.path().clone());
let cfg = config::build_configuration(&sess);
let libdir = sess.target_filesearch().get_lib_path();
driver::compile_input(sess, cfg, &input, &out, &None);
if no_run { return }
// Run the code!
match Command::new(outdir.path().join("rust_out")).output() {
//
// We're careful to prepend the *target* dylib search path to the child's
// environment to ensure that the target loads the right libraries at
// runtime. It would be a sad day if the *host* libraries were loaded as a
// mistake.
let exe = outdir.path().join("rust_out");
let env = {
let mut path = DynamicLibrary::search_path();
path.insert(0, libdir.clone());
// Remove the previous dylib search path var
let var = DynamicLibrary::envvar();
let mut env: Vec<(~str,~str)> = os::env().move_iter().collect();
match env.iter().position(|&(ref k, _)| k.as_slice() == var) {
Some(i) => { env.remove(i); }
None => {}
};
// Add the new dylib search path var
let newpath = DynamicLibrary::create_path(path.as_slice());
env.push((var.to_owned(),
str::from_utf8(newpath.as_slice()).unwrap().to_owned()));
env
};
match Command::new(exe).env(env.as_slice()).output() {
Err(e) => fail!("couldn't run the test: {}{}", e,
if e.kind == io::PermissionDenied {
" - maybe your tempdir is mounted with noexec?"