Skip to content

Commit 461bf13

Browse files
committed
CI: catch malformed test cases
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
1 parent b74044f commit 461bf13

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

.github/emit_test_errors.pl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/perl -n
2+
3+
sub analyze_errors() {
4+
/^(FAIL|ERROR|XPASS):\s([^:\s]+):?\s+(.+)/;
5+
6+
my $type = $1;
7+
my $filename = $2;
8+
my $message = $3;
9+
my $line;
10+
11+
if ( !$type ) { return; }
12+
13+
if ( $message =~ /(at line (\d+))?.+(test for \w+, line (\d+))/g ) {
14+
$line = $2 || $4;
15+
}
16+
17+
my $command = "::error file=gcc/testsuite/$filename";
18+
if ($line) {
19+
$command = "$command,line=$line";
20+
}
21+
22+
print "$command,title=Test failure ($type)::$message\n";
23+
}
24+
25+
analyze_errors();

.github/workflows/ccpp.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ jobs:
7777
- name: Check regressions
7878
run: |
7979
cd gccrs-build; \
80-
if grep -e "unexpected" -e "unresolved" gcc/testsuite/rust/rust.sum;\
80+
if grep -e "unexpected" -e "unresolved" -e "ERROR:" gcc/testsuite/rust/rust.sum;\
8181
then \
82-
echo "some tests are not correct"; \
82+
echo "::error title=Regression test failed::some tests are not correct"; \
83+
perl -n ../.github/emit_test_errors.pl < gcc/testsuite/rust/rust.sum; \
8384
exit 1; \
8485
else \
8586
exit 0; \
@@ -142,9 +143,9 @@ jobs:
142143
- name: Check regressions
143144
run: |
144145
cd gccrs-build; \
145-
if grep -e "unexpected" -e "unresolved" gcc/testsuite/rust/rust.sum;\
146+
if grep -e "unexpected" -e "unresolved" -e "ERROR:" gcc/testsuite/rust/rust.sum;\
146147
then \
147-
echo "some tests are not correct"; \
148+
echo "::error title=Regression test failed::some tests are not correct"; \
148149
exit 1; \
149150
else \
150151
exit 0; \
@@ -196,9 +197,9 @@ jobs:
196197
- name: Check regressions
197198
run: |
198199
cd gccrs-build; \
199-
if grep -e "unexpected" -e "unresolved" gcc/testsuite/rust/rust.sum;\
200+
if grep -e "unexpected" -e "unresolved" -e "ERROR:" gcc/testsuite/rust/rust.sum;\
200201
then \
201-
echo "some tests are not correct"; \
202+
echo "::error title=Regression test failed::some tests are not correct"; \
202203
exit 1; \
203204
else \
204205
exit 0; \

0 commit comments

Comments
 (0)