@@ -9,8 +9,8 @@ use std::borrow::Cow;
9
9
use std:: collections:: HashMap ;
10
10
use std:: hash:: { BuildHasherDefault , DefaultHasher } ;
11
11
use std:: num:: NonZero ;
12
- use std:: sync:: { Arc , Mutex , mpsc} ;
13
- use std:: { env, hint, io , mem, panic, thread} ;
12
+ use std:: sync:: { Arc , mpsc} ;
13
+ use std:: { env, hint, mem, panic, thread} ;
14
14
15
15
use camino:: Utf8PathBuf ;
16
16
@@ -130,10 +130,6 @@ fn run_test_inner(
130
130
panic_hook:: set_capture_buf ( Default :: default ( ) ) ;
131
131
}
132
132
133
- if let CaptureKind :: Old { ref buf } = capture {
134
- io:: set_output_capture ( Some ( Arc :: clone ( buf) ) ) ;
135
- }
136
-
137
133
let stdout = capture. stdout ( ) ;
138
134
let stderr = capture. stderr ( ) ;
139
135
@@ -144,9 +140,6 @@ fn run_test_inner(
144
140
// Forward any captured panic message to (captured) stderr.
145
141
write ! ( stderr, "{panic_buf}" ) ;
146
142
}
147
- if matches ! ( capture, CaptureKind :: Old { .. } ) {
148
- io:: set_output_capture ( None ) ;
149
- }
150
143
151
144
let outcome = match ( should_panic, panic_payload) {
152
145
( ShouldPanic :: No , None ) | ( ShouldPanic :: Yes , Some ( _) ) => TestOutcome :: Succeeded ,
@@ -167,31 +160,24 @@ enum CaptureKind {
167
160
/// runners, whose output is always captured.)
168
161
None ,
169
162
170
- /// Use the old output-capture implementation, which relies on the unstable
171
- /// library feature `#![feature(internal_output_capture)]`.
172
- Old { buf : Arc < Mutex < Vec < u8 > > > } ,
173
-
174
- /// Use the new output-capture implementation, which only uses stable Rust.
175
- New { buf : output_capture:: CaptureBuf } ,
163
+ /// Capture all console output that would be printed by test runners via
164
+ /// their `stdout` and `stderr` trait objects, or via the custom panic hook.
165
+ Capture { buf : output_capture:: CaptureBuf } ,
176
166
}
177
167
178
168
impl CaptureKind {
179
169
fn for_config ( config : & Config ) -> Self {
180
170
if config. nocapture {
181
171
Self :: None
182
- } else if config. new_output_capture {
183
- Self :: New { buf : output_capture:: CaptureBuf :: new ( ) }
184
172
} else {
185
- // Create a capure buffer for `io::set_output_capture`.
186
- Self :: Old { buf : Default :: default ( ) }
173
+ Self :: Capture { buf : output_capture:: CaptureBuf :: new ( ) }
187
174
}
188
175
}
189
176
190
177
fn should_set_panic_hook ( & self ) -> bool {
191
178
match self {
192
179
Self :: None => false ,
193
- Self :: Old { .. } => true ,
194
- Self :: New { .. } => true ,
180
+ Self :: Capture { .. } => true ,
195
181
}
196
182
}
197
183
@@ -205,16 +191,15 @@ impl CaptureKind {
205
191
206
192
fn capture_buf_or < ' a > ( & ' a self , fallback : & ' a dyn ConsoleOut ) -> & ' a dyn ConsoleOut {
207
193
match self {
208
- Self :: None | Self :: Old { .. } => fallback,
209
- Self :: New { buf } => buf,
194
+ Self :: None => fallback,
195
+ Self :: Capture { buf } => buf,
210
196
}
211
197
}
212
198
213
199
fn into_inner ( self ) -> Option < Vec < u8 > > {
214
200
match self {
215
201
Self :: None => None ,
216
- Self :: Old { buf } => Some ( buf. lock ( ) . unwrap_or_else ( |e| e. into_inner ( ) ) . to_vec ( ) ) ,
217
- Self :: New { buf } => Some ( buf. into_inner ( ) . into ( ) ) ,
202
+ Self :: Capture { buf } => Some ( buf. into_inner ( ) . into ( ) ) ,
218
203
}
219
204
}
220
205
}
0 commit comments