1
- From e77c222bb7ec0a99a69dcbb039c75fd1ea9db368 Mon Sep 17 00:00:00 2001
1
+ From e06143d3373293d0490df482261cd4a842f1a5c5 Mon Sep 17 00:00:00 2001
2
2
3
- Date: Thu, 3 Oct 2019 16:22:21 +0200
3
+ Date: Thu, 3 Oct 2019 16:51:34 +0200
4
4
Subject: [PATCH] Fix libtest compilation
5
5
6
6
---
7
- src/libtest/lib.rs | 30 +++++----- --------------------
8
- 1 file changed, 5 insertions(+), 25 deletions(-)
7
+ src/libtest/lib.rs | 28 ++++++++ --------------------
8
+ 1 file changed, 8 insertions(+), 20 deletions(-)
9
9
10
10
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
11
- index e441514..8e8b4df 100644
11
+ index 8b76080..9e65de2 100644
12
12
--- a/src/libtest/lib.rs
13
13
+++ b/src/libtest/lib.rs
14
- @@ -24,7 +24,6 @@
15
- #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))]
16
- #![feature(nll)]
17
- #![feature(set_stdio)]
18
- - #![feature(panic_unwind)]
19
- #![feature(staged_api)]
20
- #![feature(termination_trait_lib)]
21
- #![feature(test)]
22
- @@ -34,16 +33,6 @@ use getopts;
23
- extern crate libc;
24
- use term;
25
-
26
- - // FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind
27
- - // on aarch64-pc-windows-msvc, or thumbv7a-pc-windows-msvc
28
- - // so we don't link libtest against libunwind (for the time being)
29
- - // even though it means that libtest won't be fully functional on
30
- - // these platforms.
31
- - //
32
- - // See also: https://github.com/rust-lang/rust/issues/54190#issuecomment-422904437
33
- - #[cfg(not(all(windows, any(target_arch = "aarch64", target_arch = "arm"))))]
34
- - extern crate panic_unwind;
35
- -
36
- pub use self::ColorConfig::*;
37
- use self::NamePadding::*;
38
- use self::OutputLocation::*;
39
- @@ -61,7 +50,6 @@ use std::fmt;
14
+ @@ -52,7 +52,7 @@ use std::fmt;
40
15
use std::fs::File;
41
16
use std::io;
42
17
use std::io::prelude::*;
43
- - use std::panic::{catch_unwind, AssertUnwindSafe};
18
+ - use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo};
19
+ + use std::panic::{self, PanicInfo};
44
20
use std::path::PathBuf;
45
21
use std::process;
46
- use std::process::Termination;
47
- @@ -1434,7 +1422,7 @@ pub fn run_test(
48
- monitor_ch: Sender<MonitorMsg>,
49
- nocapture: bool,
22
+ use std::process::{ExitStatus, Command, Termination};
23
+ @@ -1493,7 +1493,7 @@ pub fn run_test(
50
24
report_time: bool,
25
+ strategy: RunStrategy,
26
+ monitor_ch: Sender<MonitorMsg>,
51
27
- testfn: Box<dyn FnOnce() + Send>,
52
28
+ testfn: Box<impl FnOnce() + Send + 'static>,
53
29
concurrency: Concurrent,
54
30
) {
55
- // Buffer for capturing standard I/O
56
- @@ -1457,7 +1445,7 @@ pub fn run_test(
57
- } else {
58
- None
59
- };
60
- - let result = catch_unwind(AssertUnwindSafe(testfn));
61
- + let result = Ok(testfn());
62
- let exec_time = start.map(|start| {
63
- let duration = start.elapsed();
64
- TestExecTime(duration)
65
- @@ -1478,7 +1466,7 @@ pub fn run_test(
31
+ let name = desc.name.clone();
32
+ @@ -1509,7 +1509,7 @@ pub fn run_test(
66
33
// If the platform is single-threaded we're just going to run
67
34
// the test synchronously, regardless of the concurrency
68
35
// level.
@@ -71,25 +38,56 @@ index e441514..8e8b4df 100644
71
38
if concurrency == Concurrent::Yes && supports_threads {
72
39
let cfg = thread::Builder::new().name(name.as_slice().to_owned());
73
40
cfg.spawn(runtest).unwrap();
74
- @@ -1498,16 +1486 ,8 @@ pub fn run_test(
41
+ @@ -1531,20 +1531 ,8 @@ pub fn run_test(
75
42
(benchfn.clone())(harness)
76
43
});
77
44
}
78
45
- DynTestFn(f) => {
79
- - let cb = move || __rust_begin_short_backtrace(f);
46
+ - match strategy {
47
+ - RunStrategy::InProcess => (),
48
+ - _ => panic!("Cannot run dynamic test fn out-of-process"),
49
+ - };
80
50
- run_test_inner(
81
51
- desc,
82
- - monitor_ch,
83
52
- opts.nocapture,
84
53
- opts.report_time,
85
- - Box::new(cb),
86
- - concurrency,
87
- - )
54
+ - strategy,
55
+ - monitor_ch,
56
+ - Box::new(move || __rust_begin_short_backtrace(f)),
57
+ - concurrency
58
+ - );
88
59
+ DynTestFn(_f) => {
89
60
+ unimplemented!();
90
61
}
91
62
StaticTestFn(f) => run_test_inner(
92
63
desc,
64
+ @@ -1604,7 +1592,7 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult {
65
+ fn run_test_in_process(desc: TestDesc,
66
+ nocapture: bool,
67
+ report_time: bool,
68
+ - testfn: Box<dyn FnOnce() + Send>,
69
+ + testfn: Box<impl FnOnce() + Send + 'static>,
70
+ monitor_ch: Sender<MonitorMsg>) {
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 Any + Send>>(testfn());
79
+ let exec_time = start.map(|start| {
80
+ let duration = start.elapsed();
81
+ TestExecTime(duration)
82
+ @@ -1688,7 +1676,7 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender<M
83
+ monitor_ch.send((desc.clone(), result, exec_time, test_output)).unwrap();
84
+ }
85
+
86
+ - fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box<dyn FnOnce() + Send>) -> ! {
87
+ + fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box<impl FnOnce() + Send + 'static>) -> ! {
88
+ let builtin_panic_hook = panic::take_hook();
89
+ let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| {
90
+ let test_result = match panic_info {
93
91
- -
94
92
2.20.1
95
93
0 commit comments