mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 03:32:39 +00:00
Adding release flag to cargo test
This commit is contained in:
parent
3499c8ec8e
commit
1f99ed0b6a
|
@ -15,6 +15,7 @@ struct Options {
|
||||||
flag_package: Option<String>,
|
flag_package: Option<String>,
|
||||||
flag_target: Option<String>,
|
flag_target: Option<String>,
|
||||||
flag_verbose: bool,
|
flag_verbose: bool,
|
||||||
|
flag_release: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const USAGE: &'static str = "
|
pub const USAGE: &'static str = "
|
||||||
|
@ -30,6 +31,7 @@ Options:
|
||||||
--no-run Compile, but don't run tests
|
--no-run Compile, but don't run tests
|
||||||
-p SPEC, --package SPEC Package to run tests for
|
-p SPEC, --package SPEC Package to run tests for
|
||||||
-j N, --jobs N The number of jobs to run in parallel
|
-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
|
--features FEATURES Space-separated list of features to also build
|
||||||
--no-default-features Do not build the `default` feature
|
--no-default-features Do not build the `default` feature
|
||||||
--target TRIPLE Build for the target triple
|
--target TRIPLE Build for the target triple
|
||||||
|
@ -72,7 +74,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
|
||||||
no_default_features: options.flag_no_default_features,
|
no_default_features: options.flag_no_default_features,
|
||||||
spec: options.flag_package.as_ref().map(|s| &s[..]),
|
spec: options.flag_package.as_ref().map(|s| &s[..]),
|
||||||
exec_engine: None,
|
exec_engine: None,
|
||||||
release: false,
|
release: options.flag_release,
|
||||||
mode: ops::CompileMode::Test,
|
mode: ops::CompileMode::Test,
|
||||||
filter: if tests.is_empty() && bins.is_empty() {
|
filter: if tests.is_empty() && bins.is_empty() {
|
||||||
ops::CompileFilter::Everything
|
ops::CompileFilter::Everything
|
||||||
|
|
|
@ -46,6 +46,54 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
||||||
RUNNING)));
|
RUNNING)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test!(cargo_test_release {
|
||||||
|
let p = project("foo")
|
||||||
|
.file("src/lib.rs", r#"
|
||||||
|
extern crate bar as the_bar;
|
||||||
|
|
||||||
|
pub fn bar() { the_bar::baz(); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn foo() { bar(); }
|
||||||
|
"#)
|
||||||
|
.file("tests/test.rs", r#"
|
||||||
|
extern crate foo as the_foo;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn foo() { the_foo::bar(); }
|
||||||
|
"#)
|
||||||
|
.file("bar/Cargo.toml", r#"
|
||||||
|
[package]
|
||||||
|
name = "bar"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = []
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "bar"
|
||||||
|
crate_type = ["dylib"]
|
||||||
|
"#)
|
||||||
|
.file("bar/src/lib.rs", "
|
||||||
|
pub fn baz() {}
|
||||||
|
");
|
||||||
|
|
||||||
|
assert_that(p.cargo_process("test").arg("-v").arg("--release"),
|
||||||
|
execs().with_stdout(format!("\
|
||||||
|
{compiling} bar v0.0.1 ({dir})
|
||||||
|
{running} [..] -C opt-level=3 [..]
|
||||||
|
{compiling} foo v0.0.1 ({dir})
|
||||||
|
{running} [..] -C opt-level=3 [..]
|
||||||
|
{running} [..] -C opt-level=3 [..]
|
||||||
|
{running} `[..]target[..]foo-[..]`
|
||||||
|
|
||||||
|
running 1 test
|
||||||
|
test test_hello ... ok
|
||||||
|
|
||||||
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
||||||
|
|
||||||
|
",
|
||||||
|
compiling = COMPILING, dir = p.url(), running = RUNNING)));
|
||||||
|
});
|
||||||
|
|
||||||
test!(cargo_test_verbose {
|
test!(cargo_test_verbose {
|
||||||
let p = project("foo")
|
let p = project("foo")
|
||||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||||
|
|
Loading…
Reference in a new issue