From cb436c69d9bcb0330518a48559649c9436ed5e7a Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 6 Aug 2020 14:55:39 +0200 Subject: executor: add some code style checks Move the test from pkg/csource to executor/ in order to be able to (1) run it on *.cc files, (2) run on unprocessed *.h files, (3) produce line numbers. Add a check for missed space after //. --- pkg/csource/csource_test.go | 48 --------------------------------------------- 1 file changed, 48 deletions(-) (limited to 'pkg/csource/csource_test.go') diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index a3a731a7c..ece28cd92 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -184,51 +184,3 @@ func TestExecutorMacros(t *testing.T) { } } } - -func TestExecutorMistakes(t *testing.T) { - mistakes := []struct { - pattern string - message string - tests []string - }{ - { - pattern: `\)\n\t*(debug|debug_dump_data)\(`, - message: "debug() calls are stripped from C reproducers, this code will break. Use {} around debug() to fix", - tests: []string{ - ` -if (foo) - debug("foo failed"); -`, ` - if (x + y) - debug_dump_data(data, len); -`, - }, - }, - { - // These are also not properly stripped by pkg/csource. - pattern: `/\*[^{]`, - message: "Don't use /* */ block comments. Use // line comments instead", - tests: []string{ - `/* C++ comment */`, - }, - }, - } - for _, mistake := range mistakes { - re := regexp.MustCompile(mistake.pattern) - for _, test := range mistake.tests { - if !re.MatchString(test) { - t.Errorf("patter %q does not match test %q", mistake.pattern, test) - } - } - for _, match := range re.FindAllStringIndex(commonHeader, -1) { - start, end := match[0], match[1] - for start != 0 && commonHeader[start] != '\n' { - start-- - } - for end != len(commonHeader) && commonHeader[end] != '\n' { - end++ - } - t.Errorf("%v:%v", mistake.message, commonHeader[start:end]) - } - } -} -- cgit mrf-deployment