Skip to content

Commit 217d97a

Browse files
committed
Add run-make test for ICE dump
1 parent 8eb5843 commit 217d97a

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include ../tools.mk
2+
3+
# ignore-windows
4+
5+
export RUSTC := $(RUSTC_ORIGINAL)
6+
export TMPDIR := $(TMPDIR)
7+
8+
all:
9+
bash check.sh
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn func(s: &str) {
2+
println!("{}", s);
3+
}
4+
5+
fn main() {
6+
func(1);
7+
}

0 commit comments

Comments
 (0)