Tests for camel_case_for_classes codecheck fails

Bug #1388228 reported by Hans Joachim Desserud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Low
Unassigned

Bug Description

Edited one of the code check rules, so I ran the test suite before committing. To my surprise the tests for camel_case_for_classes failed, even though I hadn't touched it. I believe it might have been this way for a while.

$ ./cmake/codecheck/run_tests.py
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................FFFFFFFFF.........
======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'class my_class' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'class myClass' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'struct my_struct' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'struct myStruct' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'using my_typedef' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'using myTypedef' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'enum class my_enum' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'enum class myEnumenum my_enum' should fail, but passed

======================================================================
FAIL: runTest (__main__.ForbiddenTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./cmake/codecheck/run_tests.py", line 19, in runTest
    self._do_test()
  File "./cmake/codecheck/run_tests.py", line 36, in _do_test
    "Rule '%s' failed. Example '%s' should fail, but passed" % (self.c.name,self.tv) )
AssertionError: Rule 'camel_case_for_classes' failed. Example 'enum myEnum' should fail, but passed

----------------------------------------------------------------------
Ran 1274 tests in 0.283s

Related branches

Revision history for this message
GunChleoc (gunchleoc) wrote :

cmake/codecheck/CodeCheck.py works. Any particular reason you are using run_tests.py instead?

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

> Any particular reason you are using run_tests.py instead?

They do different things. :)

The code check consists of multiple rules files. These contain a regex and a set of allowed examples and and another list of forbidden examples.
run_tests.py goes through all the rules and verifies the allowed examples don't raise any warnings and that forbidden examples trigger the rule as expected. This is done to ensure that the rules behave the way we want and catch issues. (As a bonus, it makes it really easy to use Test Driven Design to write new rules or expand existing ones before running it on the WL source)

CodeCheck on the other hand, check the Widelands source code using the specified rules.

So the failures above indicate that the check for camel_case_for_classes above indicates that the rule doesn't catch the unwanted examples which means it won't be able to find and warn about it in the WL code base.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Now I now what the examples are used for :)

I expect that there is a mistake in the examples here. If we look at this one:

AssertionError: Rule 'camel_case_for_classes' failed. Example 'enum myEnum' should fail, but passed

Wrong, enum myEnum should pass.

On the other hand, this statement is wanted behaviour for the rule:

'enum class my_enum' should fail, but passed

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

I think the first step is to gather the allowed and forbidden examples according to where they actually belong. Then, if the tests are still failing, the regex should be fixed so that the examples have the expected behaviour.

GunChleoc (gunchleoc)
Changed in widelands:
milestone: build19-rc1 → none
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Still present in r8237. Looks like some of the tests from missing_space_starting_comment and upcast_without_macro are failing as well.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Yes, we never had another look at these, so they're still failing.

SirVer (sirver)
Changed in widelands:
status: Triaged → Won't Fix
status: Won't Fix → In Progress
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Ran 854 tests in 0.264s

OK

Works now after the branch got merged :)

Changed in widelands:
milestone: none → build20-rc1
status: In Progress → Fix Committed
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.