You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]
0 commit comments