-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cargo-codspeed): handle working-directory when using workspaces
- Loading branch information
Showing
11 changed files
with
164 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
crates/cargo-codspeed/tests/crates_working_directory.in/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Cargo.lock | ||
target/ |
2 changes: 2 additions & 0 deletions
2
crates/cargo-codspeed/tests/crates_working_directory.in/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[workspace] | ||
members = ["the_crate"] |
14 changes: 14 additions & 0 deletions
14
crates/cargo-codspeed/tests/crates_working_directory.in/the_crate/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "the_crate" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
bencher = "0.1.5" | ||
codspeed = { path = "../../../../codspeed" } | ||
codspeed-bencher-compat = { path = "../../../../bencher_compat" } | ||
|
||
[[bench]] | ||
name = "bencher_example" | ||
harness = false |
12 changes: 12 additions & 0 deletions
12
crates/cargo-codspeed/tests/crates_working_directory.in/the_crate/benches/bencher_example.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::hint::black_box; | ||
|
||
use codspeed_bencher_compat::{benchmark_group, benchmark_main, Bencher}; | ||
|
||
pub fn a(bench: &mut Bencher) { | ||
// Open ./input.txt file | ||
std::fs::read_to_string("./input.txt").expect("Failed to read file"); | ||
bench.iter(|| (0..100).fold(0, |x, y| black_box(x + y))) | ||
} | ||
|
||
benchmark_group!(benches, a); | ||
benchmark_main!(benches); |
1 change: 1 addition & 0 deletions
1
crates/cargo-codspeed/tests/crates_working_directory.in/the_crate/input.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use predicates::str::contains; | ||
|
||
mod helpers; | ||
use helpers::*; | ||
|
||
const DIR: &str = "tests/crates_working_directory.in"; | ||
|
||
#[test] | ||
fn test_crates_working_directory_build_and_run_explicit() { | ||
let dir = setup(DIR, Project::CratesWorkingDirectory); | ||
cargo_codspeed(&dir) | ||
.args(["build", "-p", "the_crate"]) | ||
.assert() | ||
.success(); | ||
cargo_codspeed(&dir) | ||
.args(["run", "-p", "the_crate"]) | ||
.assert() | ||
.success() | ||
.stderr(contains("Finished running 1 benchmark suite(s)")); | ||
teardown(dir); | ||
} | ||
|
||
#[test] | ||
fn test_crates_working_directory_build_and_run_implicit() { | ||
let dir = setup(DIR, Project::CratesWorkingDirectory); | ||
cargo_codspeed(&dir) | ||
.args(["build", "-p", "the_crate"]) | ||
.assert() | ||
.success(); | ||
cargo_codspeed(&dir) | ||
.arg("run") | ||
.assert() | ||
.success() | ||
.stderr(contains("Finished running 1 benchmark suite(s)")); | ||
teardown(dir); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters