aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/csource_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-08-06 14:55:39 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-08-06 15:27:41 +0200
commitcb436c69d9bcb0330518a48559649c9436ed5e7a (patch)
tree1b1d474ad40b0748d3565c51938c1ed79b23f83e /pkg/csource/csource_test.go
parent56fe5665461fbbc19704e44c23e42d5f6ecb5361 (diff)
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 //.
Diffstat (limited to 'pkg/csource/csource_test.go')
-rw-r--r--pkg/csource/csource_test.go48
1 files changed, 0 insertions, 48 deletions
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])
- }
- }
-}