Merge pull request #2416 from devsnek/fix-newlines

Add lint check for missing newlines at end of tests and fix tests without the newlines
This commit is contained in:
Leo Balter 2019-11-11 14:48:55 -05:00 committed by GitHub
commit 13016eb89d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
168 changed files with 179 additions and 167 deletions

View File

@ -0,0 +1,10 @@
from ..check import Check
import re
class CheckPosix(Check):
'''Ensure tests are valid POSIX files'''
ID = 'POSIX'
def run(self, name, meta, source):
if not source.endswith('\n'):
return 'File must end with a newline'

View File

@ -43,6 +43,7 @@ from lib.checks.negative import CheckNegative
from lib.checks.filename import CheckFileName from lib.checks.filename import CheckFileName
from lib.checks.nopadding import CheckNoPadding from lib.checks.nopadding import CheckNoPadding
from lib.checks.flags import CheckFlags from lib.checks.flags import CheckFlags
from lib.checks.posix import CheckPosix
from lib.eprint import eprint from lib.eprint import eprint
import lib.frontmatter import lib.frontmatter
import lib.exceptions import lib.exceptions
@ -67,6 +68,7 @@ checks = [
CheckNegative(), CheckNegative(),
CheckNoPadding(), CheckNoPadding(),
CheckFlags(), CheckFlags(),
CheckPosix(),
] ]
def lint(file_names): def lint(file_names):

View File

@ -39,7 +39,7 @@ class TestLinter(unittest.TestCase):
def test_exceptions_single(self): def test_exceptions_single(self):
test_content = ('// Copyright (C) 2017 Mike Pennisi. All rights reserved.\n' + test_content = ('// Copyright (C) 2017 Mike Pennisi. All rights reserved.\n' +
'// This code is governed by the BSD license found in the LICENSE file.') '// This code is governed by the BSD license found in the LICENSE file.\n')
test_file = self.fixture('input.js', test_content) test_file = self.fixture('input.js', test_content)
exceptions_content = test_file + ' FRONTMATTER' exceptions_content = test_file + ' FRONTMATTER'
exceptions_file = self.fixture('lint.exceptions', exceptions_content) exceptions_file = self.fixture('lint.exceptions', exceptions_content)
@ -54,7 +54,7 @@ class TestLinter(unittest.TestCase):
def test_exceptions_comment(self): def test_exceptions_comment(self):
test_content = ('// Copyright (C) 2017 Mike Pennisi. All rights reserved.\n' + test_content = ('// Copyright (C) 2017 Mike Pennisi. All rights reserved.\n' +
'// This code is governed by the BSD license found in the LICENSE file.') '// This code is governed by the BSD license found in the LICENSE file.\n')
test_file = self.fixture('input.js', test_content) test_file = self.fixture('input.js', test_content)
exceptions_content = ('# One comment\n' + exceptions_content = ('# One comment\n' +
'# Another comment\n' + '# Another comment\n' +