diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7efad54964918671e2410887b0754442bd941149..36770af4c4969ec2ac9e1c7a1e83d4f01601c691 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ Test cases should be created in files that are named to identify the feature or API that's being tested. -There is no strict naming convention. The file names should be human readable, helpful and, ideally, consistent within a single directory. For examples: +The names should use alphanumeric characters and `.`, `-`, `_`. Otherwise, there is no strict naming convention, but the file names should be human readable, helpful and, ideally, consistent within a single directory. For examples: - `Math.fround` handling of `Infinity`: `test/built-ins/Math/fround/Math.fround_Infinity.js` - `Array.prototype.find` use with `Proxy`: `test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-1.js` diff --git a/test/built-ins/Object/internals/DefineOwnProperty/consistent-value-regexp-$1.js b/test/built-ins/Object/internals/DefineOwnProperty/consistent-value-regexp-dollar1.js similarity index 100% rename from test/built-ins/Object/internals/DefineOwnProperty/consistent-value-regexp-$1.js rename to test/built-ins/Object/internals/DefineOwnProperty/consistent-value-regexp-dollar1.js diff --git a/test/built-ins/Object/internals/DefineOwnProperty/consistent-writable-regexp-$1.js b/test/built-ins/Object/internals/DefineOwnProperty/consistent-writable-regexp-dollar1.js similarity index 100% rename from test/built-ins/Object/internals/DefineOwnProperty/consistent-writable-regexp-$1.js rename to test/built-ins/Object/internals/DefineOwnProperty/consistent-writable-regexp-dollar1.js diff --git a/tools/lint/lib/checks/filename.py b/tools/lint/lib/checks/filename.py new file mode 100644 index 0000000000000000000000000000000000000000..ef3cb28bf33faa61e24fa3e0d47b89fc57cc2e85 --- /dev/null +++ b/tools/lint/lib/checks/filename.py @@ -0,0 +1,13 @@ +import re + +from ..check import Check + +_DISALLOWED_PATTERN = re.compile('[^a-zA-Z0-9/\\-_.]') + +class CheckFileName(Check): + '''Ensure tests have a valid name.''' + ID = 'FILENAME' + + def run(self, name, meta, source): + if _DISALLOWED_PATTERN.search(name): + return "Contains non-alphanumeric or `-`, `_`, '.' characters." diff --git a/tools/lint/lint.py b/tools/lint/lint.py index 979616a5857a1f6126cc696c84fddf28a80cef51..1161a8526acea1e329a57135e71bd24a6de06bd2 100755 --- a/tools/lint/lint.py +++ b/tools/lint/lint.py @@ -32,6 +32,7 @@ from lib.checks.frontmatter import CheckFrontmatter from lib.checks.harnessfeatures import CheckHarnessFeatures from lib.checks.license import CheckLicense from lib.checks.negative import CheckNegative +from lib.checks.filename import CheckFileName from lib.eprint import eprint import lib.frontmatter import lib.whitelist @@ -46,6 +47,7 @@ parser.add_argument('path', checks = [ CheckEsid(), + CheckFileName(), CheckFrontmatter(), CheckFeatures('features.txt'), CheckHarnessFeatures(), diff --git a/tools/lint/test/fixtures/filename_forbidden_char_$.js b/tools/lint/test/fixtures/filename_forbidden_char_$.js new file mode 100644 index 0000000000000000000000000000000000000000..00b0cda07b1a9ece2f5d716699cb2a40d82dfcc4 --- /dev/null +++ b/tools/lint/test/fixtures/filename_forbidden_char_$.js @@ -0,0 +1,10 @@ +FILENAME +^ expected errors | v input +// Copyright (c) 2018 Valerie Young. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-assignment-operators-static-semantics-early-errors +description: Minimal test +---*/ + +void 0; diff --git a/tools/lint/test/fixtures/license_alternate_4,js b/tools/lint/test/fixtures/license_alternate_4.js similarity index 100% rename from tools/lint/test/fixtures/license_alternate_4,js rename to tools/lint/test/fixtures/license_alternate_4.js