| 
 | 1 | +#!/bin/sh  | 
 | 2 | + | 
 | 3 | +# Default nightly behavior (write ICE to current directory)  | 
 | 4 | +# FIXME(estebank): these are failing on CI, but passing locally.  | 
 | 5 | +# $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default.log 2>&1  | 
 | 6 | +# default=$(cat ./rustc-ice-*.txt | wc -l)  | 
 | 7 | +# rm ./rustc-ice-*.txt  | 
 | 8 | + | 
 | 9 | +# Explicit directory set  | 
 | 10 | +export RUSTC_ICE=$TMPDIR  | 
 | 11 | +$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1  | 
 | 12 | +default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)  | 
 | 13 | +content=$(cat $TMPDIR/rustc-ice-*.txt)  | 
 | 14 | +rm $TMPDIR/rustc-ice-*.txt  | 
 | 15 | +RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1  | 
 | 16 | +short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)  | 
 | 17 | +rm $TMPDIR/rustc-ice-*.txt  | 
 | 18 | +RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-full.log 2>&1  | 
 | 19 | +full=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)  | 
 | 20 | +rm $TMPDIR/rustc-ice-*.txt  | 
 | 21 | + | 
 | 22 | +# Explicitly disabling ICE dump  | 
 | 23 | +export RUSTC_ICE=0  | 
 | 24 | +$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-disabled.log 2>&1  | 
 | 25 | +should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt | wc -l)  | 
 | 26 | +should_be_empty_dot=$(ls -l ./rustc-ice-*.txt | wc -l)  | 
 | 27 | + | 
 | 28 | +echo "#### ICE Dump content:"  | 
 | 29 | +echo $content  | 
 | 30 | +echo "#### default length:"  | 
 | 31 | +echo $default  | 
 | 32 | +echo "#### short length:"  | 
 | 33 | +echo $short  | 
 | 34 | +echo "#### default_set length:"  | 
 | 35 | +echo $default_set  | 
 | 36 | +echo "#### full length:"  | 
 | 37 | +echo $full  | 
 | 38 | +echo "#### should_be_empty_dot length:"  | 
 | 39 | +echo $should_be_empty_dot  | 
 | 40 | +echo "#### should_be_empty_tmp length:"  | 
 | 41 | +echo $should_be_empty_tmp  | 
 | 42 | + | 
 | 43 | +## Verify that a the ICE dump file is created in the appropriate directories, that  | 
 | 44 | +## their lengths are the same regardless of other backtrace configuration options,  | 
 | 45 | +## that the file is not created when asked to (RUSTC_ICE=0) and that the file  | 
 | 46 | +## contains at least part of the expected content.  | 
 | 47 | +if [ $short -eq $default_set ] &&  | 
 | 48 | +    #[ $default -eq $short ] &&  | 
 | 49 | +    [ $default_set -eq $full ] &&  | 
 | 50 | +    [[ $content == *"thread 'rustc' panicked at "* ]] &&  | 
 | 51 | +    [[ $content == *"stack backtrace:"* ]] &&  | 
 | 52 | +    #[ $default -gt 0 ] &&  | 
 | 53 | +    [ $should_be_empty_dot -eq 0 ] &&  | 
 | 54 | +    [ $should_be_empty_tmp -eq 0 ]; then  | 
 | 55 | +    exit 0  | 
 | 56 | +else  | 
 | 57 | +    exit 1  | 
 | 58 | +fi  | 
0 commit comments