Commit Graph

35 Commits

Author SHA1 Message Date
Philip Chimento a58ae41ea7 linter: Fix parsing features.txt
Previously, split() would split on whitespace, then the if-condition would
remove `#` - interpreting every word in every comment in the file as a
potential valid feature flag. We want splitlines() here.

Partial-line comments were inadvertently "supported" before, because of
this bug. Instead, support them explicitly by chopping off a `#`
character, anything after it, and any whitespace immediately preceding it.
2023-03-06 17:31:20 +01:00
Philip Chimento 6e1b737357 linter: Use same Python interpreter when executing script in subprocess
If a specific Python interpreter is used (e.g. by invoking the script with
"/path/to/python run.py") then we should use the same Python interpreter
to execute scripts in subprocesses, not the one from the environment.

The path to the running Python interpreter is given by sys.executable.
2023-03-06 17:31:20 +01:00
Csaba Osztrogonác 00f682e746 tools: enforce restriction on YAML negative key
The phase field must precede the type field for negative tests
to have a consistent style and be able to parse easier.
Related to the goal of https://github.com/tc39/test262/issues/1997

Added this check to the linting script and updated tests accordingly.
2022-01-10 13:50:38 -05:00
Csaba Osztrogonác bd1acb51a4 tools: enforce restriction on YAML includes key
Includes key should use flow notation to be able parsed easier
as suggested in https://github.com/tc39/test262/issues/1997

Added this check to the linting script and updated tests accordingly.
2022-01-05 17:27:58 -05:00
Mike Pennisi c4e54648c0 tools: enforce restriction on YAML
Some consumers have reported difficulty parsing an uncommon YAML
construction [1] [2] [3]. Extend the linter to help ensure that
construction is not used in future contributions.

