From 40883f4c6ae17e073dfd03e34f73a6bf8c855595 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Wed, 2 May 2018 16:14:31 -0400 Subject: [PATCH] Update filename character restriction in documention, linter and a few filenames --- CONTRIBUTING.md | 2 +- ...exp-$1.js => consistent-value-regexp-dollar1.js} | 0 ...-$1.js => consistent-writable-regexp-dollar1.js} | 0 tools/lint/lib/checks/filename.py | 13 +++++++++++++ tools/lint/lint.py | 2 ++ .../lint/test/fixtures/filename_forbidden_char_$.js | 10 ++++++++++ ...icense_alternate_4,js => license_alternate_4.js} | 0 7 files changed, 26 insertions(+), 1 deletion(-) rename test/built-ins/Object/internals/DefineOwnProperty/{consistent-value-regexp-$1.js => consistent-value-regexp-dollar1.js} (100%) rename test/built-ins/Object/internals/DefineOwnProperty/{consistent-writable-regexp-$1.js => consistent-writable-regexp-dollar1.js} (100%) create mode 100644 tools/lint/lib/checks/filename.py create mode 100644 tools/lint/test/fixtures/filename_forbidden_char_$.js rename tools/lint/test/fixtures/{license_alternate_4,js => license_alternate_4.js} (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7efad54964..36770af4c4 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 0000000000..ef3cb28bf3 --- /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 979616a585..1161a8526a 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 0000000000..00b0cda07b --- /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