1
- use crate :: cmd:: { Command , CommandError , ProcessLinesActions } ;
1
+ use crate :: cmd:: { Command , CommandError , ProcessLinesActions , ProcessOutput } ;
2
2
use crate :: Workspace ;
3
3
use failure:: Error ;
4
4
use log:: { error, info} ;
@@ -277,13 +277,17 @@ impl SandboxBuilder {
277
277
} )
278
278
}
279
279
280
+ #[ allow( clippy:: too_many_arguments) ]
280
281
pub ( super ) fn run (
281
282
self ,
282
283
workspace : & Workspace ,
283
284
timeout : Option < Duration > ,
284
285
no_output_timeout : Option < Duration > ,
285
286
process_lines : Option < & mut dyn FnMut ( & str , & mut ProcessLinesActions ) > ,
286
- ) -> Result < ( ) , Error > {
287
+ log_output : bool ,
288
+ log_command : bool ,
289
+ capture : bool ,
290
+ ) -> Result < ProcessOutput , Error > {
287
291
let container = self . create ( workspace) ?;
288
292
289
293
// Ensure the container is properly deleted even if something panics
@@ -297,8 +301,14 @@ impl SandboxBuilder {
297
301
}
298
302
} }
299
303
300
- container. run ( timeout, no_output_timeout, process_lines) ?;
301
- Ok ( ( ) )
304
+ container. run (
305
+ timeout,
306
+ no_output_timeout,
307
+ process_lines,
308
+ log_output,
309
+ log_command,
310
+ capture,
311
+ )
302
312
}
303
313
}
304
314
@@ -345,17 +355,22 @@ impl Container<'_> {
345
355
timeout : Option < Duration > ,
346
356
no_output_timeout : Option < Duration > ,
347
357
process_lines : Option < & mut dyn FnMut ( & str , & mut ProcessLinesActions ) > ,
348
- ) -> Result < ( ) , Error > {
358
+ log_output : bool ,
359
+ log_command : bool ,
360
+ capture : bool ,
361
+ ) -> Result < ProcessOutput , Error > {
349
362
let mut cmd = Command :: new ( self . workspace , "docker" )
350
363
. args ( & [ "start" , "-a" , & self . id ] )
351
364
. timeout ( timeout)
365
+ . log_output ( log_output)
366
+ . log_command ( log_command)
352
367
. no_output_timeout ( no_output_timeout) ;
353
368
354
369
if let Some ( f) = process_lines {
355
370
cmd = cmd. process_lines ( f) ;
356
371
}
357
372
358
- let res = cmd. run ( ) ;
373
+ let res = cmd. run_inner ( capture ) ;
359
374
let details = self . inspect ( ) ?;
360
375
361
376
// Return a different error if the container was killed due to an OOM
0 commit comments