Skip to content

Commit

Permalink
CheckstyleBear: Detect errors
Browse files Browse the repository at this point in the history
The first commit coala/coala@9bea8fe80,
and the rewrite in 9227382, ignored ERROR from checkstyle.

Also set java files to be native EOL in .gitattributes,
to match default EOL expected by Checkstyle rule
NewlineAtEndOfFile, and force DOS EOL on AppVeyor.

Also remove `test_run` as it uses `google` by default,
which is covered in the specifically named test method.

Fixes #1464
  • Loading branch information
jayvdb committed Mar 29, 2017
1 parent beee3dd commit d9234ef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .ci/appveyor.yml
Expand Up @@ -51,6 +51,10 @@ install:
build: false # Not a C# project, build stuff at the test step instead.

test_script:
# Force DOS format, as Checkstyle configs enable NewlineAtEndOfFile,
# which defaults to CRLF on Windows, and Appveyor CI ignores .gitattributes
# http://help.appveyor.com/discussions/problems/5687-gitattributes-changes-dont-have-any-effect
- unix2dos tests/java/test_files/CheckstyleGood.java
# Clang DLLs x64 were nowadays installed, but the x64 version hangs, so we
# exclude according tests. See https://github.com/appveyor/ci/issues/495 and
# https://github.com/appveyor/ci/issues/688
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
*.java text eol=native
2 changes: 1 addition & 1 deletion bears/java/CheckstyleBear.py
Expand Up @@ -33,7 +33,7 @@ def known_checkstyle_or_path(setting):

@linter(executable='java',
output_format='regex',
output_regex=r'\[(?P<severity>WARN|INFO)\].*?'
output_regex=r'\[(?P<severity>ERROR|WARN|INFO)\].*?'
r'(?P<line>\d+):?(?P<column>\d+)?. '
r'(?P<message>.*?) *\[(?P<origin>[a-zA-Z]+?)\]')
class CheckstyleBear:
Expand Down
10 changes: 5 additions & 5 deletions tests/java/CheckstyleBearTest.py
Expand Up @@ -24,24 +24,24 @@ def setUp(self):
self.empty_config = os.path.join(test_files,
'checkstyle_empty_config.xml')

def test_run(self):
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_style_google(self):
self.section['checkstyle_configs'] = 'google'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_style_sun(self):
self.section['checkstyle_configs'] = 'sun'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.good_file, valid=False)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_style_android(self):
self.section['checkstyle_configs'] = 'android-check-easy'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

self.section['checkstyle_configs'] = 'android-check-hard'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_config_failure_use_spaces(self):
self.section['checkstyle_configs'] = 'google'
Expand Down

0 comments on commit d9234ef

Please sign in to comment.