@@ -28,9 +28,9 @@ use tracing::{instrument, trace, trace_span, warn, Instrument};
2828use crate :: {
2929 bincode_input_closed,
3030 message:: {
31- CoordinatorMessage , DeleteFileRequest , ExecuteCommandRequest , JobId , Multiplexed ,
32- OneToOneResponse , ReadFileRequest , ReadFileResponse , SerializedError , WorkerMessage ,
33- WriteFileRequest ,
31+ CoordinatorMessage , DeleteFileRequest , ExecuteCommandRequest , ExecuteCommandResponse ,
32+ JobId , Multiplexed , OneToOneResponse , ReadFileRequest , ReadFileResponse , SerializedError ,
33+ WorkerMessage , WriteFileRequest ,
3434 } ,
3535 DropErrorDetailsExt ,
3636} ;
@@ -233,6 +233,7 @@ impl CargoTomlModifier for ExecuteRequest {
233233#[ derive( Debug , Clone ) ]
234234pub struct ExecuteResponse {
235235 pub success : bool ,
236+ pub exit_detail : String ,
236237}
237238
238239#[ derive( Debug , Clone ) ]
@@ -338,6 +339,7 @@ impl CargoTomlModifier for CompileRequest {
338339#[ derive( Debug , Clone ) ]
339340pub struct CompileResponse {
340341 pub success : bool ,
342+ pub exit_detail : String ,
341343 pub code : String ,
342344}
343345
@@ -627,11 +629,17 @@ impl Container {
627629 . context ( CouldNotStartCargoSnafu ) ?;
628630
629631 let task = async move {
630- let success = task
632+ let ExecuteCommandResponse {
633+ success,
634+ exit_detail,
635+ } = task
631636 . await
632637 . context ( CargoTaskPanickedSnafu ) ?
633638 . context ( CargoFailedSnafu ) ?;
634- Ok ( ExecuteResponse { success } )
639+ Ok ( ExecuteResponse {
640+ success,
641+ exit_detail,
642+ } )
635643 }
636644 . boxed ( ) ;
637645
@@ -693,7 +701,10 @@ impl Container {
693701
694702 let commander = self . commander . clone ( ) ;
695703 let task = async move {
696- let success = task
704+ let ExecuteCommandResponse {
705+ success,
706+ exit_detail,
707+ } = task
697708 . await
698709 . context ( CargoTaskPanickedSnafu ) ?
699710 . context ( CargoFailedSnafu ) ?;
@@ -711,7 +722,11 @@ impl Container {
711722 // TODO: This is synchronous...
712723 let code = request. postprocess_result ( code) ;
713724
714- Ok ( CompileResponse { success, code } )
725+ Ok ( CompileResponse {
726+ success,
727+ exit_detail,
728+ code,
729+ } )
715730 }
716731 . boxed ( ) ;
717732
@@ -744,7 +759,7 @@ impl Container {
744759
745760 match container_msg {
746761 WorkerMessage :: ExecuteCommand ( resp) => {
747- return Ok ( resp. success ) ;
762+ return Ok ( resp) ;
748763 }
749764 WorkerMessage :: StdoutPacket ( packet) => {
750765 stdout_tx. send ( packet) . await . ok ( /* Receiver gone, that's OK */ ) ;
@@ -869,7 +884,7 @@ pub enum CompileError {
869884}
870885
871886struct SpawnCargo {
872- task : JoinHandle < Result < bool , SpawnCargoError > > ,
887+ task : JoinHandle < Result < ExecuteCommandResponse , SpawnCargoError > > ,
873888 stdout_rx : mpsc:: Receiver < String > ,
874889 stderr_rx : mpsc:: Receiver < String > ,
875890}
@@ -2060,6 +2075,31 @@ mod tests {
20602075 Ok ( ( ) )
20612076 }
20622077
2078+ #[ tokio:: test]
2079+ #[ snafu:: report]
2080+ async fn exit_due_to_signal_is_reported ( ) -> Result < ( ) > {
2081+ let coordinator = new_coordinator ( ) . await ;
2082+
2083+ let req = ExecuteRequest {
2084+ channel : Channel :: Stable ,
2085+ mode : Mode :: Release ,
2086+ edition : Edition :: Rust2021 ,
2087+ crate_type : CrateType :: Binary ,
2088+ tests : false ,
2089+ backtrace : false ,
2090+ code : r#"fn main() { std::process::abort(); }"# . into ( ) ,
2091+ } ;
2092+
2093+ let res = coordinator. execute ( req. clone ( ) ) . await . unwrap ( ) ;
2094+
2095+ assert ! ( !res. success) ;
2096+ assert_contains ! ( res. exit_detail, "abort" ) ;
2097+
2098+ coordinator. shutdown ( ) . await ?;
2099+
2100+ Ok ( ( ) )
2101+ }
2102+
20632103 fn new_execution_limited_request ( ) -> ExecuteRequest {
20642104 ExecuteRequest {
20652105 channel : Channel :: Stable ,
0 commit comments