From d9234efc8ca10fadcb85d2da5ce3d173cd01575a Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 27 Feb 2017 22:34:33 +0700 Subject: [PATCH] CheckstyleBear: Detect errors The first commit https://github.com/coala/coala/commit/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 https://github.com/coala/coala-bears/issues/1464 --- .ci/appveyor.yml | 4 ++++ .gitattributes | 1 + bears/java/CheckstyleBear.py | 2 +- tests/java/CheckstyleBearTest.py | 10 +++++----- 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .gitattributes diff --git a/.ci/appveyor.yml b/.ci/appveyor.yml index 4a3e0feba9..fc0c449b13 100644 --- a/.ci/appveyor.yml +++ b/.ci/appveyor.yml @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..3114a98fca --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.java text eol=native diff --git a/bears/java/CheckstyleBear.py b/bears/java/CheckstyleBear.py index dba5d7b487..29b77feb52 100644 --- a/bears/java/CheckstyleBear.py +++ b/bears/java/CheckstyleBear.py @@ -33,7 +33,7 @@ def known_checkstyle_or_path(setting): @linter(executable='java', output_format='regex', - output_regex=r'\[(?PWARN|INFO)\].*?' + output_regex=r'\[(?PERROR|WARN|INFO)\].*?' r'(?P\d+):?(?P\d+)?. ' r'(?P.*?) *\[(?P[a-zA-Z]+?)\]') class CheckstyleBear: diff --git a/tests/java/CheckstyleBearTest.py b/tests/java/CheckstyleBearTest.py index 0cae329971..b9eed1b56d 100644 --- a/tests/java/CheckstyleBearTest.py +++ b/tests/java/CheckstyleBearTest.py @@ -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'