2016-05-26 00:06:25 +00:00
|
|
|
use cargotest::support::{execs, project};
|
2018-03-14 15:17:44 +00:00
|
|
|
use hamcrest::assert_that;
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn rustdoc_simple() {
|
2015-09-09 08:46:43 +00:00
|
|
|
let p = project("foo")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustdoc").arg("-v"),
|
|
|
|
execs().with_status(0).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`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +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")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
|
|
|
|
execs().with_status(0).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 \
|
2017-08-30 14:50:40 +00:00
|
|
|
--cfg=foo \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +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")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
extern crate bar;
|
|
|
|
pub fn foo() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
|
|
|
let _bar = project("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
pub fn baz() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
foo.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
|
|
|
|
execs().with_status(0).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 \
|
2017-08-30 14:50:40 +00:00
|
|
|
--cfg=foo \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps \
|
2015-09-09 08:46:43 +00:00
|
|
|
--extern [..]`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +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")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
extern crate bar;
|
|
|
|
fn main() {
|
|
|
|
bar::baz()
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
|
|
|
let _bar = project("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
pub fn baz() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
foo.cargo("rustdoc")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("-p")
|
|
|
|
.arg("bar")
|
|
|
|
.arg("--")
|
|
|
|
.arg("--cfg=foo"),
|
|
|
|
execs().with_status(0).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 \
|
2017-08-30 14:50:40 +00:00
|
|
|
--cfg=foo \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +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]
|
2017-10-16 16:30:57 +00:00
|
|
|
fn rustdoc_same_name_documents_lib() {
|
2015-09-09 08:46:43 +00:00
|
|
|
let p = project("foo")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-09-09 08:46:43 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-09-09 08:46:43 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
|
|
|
|
execs().with_status(0).with_stderr(format!(
|
|
|
|
"\
|
2017-10-16 16:30:57 +00:00
|
|
|
[DOCUMENTING] foo v0.0.1 ([..])
|
|
|
|
[RUNNING] `rustdoc --crate-name foo src[/]lib.rs \
|
|
|
|
-o {dir}[/]target[/]doc \
|
|
|
|
--cfg=foo \
|
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
dir = p.root().display()
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2018-03-27 22:56:46 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn features() {
|
|
|
|
let p = project("foo")
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[features]
|
|
|
|
quux = []
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("rustdoc --verbose --features quux"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr_contains("[..]feature=[..]quux[..]"),
|
|
|
|
);
|
|
|
|
}
|