@@ -9,8 +9,8 @@ use std::borrow::Cow;
99use std:: collections:: HashMap ;
1010use std:: hash:: { BuildHasherDefault , DefaultHasher } ;
1111use 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} ;
1414
1515use camino:: Utf8PathBuf ;
1616
@@ -130,10 +130,6 @@ fn run_test_inner(
130130 panic_hook:: set_capture_buf ( Default :: default ( ) ) ;
131131 }
132132
133- if let CaptureKind :: Old { ref buf } = capture {
134- io:: set_output_capture ( Some ( Arc :: clone ( buf) ) ) ;
135- }
136-
137133 let stdout = capture. stdout ( ) ;
138134 let stderr = capture. stderr ( ) ;
139135
@@ -144,9 +140,6 @@ fn run_test_inner(
144140 // Forward any captured panic message to (captured) stderr.
145141 write ! ( stderr, "{panic_buf}" ) ;
146142 }
147- if matches ! ( capture, CaptureKind :: Old { .. } ) {
148- io:: set_output_capture ( None ) ;
149- }
150143
151144 let outcome = match ( should_panic, panic_payload) {
152145 ( ShouldPanic :: No , None ) | ( ShouldPanic :: Yes , Some ( _) ) => TestOutcome :: Succeeded ,
@@ -167,31 +160,24 @@ enum CaptureKind {
167160 /// runners, whose output is always captured.)
168161 None ,
169162
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 } ,
176166}
177167
178168impl CaptureKind {
179169 fn for_config ( config : & Config ) -> Self {
180170 if config. nocapture {
181171 Self :: None
182- } else if config. new_output_capture {
183- Self :: New { buf : output_capture:: CaptureBuf :: new ( ) }
184172 } 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 ( ) }
187174 }
188175 }
189176
190177 fn should_set_panic_hook ( & self ) -> bool {
191178 match self {
192179 Self :: None => false ,
193- Self :: Old { .. } => true ,
194- Self :: New { .. } => true ,
180+ Self :: Capture { .. } => true ,
195181 }
196182 }
197183
@@ -205,16 +191,15 @@ impl CaptureKind {
205191
206192 fn capture_buf_or < ' a > ( & ' a self , fallback : & ' a dyn ConsoleOut ) -> & ' a dyn ConsoleOut {
207193 match self {
208- Self :: None | Self :: Old { .. } => fallback,
209- Self :: New { buf } => buf,
194+ Self :: None => fallback,
195+ Self :: Capture { buf } => buf,
210196 }
211197 }
212198
213199 fn into_inner ( self ) -> Option < Vec < u8 > > {
214200 match self {
215201 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 ( ) ) ,
218203 }
219204 }
220205}
0 commit comments