On 11/10/16 16:13, Jeff Law wrote:
On 10/11/2016 05:01 AM, Bernd Schmidt wrote:
On 10/11/2016 12:56 PM, Jakub Jelinek wrote:
On Tue, Oct 11, 2016 at 11:47:21AM +0100, Kyrill Tkachov wrote:
check_GNU_style.sh complains a lot about dg-* directives in the
testsuite and in particular about line lengths.
There's nothing we can do about the directives and sometimes they're
supposed to be long, in particular the scan-assembler
checks in dg-final.  Currently check_GNU_style.sh has code to avoid
warning for dg-* directives but it's too weak, it doesn't
catch dg-final or dg-options directives.
This patch makes the code ignore all "{ dg-.*" lines for length
purposes.
This eliminates a lot of false positives in my patches and didn't
filter any legitimate warnings in my patches.

I wonder if we just shouldn't ignore all line lengths in testcases (or
perhaps any coding style whatsoever).  Some testcases are meant to be
formatted more-less according to our coding style (but, e.g.
/* PR tree-optimization/12345 */
comments never end with . and 2 spaces), except for dg- directives, but
others are entered in whatever form they came from the reporter.

I agree, probably best not to check testcases for style (but then I
don't trust automatic checkers anyway).
Agreed that checking testcases for style isn't desirable.


Ok, here's a patch that does that by filtering out everything between "+++.*testsuite/" and 
"+++<not testsuite>".
Is this is an ok approach?
This eliminates all testsuite warnings on a few of my patches that I tried it 
out on.

Disclaimer: I'm not an awk expert.

Thanks,
Kyrill

2016-10-11  Kyrylo Tkachov  <kyrylo.tkac...@arm.com>

    * check_GNU_style.sh (remove_testsuite): New function.
    Use it to remove testsuite from the diff.


jeff

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index 87a276c9cf47b5e07c4407f740ce05dce1928c30..f290a83e20eed7920155b2258d6cc6f424fc0dc0 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -81,7 +81,17 @@ if [ $nfiles -eq 1 ]; then
 else
     format="-nH"
 fi
+
+# Remove the testsuite part of the diff.  We don't care about GNU style
+# in testcases and the dg-* directives give too many false positives.
+remove_testsuite ()
+{
+  awk 'BEGIN{testsuite=0} /^\+\+\+[[:space:]]/ && ! /testsuite/{testsuite=0} \
+       {if (!testsuite) print} /\+\+\+[[:space:]].*testsuite\//{testsuite=1}'
+}
+
 grep $format '^+' $files \
+    | remove_testsuite \
     | grep -v ':+++' \
     > $inp
 
@@ -162,6 +172,7 @@ col (){
 	# Don't reuse $inp, which may be generated using -H and thus contain a
 	# file prefix.
 	grep -n '^+' $f \
+	    | remove_testsuite \
 	    | grep -v ':+++' \
 	    > $tmp
 
@@ -178,7 +189,7 @@ col (){
 	cat "$tmp" \
 	    | sed 's/^[0-9]*:+//' \
 	    | expand \
-	    | awk '$0 !~ /{[[:space:]]*dg-(error|warning|message)[[:space:]]/ { \
+	    | awk '{ \
 		     if (length($0) > 80) \
 		       printf "%s\033[1;31m%s\033[0m\n", \
 			      substr($0,1,80), \

Reply via email to