mirror of https://github.com/tc39/test262.git
add lint check for newline at end of file
This commit is contained in:
parent
1bc193528b
commit
833825849d
|
@ -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'
|
|
@ -43,6 +43,7 @@ from lib.checks.negative import CheckNegative
|
|||
from lib.checks.filename import CheckFileName
|
||||
from lib.checks.nopadding import CheckNoPadding
|
||||
from lib.checks.flags import CheckFlags
|
||||
from lib.checks.posix import CheckPosix
|
||||
from lib.eprint import eprint
|
||||
import lib.frontmatter
|
||||
import lib.exceptions
|
||||
|
@ -67,6 +68,7 @@ checks = [
|
|||
CheckNegative(),
|
||||
CheckNoPadding(),
|
||||
CheckFlags(),
|
||||
CheckPosix(),
|
||||
]
|
||||
|
||||
def lint(file_names):
|
||||
|
|
|
@ -39,7 +39,7 @@ class TestLinter(unittest.TestCase):
|
|||
|
||||
def test_exceptions_single(self):
|
||||
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)
|
||||
exceptions_content = test_file + ' FRONTMATTER'
|
||||
exceptions_file = self.fixture('lint.exceptions', exceptions_content)
|
||||
|
@ -54,7 +54,7 @@ class TestLinter(unittest.TestCase):
|
|||
|
||||
def test_exceptions_comment(self):
|
||||
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)
|
||||
exceptions_content = ('# One comment\n' +
|
||||
'# Another comment\n' +
|
||||
|
|
Loading…
Reference in New Issue