Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![feature(test)]
#![allow(incomplete_features)]
#![feature(specialization)]
#![feature(termination_trait_lib)]
#![feature(unboxed_closures)]
#![feature(fn_traits)]
//! Crate for supporting data-driven tests.
Expand Down
26 changes: 15 additions & 11 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl From<RegularShouldPanic> for ShouldPanic {
pub struct RegularTestDesc {
pub name: &'static str,
pub ignore: bool,
pub testfn: fn(),
pub testfn: fn() -> Result<(), String>,
pub should_panic: RegularShouldPanic,
pub source_file: &'static str,
}
Expand Down Expand Up @@ -125,21 +125,21 @@ impl rustc_test::TDynBenchFn for FilesBenchFn {
}

impl<'r> Fn<(&'r mut Bencher,)> for FilesBenchFn {
extern "rust-call" fn call(&self, (bencher,): (&'r mut Bencher,)) {
(self.0)(bencher, &self.1[..]);
extern "rust-call" fn call(&self, (bencher,): (&'r mut Bencher,)) -> Self::Output {
Ok((self.0)(bencher, &self.1[..]))
}
}

impl<'r> FnOnce<(&'r mut Bencher,)> for FilesBenchFn {
type Output = ();
extern "rust-call" fn call_once(self, harness: (&'r mut Bencher,)) {
(self.0)(harness.0, &self.1)
type Output = Result<(), String>;
extern "rust-call" fn call_once(self, harness: (&'r mut Bencher,)) -> Self::Output {
Ok((self.0)(harness.0, &self.1))
}
}

impl<'r> FnMut<(&'r mut Bencher,)> for FilesBenchFn {
extern "rust-call" fn call_mut(&mut self, harness: (&'r mut Bencher,)) {
(self.0)(harness.0, &self.1)
extern "rust-call" fn call_mut(&mut self, harness: (&'r mut Bencher,)) -> Self::Output {
Ok((self.0)(harness.0, &self.1))
}
}

Expand Down Expand Up @@ -183,7 +183,9 @@ fn render_files_test(desc: &FilesTestDesc, rendered: &mut Vec<TestDescAndFn>) {
.map_or(false, |ignore_func| ignore_func(&path));

let testfn = match desc.testfn {
FilesTestFn::TestFn(testfn) => TestFn::DynTestFn(Box::new(move || testfn(&paths))),
FilesTestFn::TestFn(testfn) => {
TestFn::DynTestFn(Box::new(move || Ok(testfn(&paths))))
}
FilesTestFn::BenchFn(benchfn) => {
TestFn::DynBenchFn(Box::new(FilesBenchFn(benchfn, paths)))
}
Expand Down Expand Up @@ -235,8 +237,10 @@ fn render_data_test(desc: &DataTestDesc, rendered: &mut Vec<TestDescAndFn>) {
};

let testfn = match case.case {
DataTestFn::TestFn(testfn) => TestFn::DynTestFn(testfn),
DataTestFn::BenchFn(benchfn) => TestFn::DynBenchFn(benchfn),
DataTestFn::TestFn(testfn) => TestFn::DynTestFn(Box::new(move || Ok(testfn()))),
DataTestFn::BenchFn(benchfn) => {
TestFn::DynBenchFn(Box::new(move |bencher| Ok(benchfn(bencher))))
}
};

// Generate a standard test descriptor
Expand Down