[1] https://github.com/tc39/test262/issues/1997
[2] https://github.com/tc39/test262/pull/2505
[3] https://github.com/tc39/test262/issues/3171
2021-09-07 17:41:36 -04:00
Rick Waldron 304edd2296
chore: migrate $ERROR -> throw new Test262Error in tools/lint/test/fixtures/harness/propertyHelper.js (#3124) 2021-07-29 12:34:53 -07:00
jugglinmike 6c9d2222fb
lint: disallow duplicate values in "features" tag (#3010) 2021-06-24 13:38:18 -04:00
jugglinmike 64a8968246
lint: disallow extra fields in "negative" metadata (#3009) 2021-06-24 13:37:55 -04:00
Mike Pennisi 56ca8add7d Update project structure to support non-JS files
This change is in service of forthcoming tests for the "JSON modules"
language proposal [1]. Verifying the semantics of that proposal requires
modules whose source text is not valid ECMAScript; this change updates
the guidelines for contributing and interpreting tests so that such test
material can be handled consistently.

Differentiating JSON files with a distinct file name suffice will assist
consumers which require special handling of such files (e.g. web
browsers).

Change the pattern used to designate "fixture" files so that it may be
applied to files used for JSON modules.

Increment the project version number to alert consumers of this change
in interpreting instructions.

[1] https://github.com/tc39/proposal-json-modules
2021-05-28 20:02:59 -04:00
Leo Balter 2e127ec40e Rename usage of master to main
Ref #2699
2020-07-15 15:47:15 -04:00
Gus Caplan 833825849d
add lint check for newline at end of file 2019-11-10 20:18:53 -08:00
Mike Pennisi a9111d7144 lint: add rule to verify use of harness files
Verify that every test file which references a harness file using the
"includes" directive also contains at least one reference to a value
defined in the harness file.

To support this check, extend each harness file with a list of values
which it defines.
2019-09-25 14:00:50 -04:00
Mike Pennisi bb5a6622d4 lint: Compute ergonomic name for tests
The command-line interface to Python's "unittest" module allows users to
run tests by name, e.g.

    $ test.py TestLinter.test_foo

If the tests include a period, they cannot be referenced in this way.
Rename the tests to omit the filename extension so that they may be
referenced from the command-line in this way.
2019-09-25 14:00:50 -04:00
Mike Pennisi f38748efc1 lint: Increase isolation between tests and project
Prior to this commit, the tests for the linter partially depended on
project files. This coupling risks churn in the tests: if the needs of
the project change (e.g. a harness file is modified), then the linter
tests would need to be updated. It also made the tests more difficult to
understand because the input was both larger and more complicated than
necessary to exercise the relevant functionality.

Execute the tests in the context of the fixture directory and introduce
minimal support files that serve the same purpose as the corresponding
project files.
2019-09-25 14:00:50 -04:00
Ms2ger 0b5ff0e151 Lint: Expect bytes rather than unicode from subprocess. 2019-08-12 17:14:07 +02:00
Ms2ger 8946956f19 Lint: Make CheckHarnessFeatures output stable.
The iteration order for a set is not guaranteed to be stable, but this test expected it to be.
2019-08-12 17:14:07 +02:00
Leo Balter 002d3484d6 Add tests for linter 2019-07-15 14:03:25 -04:00
André Bargull c822f4c929 Fix existing linting errors, update error phase, and add a new flags linter (#2086) 2019-03-06 12:24:44 -05:00
Leo Balter 8e0c0eac10 Linter should require direct throw statement for raw tests instead of DONOTEVALUATE 2019-02-14 15:06:08 -05:00
Leo Balter 48a7471060 Relax lint check for licensing in files 2019-02-14 15:06:08 -05:00
Leo Balter 7054805941
rename whitelist to exceptions in the linter tool (#2004) 2018-12-18 15:39:57 -02:00
Mathias Bynens b9daa57dcb Rename to $DONOTEVALUATE per @leobalter's suggestion 2018-10-23 13:51:17 +02:00
Mathias Bynens e3feffb01e Move `throw "…"` for negative parsing errors to a helper function
Closes #1634.
2018-10-23 13:51:16 +02:00
Rick Waldron ae925f6791 Lint: make esid check allow "%" (#1638) 2018-07-13 16:39:32 -04:00
jugglinmike ac02aa57ff Relax linting rules for `esid` metadata (#1632)
The document fragments used by the ECMAScript specification do not
conform to any particular pattern beyond the grammar defined by the URL
standard [1]. Relax the linting rule to enforce a simplified version of
that grammar.

[1] https://url.spec.whatwg.org/#fragment-state
2018-07-09 12:29:43 -04:00
Rick Waldron c686cc6099 Lint: disallow calls to verifyConfigurable and verifyProperty in same file 2018-06-07 22:38:36 -04:00
Valerie R Young 40883f4c6a Update filename character restriction in documention, linter and a few filenames 2018-05-11 22:19:01 -04:00
Mike Pennisi e6d674ef7a Rename negative test "phase" for module resolution 2018-01-05 15:17:51 -05:00
Mike Pennisi 136110378b Rename negative test "phase" for parsing
Early errors may result from parsing the source text of a test file, but
they may also result from parsing some other source text as referenced
through the ES2015 module syntax. The latter form of early error is not
necessarily detectable by ECMAScript parsers, however. Because of this,
the label "early" is not sufficiently precise for all Test262 consumers
to correctly interpret all tests.

Update the "phase" name of "early" to "parse" for all those negative
tests that describe errors resulting from parsing of the file's source
text directly. A forthcoming commit will update the remaining tests to
use a "phase" name that is more specific to module resolution.
2018-01-05 15:17:50 -05:00
Rick Waldron e294b8004d Rename fixture and change actual test, because an empty "features" list is invalid anyway! 2017-09-08 13:05:21 -04:00
Rick Waldron 1df51ee19c Lint/test: update multiple includes test 2017-09-08 12:48:06 -04:00
Rick Waldron 65424be3ef Lint: harness features flag enforcement via linter 2017-09-08 12:24:48 -04:00
Mike Pennisi 53842533b7 Enforce use of `throw` stmt in early error tests
Previously, test consumers were encouraged to insert a `throw` statement
as the first statement of tests for early errors. This recommendation
made tests harder to consume, and as an optional transformation,
consumers may have ignored it or simply been unaware it was made. By
explicitly including such a `throw` statement, the tests become more
literal, making them easier to consume and more transparent in their
expectations.

Document expectation for all tests for early errors to include an
explicit `throw` statement. Extend linting script to verify that
contributors are automatically notified of violations and to ensure that
future contributions satisfy this expectation.
2017-06-28 11:24:36 -04:00
jugglinmike 66bd632bae Lint test `features` tag (#1060)
A recent commit introduced a document that enumerated acceptable values
for the test "features" metadata tag. However, this list was incomplete,
and maintaining it placed extra burden on the project owners.

Restructure the document into a machine-readable format. Add entries for
all previously-omitted values. Add in-line documentation with
recommendations for maintenance of the file. Extend the project's
linting tool to validate tests according to the document's contents.
2017-06-12 18:59:14 -03:00
jugglinmike 74954bfa91 Introduce automated validation for test format (#994)
This script is intended to identify common test file formatting errors
prior to their acceptance into the project. It is designed to support
future extensions for additional validation rules.
2017-05-01 12:04:05 -04:00