2016-05-26 00:06:25 +00:00
|
|
|
extern crate cargotest;
|
|
|
|
extern crate hamcrest;
|
|
|
|
|
|
|
|
use cargotest::support::{execs, project};
|
2015-09-09 08:46:43 +00:00
|
|
|
use hamcrest::{assert_that};
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn rustdoc_simple() {
|
2015-09-09 08:46:43 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#" "#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("rustdoc").arg("-v"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
2016-05-15 21:17:56 +00:00
|
|
|
.with_stderr(format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[DOCUMENTING] foo v0.0.1 ({url})
|
2016-11-30 20:05:23 +00:00
|
|
|
[RUNNING] `rustdoc --crate-name foo src[/]lib.rs \
|
2016-11-06 04:53:21 +00:00
|
|
|
-o {dir}[/]target[/]doc \
|
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
", dir = p.root().display(), url = p.url())));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn rustdoc_args() {
|
2015-09-09 08:46:43 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#" "#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("rustdoc").arg("-v").arg("--").arg("--no-defaults"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
2016-05-15 21:17:56 +00:00
|
|
|
.with_stderr(format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[DOCUMENTING] foo v0.0.1 ({url})
|
2016-11-30 20:05:23 +00:00
|
|
|
[RUNNING] `rustdoc --crate-name foo src[/]lib.rs \
|
2016-11-06 04:53:21 +00:00
|
|
|
-o {dir}[/]target[/]doc \
|
2015-09-09 08:46:43 +00:00
|
|
|
--no-defaults \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
", dir = p.root().display(), url = p.url())));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-09-09 08:46:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn rustdoc_foo_with_bar_dependency() {
|
2015-09-09 08:46:43 +00:00
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
pub fn foo() {}
|
|
|
|
"#);
|
|
|
|
let bar = project("bar")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
pub fn baz() {}
|
|
|
|
"#);
|
|
|
|
bar.build();
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("rustdoc").arg("-v").arg("--").arg("--no-defaults"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
2016-05-15 21:17:56 +00:00
|
|
|
.with_stderr(format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] bar v0.0.1 ([..])
|
2016-11-06 04:53:21 +00:00
|
|
|
[RUNNING] `rustc [..]bar[/]src[/]lib.rs [..]`
|
2016-05-11 16:55:43 +00:00
|
|
|
[DOCUMENTING] foo v0.0.1 ({url})
|
2016-11-30 20:05:23 +00:00
|
|
|
[RUNNING] `rustdoc --crate-name foo src[/]lib.rs \
|
2016-11-06 04:53:21 +00:00
|
|
|
-o {dir}[/]target[/]doc \
|
2015-09-09 08:46:43 +00:00
|
|
|
--no-defaults \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps \
|
2015-09-09 08:46:43 +00:00
|
|
|
--extern [..]`
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
", dir = foo.root().display(), url = foo.url())));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn rustdoc_only_bar_dependency() {
|
2015-09-09 08:46:43 +00:00
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
fn main() {
|
|
|
|
bar::baz()
|
|
|
|
}
|
|
|
|
"#);
|
|
|
|
let bar = project("bar")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
pub fn baz() {}
|
|
|
|
"#);
|
|
|
|
bar.build();
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("rustdoc").arg("-v").arg("-p").arg("bar")
|
|
|
|
.arg("--").arg("--no-defaults"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
2016-05-15 21:17:56 +00:00
|
|
|
.with_stderr(format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[DOCUMENTING] bar v0.0.1 ([..])
|
2016-11-30 20:05:23 +00:00
|
|
|
[RUNNING] `rustdoc --crate-name bar [..]bar[/]src[/]lib.rs \
|
2016-11-06 04:53:21 +00:00
|
|
|
-o {dir}[/]target[/]doc \
|
2015-09-09 08:46:43 +00:00
|
|
|
--no-defaults \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
", dir = foo.root().display())));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-09-09 08:46:43 +00:00
|
|
|
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn rustdoc_same_name_err() {
|
2015-09-09 08:46:43 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {}
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#" "#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("rustdoc").arg("-v")
|
|
|
|
.arg("--").arg("--no-defaults"),
|
|
|
|
execs()
|
|
|
|
.with_status(101)
|
2016-05-12 17:06:36 +00:00
|
|
|
.with_stderr("[ERROR] cannot document a package where a library and a \
|
2015-09-09 08:46:43 +00:00
|
|
|
binary have the same name. Consider renaming one \
|
2016-05-12 17:06:36 +00:00
|
|
|
or marking the target as `doc = false`"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|