mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 14:02:57 +00:00
Rollup merge of #92409 - bjorn3:libtest_cleanups, r=m-ou-se
Couple of libtest cleanups Remove the unnecessary `TDynBenchFn` trait and remove a couple of unused attributes and feature gates.
This commit is contained in:
commit
92f28bda38
@ -13,20 +13,12 @@
|
|||||||
// running tests while providing a base that other test frameworks may
|
// running tests while providing a base that other test frameworks may
|
||||||
// build off of.
|
// build off of.
|
||||||
|
|
||||||
// N.B., this is also specified in this crate's Cargo.toml, but librustc_ast contains logic specific to
|
|
||||||
// this crate, which relies on this attribute (rather than the value of `--crate-name` passed by
|
|
||||||
// cargo) to detect this crate.
|
|
||||||
|
|
||||||
#![crate_name = "test"]
|
|
||||||
#![unstable(feature = "test", issue = "50297")]
|
#![unstable(feature = "test", issue = "50297")]
|
||||||
#![doc(test(attr(deny(warnings))))]
|
#![doc(test(attr(deny(warnings))))]
|
||||||
#![feature(libc)]
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(available_parallelism)]
|
#![feature(available_parallelism)]
|
||||||
#![feature(bench_black_box)]
|
#![feature(bench_black_box)]
|
||||||
#![feature(internal_output_capture)]
|
#![feature(internal_output_capture)]
|
||||||
#![feature(panic_unwind)]
|
|
||||||
#![feature(staged_api)]
|
#![feature(staged_api)]
|
||||||
#![feature(termination_trait_lib)]
|
#![feature(termination_trait_lib)]
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
@ -444,8 +436,8 @@ pub fn convert_benchmarks_to_tests(tests: Vec<TestDescAndFn>) -> Vec<TestDescAnd
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
let testfn = match x.testfn {
|
let testfn = match x.testfn {
|
||||||
DynBenchFn(bench) => DynTestFn(Box::new(move || {
|
DynBenchFn(benchfn) => DynTestFn(Box::new(move || {
|
||||||
bench::run_once(|b| __rust_begin_short_backtrace(|| bench.run(b)))
|
bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b)))
|
||||||
})),
|
})),
|
||||||
StaticBenchFn(benchfn) => DynTestFn(Box::new(move || {
|
StaticBenchFn(benchfn) => DynTestFn(Box::new(move || {
|
||||||
bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b)))
|
bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b)))
|
||||||
@ -544,11 +536,9 @@ pub fn run_test(
|
|||||||
TestRunOpts { strategy, nocapture: opts.nocapture, concurrency, time: opts.time_options };
|
TestRunOpts { strategy, nocapture: opts.nocapture, concurrency, time: opts.time_options };
|
||||||
|
|
||||||
match testfn {
|
match testfn {
|
||||||
DynBenchFn(bencher) => {
|
DynBenchFn(benchfn) => {
|
||||||
// Benchmarks aren't expected to panic, so we run them all in-process.
|
// Benchmarks aren't expected to panic, so we run them all in-process.
|
||||||
crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, |harness| {
|
crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, benchfn);
|
||||||
bencher.run(harness)
|
|
||||||
});
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
StaticBenchFn(benchfn) => {
|
StaticBenchFn(benchfn) => {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
#![allow(deprecated)] // Float
|
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
|
@ -74,11 +74,6 @@ impl fmt::Display for TestName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a benchmark function.
|
|
||||||
pub trait TDynBenchFn: Send {
|
|
||||||
fn run(&self, harness: &mut Bencher);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A function that runs a test. If the function returns successfully,
|
// A function that runs a test. If the function returns successfully,
|
||||||
// the test succeeds; if the function panics then the test fails. We
|
// the test succeeds; if the function panics then the test fails. We
|
||||||
// may need to come up with a more clever definition of test in order
|
// may need to come up with a more clever definition of test in order
|
||||||
@ -87,7 +82,7 @@ pub enum TestFn {
|
|||||||
StaticTestFn(fn()),
|
StaticTestFn(fn()),
|
||||||
StaticBenchFn(fn(&mut Bencher)),
|
StaticBenchFn(fn(&mut Bencher)),
|
||||||
DynTestFn(Box<dyn FnOnce() + Send>),
|
DynTestFn(Box<dyn FnOnce() + Send>),
|
||||||
DynBenchFn(Box<dyn TDynBenchFn + 'static>),
|
DynBenchFn(Box<dyn Fn(&mut Bencher) + Send>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestFn {
|
impl TestFn {
|
||||||
|
Loading…
Reference in New Issue
Block a user