Skip to content

Commit a5b3008

Browse files
committed
Enable cpplint regression tests
We have regression tests for cpplint.py, and should perhaps have used them to avoid silently failing.
1 parent ccce53c commit a5b3008

File tree

35 files changed

+141
-73
lines changed

35 files changed

+141
-73
lines changed

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ add_subdirectory(validate-trace-xml-schema)
6969
add_subdirectory(cbmc-primitives)
7070
add_subdirectory(goto-interpreter)
7171
add_subdirectory(cbmc-sequentialization)
72+
add_subdirectory(cpp-linter)
7273

7374
if(WITH_MEMORY_ANALYZER)
7475
add_subdirectory(snapshot-harness)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ DIRS = cbmc \
4242
cbmc-primitives \
4343
goto-interpreter \
4444
cbmc-sequentialization \
45+
cpp-linter \
4546
# Empty last line
4647

4748
ifeq ($(OS),Windows_NT)

regression/cpp-linter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_test_pl_tests("../../../scripts/cpplint.py")

regression/cpp-linter/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
default: tests.log
22

33
test:
4-
@../test.pl -p -c "python ../../../scripts/cpplint.py"
4+
@../test.pl -p -c ../../../scripts/cpplint.py
55

66
tests.log: ../test.pl
7-
@../test.pl -p -c "python ../../../scripts/cpplint.py"
7+
@../test.pl -p -c ../../../scripts/cpplint.py
88

99
show:
1010
@for dir in *; do \
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:8: assert is deprecated, use INVARIANT instead \[build/deprecated\] \[4\]
5-
^Total errors found: 1$
4+
^regression/cpp-linter/assert/main\.cpp:8: assert is deprecated, use UNREACHABLE instead \[build/deprecated\] \[4\]
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$

regression/cpp-linter/class-decl-space/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ Author: Thomas Kiley, thomas@diffblue.com
66
77
\*******************************************************************/
88

9+
// clang-format off
910
class temp_classt : public base_classt
1011
{}
1112

12-
class another_class : public base_classt
13+
class another_class: public base_classt
1314
{}
1415

15-
class more_class:public base_classt
16+
class more_class: public base_classt
1617
{}
1718

