test: point doc tests to the main library, for cyclic deps.

Previously a dependency cycle like `a` <-(normal)- `b` <-(dev)- `a`
would mean that importing `b` in `a`'s doc test would fail because the
original `a` library was not found.

Fixes #1686.
This commit is contained in:
Huon Wilson 2015-06-06 18:22:36 +10:00
parent 3b164462d6
commit eca88fd2f6
2 changed files with 53 additions and 5 deletions

View file

@ -38,13 +38,13 @@ pub fn run_tests(manifest_path: &Path,
let mut p = try!(compile.rustdoc_process(&compile.package));
p.arg("--test").arg(lib)
.arg("--crate-name").arg(&crate_name)
.arg("-L").arg(&{
let mut arg = OsString::from("dependency=");
arg.push(&compile.deps_output);
arg
})
.cwd(compile.package.root());
for &rust_dep in &[&compile.deps_output, &compile.root_output] {
let mut arg = OsString::from("dependency=");
arg.push(rust_dep);
p.arg("-L").arg(arg);
}
for native_dep in compile.native_dirs.values() {
p.arg("-L").arg(native_dep);
}

View file

@ -1582,3 +1582,51 @@ test!(dylib_doctest2 {
assert_that(p.cargo_process("test"),
execs().with_stdout(""));
});
test!(cyclic_dev_dep_doc_test {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dev-dependencies]
bar = { path = "bar" }
"#)
.file("src/lib.rs", r#"
//! ```
//! extern crate bar;
//! ```
"#)
.file("bar/Cargo.toml", r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
[dependencies]
foo = { path = ".." }
"#)
.file("bar/src/lib.rs", r#"
extern crate foo;
"#);
assert_that(p.cargo_process("test"),
execs().with_stdout(format!("\
{compiling} foo v0.0.1 ([..])
{compiling} bar v0.0.1 ([..])
{running} target[..]foo[..]
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
{doctest} foo
running 1 test
test _0 ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
", compiling = COMPILING, running = RUNNING, doctest = DOCTEST)))
});