2019-10-03 10:22:01 -05:00
|
|
|
From e06143d3373293d0490df482261cd4a842f1a5c5 Mon Sep 17 00:00:00 2001
|
2019-07-31 07:04:00 -05:00
|
|
|
From: bjorn3 <bjorn3@users.noreply.github.com>
|
2019-10-03 10:22:01 -05:00
|
|
|
Date: Thu, 3 Oct 2019 16:51:34 +0200
|
2019-07-31 07:04:00 -05:00
|
|
|
Subject: [PATCH] Fix libtest compilation
|
|
|
|
|
|
|
|
---
|
2019-10-03 10:22:01 -05:00
|
|
|
src/libtest/lib.rs | 28 ++++++++--------------------
|
|
|
|
1 file changed, 8 insertions(+), 20 deletions(-)
|
2019-07-31 07:04:00 -05:00
|
|
|
|
|
|
|
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
|
2019-10-03 10:22:01 -05:00
|
|
|
index 8b76080..9e65de2 100644
|
2019-07-31 07:04:00 -05:00
|
|
|
--- a/src/libtest/lib.rs
|
|
|
|
+++ b/src/libtest/lib.rs
|
2019-10-03 10:22:01 -05:00
|
|
|
@@ -52,7 +52,7 @@ use std::fmt;
|
2019-10-03 09:24:06 -05:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io;
|
|
|
|
use std::io::prelude::*;
|
2019-10-03 10:22:01 -05:00
|
|
|
-use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo};
|
|
|
|
+use std::panic::{self, PanicInfo};
|
2019-10-03 09:24:06 -05:00
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::process;
|
2019-10-03 10:22:01 -05:00
|
|
|
use std::process::{ExitStatus, Command, Termination};
|
|
|
|
@@ -1493,7 +1493,7 @@ pub fn run_test(
|
2019-10-16 11:39:12 -05:00
|
|
|
fn run_test_inner(
|
|
|
|
desc: TestDesc,
|
2019-10-03 10:22:01 -05:00
|
|
|
monitor_ch: Sender<MonitorMsg>,
|
2019-07-31 07:04:00 -05:00
|
|
|
- testfn: Box<dyn FnOnce() + Send>,
|
2019-10-03 09:24:06 -05:00
|
|
|
+ testfn: Box<impl FnOnce() + Send + 'static>,
|
2019-10-16 11:39:12 -05:00
|
|
|
opts: TestRunOpts,
|
2019-07-31 07:04:00 -05:00
|
|
|
) {
|
2019-10-16 11:39:12 -05:00
|
|
|
let concurrency = opts.concurrency;
|
2019-10-03 10:22:01 -05:00
|
|
|
@@ -1509,7 +1509,7 @@ pub fn run_test(
|
2019-10-03 09:24:06 -05:00
|
|
|
// 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();
|
2019-10-16 11:39:12 -05:00
|
|
|
@@ -1531,17 +1531,8 @@ pub fn run_test(
|
2019-07-31 07:04:00 -05:00
|
|
|
(benchfn.clone())(harness)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
- DynTestFn(f) => {
|
2019-10-03 10:22:01 -05:00
|
|
|
- match strategy {
|
|
|
|
- RunStrategy::InProcess => (),
|
|
|
|
- _ => panic!("Cannot run dynamic test fn out-of-process"),
|
|
|
|
- };
|
2019-09-28 04:13:40 -05:00
|
|
|
- run_test_inner(
|
|
|
|
- desc,
|
2019-10-03 10:22:01 -05:00
|
|
|
- monitor_ch,
|
|
|
|
- Box::new(move || __rust_begin_short_backtrace(f)),
|
2019-10-16 11:39:12 -05:00
|
|
|
- test_run_opts,
|
2019-10-03 10:22:01 -05:00
|
|
|
- );
|
2019-07-31 07:04:00 -05:00
|
|
|
+ DynTestFn(_f) => {
|
|
|
|
+ unimplemented!();
|
|
|
|
}
|
|
|
|
StaticTestFn(f) => run_test_inner(
|
|
|
|
desc,
|
2019-10-16 11:39:12 -05:00
|
|
|
@@ -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<MonitorMsg>,
|
|
|
|
time_opts: Option<TestTimeOptions>,
|
|
|
|
) {
|
2019-10-03 10:22:01 -05:00
|
|
|
// 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 Any + Send>>(testfn());
|
|
|
|
let exec_time = start.map(|start| {
|
|
|
|
let duration = start.elapsed();
|
|
|
|
TestExecTime(duration)
|
2019-10-16 11:39:12 -05:00
|
|
|
@@ -1688,10 +1676,10 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender<M
|
2019-10-03 10:22:01 -05:00
|
|
|
monitor_ch.send((desc.clone(), result, exec_time, test_output)).unwrap();
|
|
|
|
}
|
|
|
|
|
2019-10-16 11:39:12 -05:00
|
|
|
fn run_test_in_spawned_subprocess(
|
|
|
|
desc: TestDesc,
|
|
|
|
- testfn: Box<dyn FnOnce() + Send>,
|
|
|
|
+ testfn: Box<impl FnOnce() + Send + 'static>,
|
|
|
|
) -> ! {
|
2019-10-03 10:22:01 -05:00
|
|
|
let builtin_panic_hook = panic::take_hook();
|
|
|
|
let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| {
|
|
|
|
let test_result = match panic_info {
|
2019-07-31 07:04:00 -05:00
|
|
|
--
|
2019-10-03 09:24:06 -05:00
|
|
|
2.20.1
|
|
|
|
|