-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Finalize story for libtest #20603
Finalize story for libtest #20603
Conversation
r? @nick29581 (rust_highfive has picked a reviewer for you, use r? to override) |
2f0c0c1
to
2a0f1c1
Compare
LGTM. @brson are you comfortable with this strategy? |
2a0f1c1
to
15bbe16
Compare
@aturon I'm not sure yet. |
I don't know that I'm comfortable stabilizing and standardizing a crate called 'rustc_something'. This is a crate that will need to be implemented and supplied by all Rust implementations. Is the motivation here to save the name |
My bigger concerns around stability of |
If we're uncomfortable exposing a good crate name here we could instead inject a 'std test' prelude - this arguably seems better to me anyway since |
One of the last remaining crates to have a stabilization story in the standard distribution is the libtest library. This library currently provides the backing infrastructure and test harness used when rustc generates a test execuable via the `--test` command line flag. It's well known that libtest is not the end-all-be-all of testing frameworks. It is intentionally minimal and is currently quite conservative in its scope of what it tries to accomplish as well as what it implements. A testament to this is the fact that one very rarely writes `extern crate test`, and it almost means that the stabilization story need not be considered for the crate at all! The benchmarking feature of the compiler, however, is quite useful and is one of the sole reasons for using `extern crate test`. When benchmarking, there are a few primary interfaces to the libtest library that are used: * `test::Bencher` - the type for a benchmarking harness. * `test::Bencher::iter` - a member function used to run a benchmark. * `test::black_box` - a useful function to hinder optimizations and prevent a value from being optimized away. These three pieces of information are the primary targets for the stabilization in this commit. The rest of the testing infrastructure, while still quite useful to some projects, is not in scope for stabilization at 1.0 and will remain `#[experimental]` for now. The benchmarking pieces have been moved to a new `rustc_bench` crate which will be part of the standard distribution. In order to write a benchmark one will need to import the crate via `extern crate rustc_bench` and otherwise all usage remains the same. The purpose of this crate is to provide a clear area for these benchmarking utilities as well as provide a clear name that it is *only* intended for use via the compiler `#[bench]` attribute. The current interface is quite minimal with only what's necessary as `#[stable]`. It is most certainly a desire for the compiler to support other testing frameworks other than the standard libtest. This form of infrastructure (be it a plugin or a separate interface) is out of scope for 1.0, however, and this commit does not attempt to resolve it. Due to the removal of benchmarking items from libtest, this is a breaking change. To update, rewrite imports of `extern crate test` to `extern crate rustc_bench` and then rewrite all `use` statements as well. The public interface of the `Bencher` struct has not changed. [breaking-change]
15bbe16
to
a800e3e
Compare
Yeah I was trying to hide the I can think of a few alternatives:
I'd almost personally lean towards option 1... thoughts @brson or @aturon? |
After some more discussion on IRC, I'm going to withdraw this and continue pursuing a strategy after the alpha release. This means that for the alpha release crates will need to opt-in to the unstable apis provided by the |
One of the last remaining crates to have a stabilization story in the standard
distribution is the libtest library. This library currently provides the backing
infrastructure and test harness used when rustc generates a test execuable via
the
--test
command line flag.It's well known that libtest is not the end-all-be-all of testing frameworks. It
is intentionally minimal and is currently quite conservative in its scope of
what it tries to accomplish as well as what it implements. A testament to this
is the fact that one very rarely writes
extern crate test
, and it almost meansthat the stabilization story need not be considered for the crate at all! The
benchmarking feature of the compiler, however, is quite useful and is one of the
sole reasons for using
extern crate test
.When benchmarking, there are a few primary interfaces to the libtest library
that are used:
test::Bencher
- the type for a benchmarking harness.test::Bencher::iter
- a member function used to run a benchmark.test::black_box
- a useful function to hinder optimizations and prevent avalue from being optimized away.
These three pieces of information are the primary targets for the stabilization
in this commit. The rest of the testing infrastructure, while still quite useful
to some projects, is not in scope for stabilization at 1.0 and will remain
#[experimental]
for now.The benchmarking pieces have been moved to a new
rustc_bench
crate which willbe part of the standard distribution. In order to write a benchmark one will
need to import the crate via
extern crate rustc_bench
and otherwise all usageremains the same. The purpose of this crate is to provide a clear area for these
benchmarking utilities as well as provide a clear name that it is only
intended for use via the compiler
#[bench]
attribute. The current interface isquite minimal with only what's necessary as
#[stable]
.It is most certainly a desire for the compiler to support other testing
frameworks other than the standard libtest. This form of infrastructure (be it a
plugin or a separate interface) is out of scope for 1.0, however, and this
commit does not attempt to resolve it.
Due to the removal of benchmarking items from libtest, this is a breaking
change. To update, rewrite imports of
extern crate test
toextern crate rustc_bench
and then rewrite alluse
statements as well. The public interfaceof the
Bencher
struct has not changed.[breaking-change]