Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --release flag to cargo doc #1973

Merged
merged 1 commit into from
Sep 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bin/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct Options {
flag_no_deps: bool,
flag_open: bool,
flag_verbose: bool,
flag_release: bool,
flag_quiet: bool,
flag_color: Option<String>,
flag_package: Option<String>,
Expand All @@ -29,6 +30,7 @@ Options:
-p SPEC, --package SPEC Package to document
--no-deps Don't build documentation for dependencies
-j N, --jobs N The number of jobs to run in parallel
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
--target TRIPLE Build for the target triple
Expand Down Expand Up @@ -63,7 +65,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
spec: options.flag_package.as_ref().map(|s| &s[..]),
exec_engine: None,
filter: ops::CompileFilter::Everything,
release: false,
release: options.flag_release,
mode: ops::CompileMode::Doc {
deps: !options.flag_no_deps,
},
Expand Down
22 changes: 21 additions & 1 deletion tests/test_cargo_doc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use support::{project, execs, path2url};
use support::COMPILING;
use support::{COMPILING, RUNNING};
use hamcrest::{assert_that, existing_file, existing_dir, is_not};

fn setup() {
Expand Down Expand Up @@ -347,3 +347,23 @@ test!(target_specific_documented {
assert_that(p.cargo_process("doc"),
execs().with_status(0));
});

test!(doc_release {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
"#)
.file("src/lib.rs", "");

assert_that(p.cargo_process("build").arg("--release"),
execs().with_status(0));
assert_that(p.cargo("doc").arg("--release").arg("-v"),
execs().with_status(0)
.with_stdout(&format!("\
{compiling} foo v0.0.1 ([..])
{running} `rustdoc src[..]lib.rs [..]`
", compiling = COMPILING, running = RUNNING)));
});