-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Better error message needed when user creates a bench
rather than a benches
dir
#9014
Comments
That's weird. I just implemented this test and it passes: #[cargo_test]
fn external_bench_warns_wrong_path() {
if !is_nightly() {
return;
}
let p = project()
.file(
"src/lib.rs",
r#"
#![feature(test)]
#[cfg(test)]
extern crate test;
pub fn get_hello() -> &'static str { "Hello" }
"#,
)
.file(
"./bench/external.rs",
r#"
#![feature(test)]
#[allow(unused_extern_crates)]
extern crate foo;
extern crate test;
#[bench]
fn external_bench(_b: &mut test::Bencher) {()}
"#,
)
.build();
p.cargo("bench")
.with_stderr_contains("can't find `[..]` bench, specify `[..]`")
.run();
} @gilescope was the |
In the above case it's not erroring but not running any benchmarks either I think? Looking back I was using criterion (sorry) and so had this in the Cargo.toml:
That at least errored (but didn't point out what the error was). I think Criterion could do with an upgradeed error message (assuming the error message above is ultimately created by criterion) and rust's bench could do with emitting a warning that while no benchmarks were found there's suspiciously a |
It is, the bench runs and works. that's why the test fails if I include So basically I asume (maybe @ehuss or @Eh2406 can bring some light here) that adding this
And I guess that this is the problem. When the Criterion Again I might be wrong, but looks to me that this can be closed and the issue should be opened in Criterion instead. |
@CPerezz I think you may be misunderstanding the issue. The issue is that specifying a bench target like this in [[bench]]
name = "mybench" And you place the file in I think there are two parts to improve the message here:
It would be nice if these better error messages worked for all of the target types ( |
@ehuss I understood the problem. But I wrongly thought that was Will start working on it if it's ok with you! I'll probably push a PR for |
As it was stated in rust-lang#9014 it's not really useful the message that you get when using `bench/your_bench.rs` instead of the correct path `benches/your_bench.rs`. Therefore, as @ehuss suggested, the error message has been improved not only suggesting the correct path but also suggesting to specify `bench.path` in `Cargo.toml` for non-default path usage. And this has been exented to `test`, `example` and `bin`.
@CPerezz are you still planning to work on this? If not, I could.. |
I completely forgot about this after polling @CPerezz. I think you're clear to continue! |
Hey. Feel free to work on it! I´ve been extremely bussy.. Apologies
…On Fri, 10 Sept 2021 at 19:57, Dustin J. Mitchell ***@***.***> wrote:
I completely forgot about this after polling @CPerezz
<https://github.com/CPerezz>. I think you're clear to continue!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9014 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI4J4HRWANCWCHAXL7A7ZEDUBJBHDANCNFSM4VH7JGXQ>
.
|
A common error with benchmarking is to call the dir
bench
rather thanbenches
.This is the error message a user currently gets:
It fails the
esteban
test as it doesn't hint as to what we've done wrong.At a minimum can we change it to this please?
That way they stand a chance of spotting there's an issue. Personally I think it's worth testing for a
bench
dir and having an explicit message because so many people must do this and then kick themselves when the penny drops.The text was updated successfully, but these errors were encountered: