Skip to content

Commit

Permalink
Auto merge of #3145 - alexcrichton:rustdoc-cross-test, r=brson
Browse files Browse the repository at this point in the history
Test requested --target from source of truth

We skip doc tests for any cross compiles (as they don't work) but to detect a
cross compile we checked `--target` but forgot to check other locations like
`CARGO_BUILD_TARGET` or `[build.target]`. This alters the check to ensure that
it verifies from the source of truth whether a cross compilation happened or
not.

Closes #3143
  • Loading branch information
bors authored Oct 6, 2016
2 parents a713da1 + 9f1203f commit 885dc89
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/cargo/ops/cargo_rustc/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct Compilation<'cfg> {
/// Features enabled during this compilation.
pub cfgs: HashSet<String>,

pub target: String,

config: &'cfg Config,
}

Expand All @@ -60,6 +62,7 @@ impl<'cfg> Compilation<'cfg> {
to_doc_test: Vec::new(),
cfgs: HashSet::new(),
config: config,
target: String::new(),
}
}

Expand Down
1 change: 1 addition & 0 deletions src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>,
cx.compilation.native_dirs.insert(dir.clone());
}
}
cx.compilation.target = cx.target_triple().to_string();
Ok(cx.compilation)
}

Expand Down
6 changes: 2 additions & 4 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ fn run_doc_tests(options: &TestOptions,
let config = options.compile_opts.config;

// We don't build/rust doctests if target != host
if let Some(target) = options.compile_opts.target {
if try!(config.rustc()).host != target {
return Ok(errors);
}
if try!(config.rustc()).host != compilation.target {
return Ok(errors);
}

let libs = compilation.to_doc_test.iter().map(|package| {
Expand Down

0 comments on commit 885dc89

Please sign in to comment.