Skip to content

Commit

Permalink
Auto merge of #1149 - rndr:issue-1146, r=alexcrichton
Browse files Browse the repository at this point in the history
Closes #1146
  • Loading branch information
bors committed Jan 11, 2015
2 parents c2c6f40 + db73829 commit 027c815
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/bin/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));

let env = match (options.flag_release, options.flag_example.is_some()) {
(true, true) => "bench",
(true, false) => "release",
(true, _) => "release",
(false, true) => "test",
(false, false) => "compile"
};
Expand Down
7 changes: 0 additions & 7 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,6 @@ impl Profile {
}
}

pub fn default_example_release() -> Profile {
Profile {
test: false,
.. Profile::default_bench()
}
}

pub fn default_release() -> Profile {
Profile {
env: "release".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ fn normalize(libs: &[TomlLibTarget],
let path = ex.path.clone().unwrap_or_else(|| PathValue::String(default(ex)));

let profile = merge(Profile::default_example(), &profiles.test);
let profile_release = merge(Profile::default_example_release(), &profiles.release);
let profile_release = merge(Profile::default_release(), &profiles.release);
dst.push(Target::example_target(ex.name.as_slice(),
&path.to_path(),
&profile));
Expand Down
79 changes: 79 additions & 0 deletions tests/test_cargo_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,3 +785,82 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
",
running = RUNNING)));
});

test!(bench_with_examples {
let p = project("testbench")
.file("Cargo.toml", r#"
[package]
name = "testbench"
version = "6.6.6"
authors = []
[[example]]
name = "teste1"
[[bench]]
name = "testb1"
"#)
.file("src/lib.rs", r#"
extern crate test;
use test::Bencher;
pub fn f1() {
println!("f1");
}
pub fn f2() {}
#[bench]
fn bench_bench1(_b: &mut Bencher) {
f2();
}
"#)
.file("benches/testb1.rs", "
extern crate testbench;
extern crate test;
use test::Bencher;
#[bench]
fn bench_bench2(_b: &mut Bencher) {
testbench::f2();
}
")
.file("examples/teste1.rs", r#"
extern crate testbench;
fn main() {
println!("example1");
testbench::f1();
}
"#);

assert_that(p.cargo_process("bench").arg("-v"),
execs().with_status(0)
.with_stdout(format!("\
{compiling} testbench v6.6.6 ({url})
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name testbench --crate-type lib [..]`
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name testbench --crate-type lib [..]`
{running} `rustc benches{sep}testb1.rs --crate-name testb1 --crate-type bin \
[..] --test [..]`
{running} `{dir}{sep}target{sep}release{sep}testb1-[..] --bench`
running 1 test
test bench_bench2 ... bench: 0 ns/iter (+/- 0)
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
{running} `{dir}{sep}target{sep}release{sep}testbench-[..] --bench`
running 1 test
test bench_bench1 ... bench: 0 ns/iter (+/- 0)
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
",
compiling = COMPILING,
running = RUNNING,
dir = p.root().display(),
url = p.url(),
sep = path::SEP).as_slice()));
});

0 comments on commit 027c815

Please sign in to comment.