1819
class nonderived
@@ -41,3 +42,4 @@ class testt
4142
template<class U>
4243
void bar(U t);
4344
}
45+
// clang-format on
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:9: There shouldn.t be a space between class identifier and : \[readability/identifiers\] \[4\]$
5-
^main\.cpp:12: There shouldn.t be a space between class identifier and : \[readability/identifiers\] \[4\]$
6-
^main\.cpp:12: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
7-
^main\.cpp:15: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
8-
^main\.cpp:18: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
9-
^main\.cpp:26: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
10-
^main\.cpp:30: Remove spaces around < \[whitespace/operators\] \[4\]$
11-
^main\.cpp:36: Remove spaces around < \[whitespace/operators\] \[4\]$
12-
^Total errors found: 8$
4+
^regression/cpp-linter/class-decl-space/main\.cpp:13: There should be a space between class identifier and : \[readability/identifier_spacing\] \[4\]$
5+
^regression/cpp-linter/class-decl-space/main\.cpp:16: There should be a space between class identifier and : \[readability/identifier_spacing\] \[4\]$
6+
^regression/cpp-linter/class-decl-space/main\.cpp:13: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
7+
^regression/cpp-linter/class-decl-space/main\.cpp:16: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
8+
^regression/cpp-linter/class-decl-space/main\.cpp:19: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
9+
^regression/cpp-linter/class-decl-space/main\.cpp:27: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
10+
^# Total errors found: 6$
11+
^EXIT=1$
1312
^SIGNAL=0$
1413
--
14+
--
15+
The following patters are disabled as the corresponding checks in cpplint.py
16+
were commented out in 56aea470fd6 for they yield too many false positives:
17+
^regression/cpp-linter/class-decl-space/main\.cpp:31: Remove spaces around < \[whitespace/operators\] \[4\]$
18+
^regression/cpp-linter/class-decl-space/main\.cpp:37: Remove spaces around < \[whitespace/operators\] \[4\]$
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:31: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
5-
^main\.cpp:38: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
6-
^Total errors found: 2$
4+
^regression/cpp-linter/do-while1/main\.cpp:31: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
5+
^regression/cpp-linter/do-while1/main\.cpp:38: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
78
^SIGNAL=0$
89
--
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:26: while statement of do...while loop should be on a separate line to the closing brace \[readability/braces\] \[4\]
5-
^Total errors found: 1$
4+
^EXIT=0$
65
^SIGNAL=0$
76
--
7+
--
8+
Test was marked as disabled-by-default in a00edd3e6c54.
9+
^main\.cpp:26: while statement of do...while loop should be on a separate line to the closing brace \[readability/braces\] \[4\]
10+
^# Total errors found: 1$
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
^main\.cpp:26: Could not find function header comment for foo \[readability/function_comment\] \[4\]
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
11+
caused the check to never take place. That's fine, however, as we don't use
12+
these function headers anymore.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
main\.cpp:15: Function header for fun missing Inputs: \[readability/function_comment\] \[4\]
55
main\.cpp:15: Function header for fun missing Outputs: \[readability/function_comment\] \[4\]
66
main\.cpp:15: Function header for fun missing Purpose: \[readability/function_comment\] \[4\]
7-
^Total errors found: 3$
7+
^# Total errors found: 3$
8+
^EXIT=1$
89
^SIGNAL=0$
910
--
11+
--
12+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
13+
caused the check to never take place. That's fine, however, as we don't use
14+
these function headers anymore.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
^main\.cpp:20: Insert an empty line between function header comment and the function fun \[readability/function_comment\] \[4\]$
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
11+
caused the check to never take place. That's fine, however, as we don't use
12+
these function headers anymore.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
^main\.cpp:11: Function: name in the comment doesn.t match the function name \[readability/function_comment\] \[4\]
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
11+
caused the check to never take place. That's fine, however, as we don't use
12+
these function headers anymore.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:24: Put braces on a separate next line \[whitespace/braces\] \[5\]$
5-
^main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
6-
^main\.cpp:26: Else if should be on a new line after closing brace \[readability/braces\] \[5\]$
7-
^main\.cpp:28: Put braces on a separate next line \[whitespace/braces\] \[5\]$
8-
^main\.cpp:28: Else should be on a new line after closing brace \[readability/braces\] \[5\]$
9-
^Total errors found: 5$
4+
^regression/cpp-linter/if-else1/main\.cpp:26: Else if should be on a new line after closing brace \[readability/braces\] \[5\]$
5+
^regression/cpp-linter/if-else1/main\.cpp:28: Else should be on a new line after closing brace \[readability/braces\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
108
^SIGNAL=0$
119
--
10+
--
11+
The following patters are disabled as the corresponding checks in cpplint.py
12+
were removed in 692c4f377 for they are covered by clang-format:
13+
^regression/cpp-linter/if-else1/main\.cpp:24: Put braces on a separate next line \[whitespace/braces\] \[5\]$
14+
^regression/cpp-linter/if-else1/main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
15+
^regression/cpp-linter/if-else1/main\.cpp:28: Put braces on a separate next line \[whitespace/braces\] \[5\]$
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
CORE
22
main.cpp
33

4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The following patters are disabled as the corresponding checks in cpplint.py
9+
were removed in 692c4f377 for they are covered by clang-format:
410
^main\.cpp:23: Put braces on a separate next line \[whitespace/braces\] \[5\]$
511
^main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
612
^main\.cpp:29: Put braces on a separate next line \[whitespace/braces\] \[5\]$
7-
^Total errors found: 3$
8-
^SIGNAL=0$
9-
--
13+
^# Total errors found: 3$
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5-
^main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6-
^main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
7-
^Total errors found: 3$
4+
^regression/cpp-linter/if-else3/main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5+
^regression/cpp-linter/if-else3/main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
88
^SIGNAL=0$
99
--
10+
--
11+
The following patters are disabled as the corresponding checks in cpplint.py
12+
were commented out in 56aea470fd6 for they yield too many false positives:
13+
^regression/cpp-linter/if-else3/main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5-
^main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6-
^main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
7-
^Total errors found: 3$
4+
^regression/cpp-linter/if-else4/main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5+
^regression/cpp-linter/if-else4/main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
88
^SIGNAL=0$
99
--
10+
--
11+
The following patters are disabled as the corresponding checks in cpplint.py
12+
were commented out in 56aea470fd6 for they yield too many false positives:
13+
^regression/cpp-linter/if-else4/main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CORE
22
main.cpp
33

4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The following patters are disabled as the corresponding checks in cpplint.py
9+
were commented out in 56aea470fd6 for they yield too many false positives:
410
^main\.cpp:29: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
511
^main\.cpp:34: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
612
^main\.cpp:43: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
@@ -11,7 +17,4 @@ main.cpp
1117
^main\.cpp:76: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
1218
^main\.cpp:81: If parameters or arguments require a line break, the closing bracket should be on the same line as the final parameter \[whitespace/indent\] \[4\]
1319
^main\.cpp:85: If parameters or arguments require a line break, each parameter should be put on its own line. \[whitespace/indent\] \[4\]
14-
^Total errors found: 10$
15-
^EXIT=1$
16-
^SIGNAL=0$
17-
--
20+
^# Total errors found: 10$
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
CORE
22
main.cpp
33

4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The following patters are disabled as the corresponding checks in cpplint.py
9+
were commented out in 56aea470fd6 for they yield too many false positives:
410
^main\.cpp:24: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
511
^main\.cpp:29: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
612
^main\.cpp:60: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
713
^main\.cpp:65: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
8-
^Total errors found: 4$
9-
^EXIT=1$
10-
^SIGNAL=0$
11-
--
14+
^# Total errors found: 4$
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
CORE
1+
FUTURE
22
main.cpp
33

44
^main\.cpp:23: Remove spaces around = \[whitespace/operators\] \[4\]
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
Test disabled (marked as "FUTURE") as the corresponding checks in cpplint.py
11+
were commented out in 56aea470fd6 for they yield too many false positives.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/operator-spacing3/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ main.cpp
55
^main\.cpp:27: Missing spaces around << \[whitespace/operators\] \[3\]
66
^main\.cpp:29: Remove spaces around << \[whitespace/operators\] \[4\]
77
^main\.cpp:29: Remove spaces around << \[whitespace/operators\] \[4\]
8-
^Total errors found: 4$
8+
^# Total errors found: 4$
9+
^EXIT=1$
910
^SIGNAL=0$
1011
--

regression/cpp-linter/override-final/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Author: Thomas Kiley, thomas@diffblue.com
66
77
\*******************************************************************/
88

9-
class test_classt:public base_classt
9+
class test_classt : public base_classt
1010
{
1111
public:
1212
virtual void fun() override final;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.cpp
33

4-
^EXIT=0$
4+
^regression/cpp-linter/override-final/main\.cpp:12: "virtual" is redundant since function is already declared as "override" \[readability/inheritance\] \[4\]$
5+
^EXIT=1$
56
^SIGNAL=0$
67
--

0 commit comments

Comments
 (0)