rust/patches/0017-Fix-libtest-compilation.patch

97 lines
3.4 KiB
Diff

From e06143d3373293d0490df482261cd4a842f1a5c5 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Thu, 3 Oct 2019 16:51:34 +0200
Subject: [PATCH] Fix libtest compilation
---
src/libtest/lib.rs | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 8b76080..9e65de2 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -52,7 +52,7 @@ use std::fmt;
env,
io,
io::prelude::Write,
- panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo},
+ panic::{self, PanicInfo},
process,
process::{Command, Termination},
sync::mpsc::{channel, Sender},
@@ -1493,7 +1493,7 @@ pub fn run_test(
fn run_test_inner(
desc: TestDesc,
monitor_ch: Sender<CompletedTest>,
- testfn: Box<dyn FnOnce() + Send>,
+ testfn: Box<impl FnOnce() + Send + 'static>,
opts: TestRunOpts,
) {
let concurrency = opts.concurrency;
@@ -1509,7 +1509,7 @@ pub fn run_test(
// If the platform is single-threaded we're just going to run
// the test synchronously, regardless of the concurrency
// level.
- let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32");
+ let supports_threads = false;
if concurrency == Concurrent::Yes && supports_threads {
let cfg = thread::Builder::new().name(name.as_slice().to_owned());
cfg.spawn(runtest).unwrap();
@@ -1531,17 +1531,8 @@ pub fn run_test(
(benchfn.clone())(harness)
});
}
- DynTestFn(f) => {
- match strategy {
- RunStrategy::InProcess => (),
- _ => panic!("Cannot run dynamic test fn out-of-process"),
- };
- run_test_inner(
- desc,
- monitor_ch,
- Box::new(move || __rust_begin_short_backtrace(f)),
- test_run_opts,
- );
+ DynTestFn(_f) => {
+ unimplemented!();
}
StaticTestFn(f) => run_test_inner(
desc,
@@ -1604,10 +1592,10 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult {
fn run_test_in_process(
desc: TestDesc,
nocapture: bool,
report_time: bool,
- testfn: Box<dyn FnOnce() + Send>,
+ testfn: Box<impl FnOnce() + Send + 'static>,
monitor_ch: Sender<CompletedTest>,
time_opts: Option<time::TestTimeOptions>,
) {
// Buffer for capturing standard I/O
let data = Arc::new(Mutex::new(Vec::new()));
@@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc,
} else {
None
};
- let result = catch_unwind(AssertUnwindSafe(testfn));
+ let result = Ok::<(), Box<dyn std::any::Any + Send>>(testfn());
let exec_time = start.map(|start| {
let duration = start.elapsed();
TestExecTime(duration)
@@ -1688,10 +1676,10 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender<M
monitor_ch.send(message).unwrap();
}
fn run_test_in_spawned_subprocess(
desc: TestDesc,
- testfn: Box<dyn FnOnce() + Send>,
+ testfn: Box<impl FnOnce() + Send + 'static>,
) -> ! {
let builtin_panic_hook = panic::take_hook();
let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| {
let test_result = match panic_info {
--
2.20.1