]> git.lizzy.rs Git - rust.git/blob - patches/0017-Fix-libtest-compilation.patch
c76e2e2f8b42d64a6a30bb3d70117e79f96ef2fb
[rust.git] / patches / 0017-Fix-libtest-compilation.patch
1 From e06143d3373293d0490df482261cd4a842f1a5c5 Mon Sep 17 00:00:00 2001
2 From: bjorn3 <bjorn3@users.noreply.github.com>
3 Date: Thu, 3 Oct 2019 16:51:34 +0200
4 Subject: [PATCH] Fix libtest compilation
5
6 ---
7  src/libtest/lib.rs | 28 ++++++++--------------------
8  1 file changed, 8 insertions(+), 20 deletions(-)
9
10 diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
11 index 8b76080..9e65de2 100644
12 --- a/src/libtest/lib.rs
13 +++ b/src/libtest/lib.rs
14 @@ -52,7 +52,7 @@ use std::fmt;
15      env,
16      io,
17      io::prelude::Write,
18 -    panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo},
19 +    panic::{self, PanicInfo},
20      process,
21      process::{Command, Termination},
22      sync::mpsc::{channel, Sender},
23 @@ -1493,7 +1493,7 @@ pub fn run_test(
24      fn run_test_inner(
25          desc: TestDesc,
26          monitor_ch: Sender<CompletedTest>,
27 -        testfn: Box<dyn FnOnce() + Send>,
28 +        testfn: Box<impl FnOnce() + Send + 'static>,
29          opts: TestRunOpts,
30      ) {
31          let concurrency = opts.concurrency;
32 @@ -1509,7 +1509,7 @@ pub fn run_test(
33          // If the platform is single-threaded we're just going to run
34          // the test synchronously, regardless of the concurrency
35          // level.
36 -        let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32");
37 +        let supports_threads = false;
38          if concurrency == Concurrent::Yes && supports_threads {
39              let cfg = thread::Builder::new().name(name.as_slice().to_owned());
40              cfg.spawn(runtest).unwrap();
41 @@ -1531,17 +1531,8 @@ pub fn run_test(
42                  (benchfn.clone())(harness)
43              });
44          }
45 -        DynTestFn(f) => {
46 -            match strategy {
47 -                RunStrategy::InProcess => (),
48 -                _ => panic!("Cannot run dynamic test fn out-of-process"),
49 -            };
50 -            run_test_inner(
51 -                desc,
52 -                monitor_ch,
53 -                Box::new(move || __rust_begin_short_backtrace(f)),
54 -                test_run_opts,
55 -            );
56 +        DynTestFn(_f) => {
57 +            unimplemented!();
58          }
59          StaticTestFn(f) => run_test_inner(
60              desc,
61 @@ -1604,10 +1592,10 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult {
62  fn run_test_in_process(
63      desc: TestDesc,
64      nocapture: bool,
65      report_time: bool,
66 -    testfn: Box<dyn FnOnce() + Send>,
67 +    testfn: Box<impl FnOnce() + Send + 'static>,
68      monitor_ch: Sender<CompletedTest>,
69      time_opts: Option<time::TestTimeOptions>,
70  ) {
71      // Buffer for capturing standard I/O
72      let data = Arc::new(Mutex::new(Vec::new()));
73 @@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc,
74      } else {
75          None
76      };
77 -    let result = catch_unwind(AssertUnwindSafe(testfn));
78 +    let result = Ok::<(), Box<dyn std::any::Any + Send>>(testfn());
79      let exec_time = start.map(|start| {
80          let duration = start.elapsed();
81          TestExecTime(duration)
82 @@ -1688,10 +1676,10 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender<M
83      monitor_ch.send(message).unwrap();
84  }
85  
86  fn run_test_in_spawned_subprocess(
87      desc: TestDesc,
88 -    testfn: Box<dyn FnOnce() + Send>,
89 +    testfn: Box<impl FnOnce() + Send + 'static>,
90  ) -> ! {
91      let builtin_panic_hook = panic::take_hook();
92      let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| {
93          let test_result = match panic_info {
94 -- 
95 2.20.1
96