File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use crate :: args:: EmulatorArgs ;
2- use crate :: langs:: check_output ;
2+ use crate :: langs:: check_exit_status ;
33use anyhow:: { Context , Result , bail} ;
44use flate2:: read:: GzDecoder ;
55use std:: fs:: File ;
@@ -20,8 +20,8 @@ pub fn cmd_emulator(vfs: &Path, args: &EmulatorArgs) -> Result<()> {
2020 download_emulator ( & bin_path) . context ( "download emulator" ) ?;
2121 }
2222 println ! ( "⌛ running..." ) ;
23- let output = Command :: new ( bin_path) . args ( & args. args ) . output ( ) ?;
24- check_output ( & output ) . context ( "run emulator" ) ?;
23+ let exit_status = Command :: new ( bin_path) . args ( & args. args ) . status ( ) ?;
24+ check_exit_status ( exit_status ) . context ( "run emulator" ) ?;
2525 Ok ( ( ) )
2626}
2727
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use std::env::temp_dir;
77use std:: fs:: File ;
88use std:: io:: Write ;
99use std:: path:: { Path , PathBuf } ;
10- use std:: process:: { Command , Output } ;
10+ use std:: process:: { Command , ExitStatus , Output } ;
1111
1212pub fn build_bin ( config : & Config , args : & BuildArgs ) -> anyhow:: Result < ( ) > {
1313 // Don't build the binary if it will be copied directly in "files".
@@ -511,8 +511,12 @@ pub fn path_to_utf8(path: &Path) -> anyhow::Result<&str> {
511511pub fn check_output ( output : & Output ) -> anyhow:: Result < ( ) > {
512512 std:: io:: stdout ( ) . write_all ( & output. stdout ) ?;
513513 std:: io:: stderr ( ) . write_all ( & output. stderr ) ?;
514- if !output. status . success ( ) {
515- let code = output. status . code ( ) . unwrap_or ( 1 ) ;
514+ check_exit_status ( output. status )
515+ }
516+
517+ pub fn check_exit_status ( output : ExitStatus ) -> anyhow:: Result < ( ) > {
518+ if !output. success ( ) {
519+ let code = output. code ( ) . unwrap_or ( 1 ) ;
516520 bail ! ( "subprocess exited with status code {code}" ) ;
517521 }
518522 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments