File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,12 @@ cargo_test_options() {
2424}
2525
2626cargo_test () {
27- RUST_BACKTRACE=1 cargo nextest run --profile ci $( cargo_test_options $1 )
27+ LOG_PATH=$( mktemp)
28+ tail -f ${LOG_PATH} &
29+ TAIL_PID=$!
30+ LOG_UNCAPTURED=${LOG_PATH} RUST_BACKTRACE=1 cargo nextest run --profile ci $( cargo_test_options $1 )
2831 (( CARGO_RESULT = ${CARGO_RESULT} || $? ))
2932 mv target/nextest/ci/junit.xml $2
33+ kill ${TAIL_PID}
34+ rm ${LOG_PATH}
3035}
Original file line number Diff line number Diff line change @@ -525,8 +525,24 @@ pub(crate) fn log_uncaptured<S: AsRef<str>>(text: S) {
525525 use std:: io:: Write ;
526526
527527 let mut stderr = std:: io:: stderr ( ) ;
528- stderr. write_all ( text. as_ref ( ) . as_bytes ( ) ) . unwrap ( ) ;
529- stderr. write_all ( b"\n " ) . unwrap ( ) ;
528+ let mut sinks = vec ! [ & mut stderr as & mut dyn Write ] ;
529+ let mut other;
530+ let other_path = std:: env:: var ( "LOG_UNCAPTURED" ) . unwrap_or ( "/dev/tty" . to_string ( ) ) ;
531+ if let Ok ( f) = std:: fs:: OpenOptions :: new ( ) . append ( true ) . open ( & other_path) {
532+ other = f;
533+ sinks. push ( & mut other) ;
534+ }
535+
536+ for sink in sinks {
537+ sink. write_all ( text. as_ref ( ) . as_bytes ( ) ) . unwrap ( ) ;
538+ sink. write_all ( b"\n " ) . unwrap ( ) ;
539+ }
540+ }
541+
542+ #[ test]
543+ fn log_uncaptured_example ( ) {
544+ println ! ( "this is captured" ) ;
545+ log_uncaptured ( "this is not captured" ) ;
530546}
531547
532548pub ( crate ) fn file_level_log ( message : impl AsRef < str > ) {
You can’t perform that action at this time.
0 commit comments