cargo/tests/testsuite/rustdoc.rs

174 lines
4.7 KiB
Rust
Raw Normal View History

use cargotest::support::{execs, project};
use hamcrest::{assert_that};
#[test]
fn rustdoc_simple() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
"#)
.file("src/lib.rs", r#" "#)
.build();
assert_that(p.cargo("rustdoc").arg("-v"),
execs()
.with_status(0)
2016-05-15 21:17:56 +00:00
.with_stderr(format!("\
[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`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2016-11-06 04:53:21 +00:00
", dir = p.root().display(), url = p.url())));
}
#[test]
fn rustdoc_args() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
"#)
.file("src/lib.rs", r#" "#)
.build();
assert_that(p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
execs()
.with_status(0)
2016-05-15 21:17:56 +00:00
.with_stderr(format!("\
[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 \
--cfg=foo \
2016-11-06 04:53:21 +00:00
-L dependency={dir}[/]target[/]debug[/]deps`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2016-11-06 04:53:21 +00:00
", dir = p.root().display(), url = p.url())));
}
#[test]
fn rustdoc_foo_with_bar_dependency() {
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() {}
"#)
.build();
let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
"#)
.build();
assert_that(foo.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
execs()
.with_status(0)
2016-05-15 21:17:56 +00:00
.with_stderr(format!("\
[COMPILING] bar v0.0.1 ([..])
2016-11-06 04:53:21 +00:00
[RUNNING] `rustc [..]bar[/]src[/]lib.rs [..]`
[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 \
--cfg=foo \
2016-11-06 04:53:21 +00:00
-L dependency={dir}[/]target[/]debug[/]deps \
--extern [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2016-11-06 04:53:21 +00:00
", dir = foo.root().display(), url = foo.url())));
}
#[test]
fn rustdoc_only_bar_dependency() {
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()
}
"#)
.build();
let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
"#)
.build();
assert_that(foo.cargo("rustdoc").arg("-v").arg("-p").arg("bar")
.arg("--").arg("--cfg=foo"),
execs()
.with_status(0)
2016-05-15 21:17:56 +00:00
.with_stderr(format!("\
[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 \
--cfg=foo \
2016-11-06 04:53:21 +00:00
-L dependency={dir}[/]target[/]debug[/]deps`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2016-11-06 04:53:21 +00:00
", dir = foo.root().display())));
}
#[test]
fn rustdoc_same_name_documents_lib() {
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#" "#)
.build();
assert_that(p.cargo("rustdoc").arg("-v")
.arg("--").arg("--cfg=foo"),
execs()
.with_status(0)
.with_stderr(format!("\
[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 [..]
", dir = p.root().display())));
}