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
This commit is contained in:
Mike Pennisi 2021-05-28 18:53:04 -04:00 committed by Rick Waldron
parent 10fc95cacb
commit 56ca8add7d
63 changed files with 18 additions and 8 deletions

View File

@ -250,9 +250,9 @@ function Test262Error(message) {
}
```
## Rules For Module `_FIXTURE.js` Files
## Rules For Module `_FIXTURE` Files
The [Module section of INTERPRETING.md](https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md#modules) states that `_FIXTURE.js` files will not have have Realm modifications applied. In practice, this means that code in `_FIXTURE.js` files must abide by the following rules:
The [Module section of INTERPRETING.md](https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md#modules) states that `_FIXTURE` files will not have have Realm modifications applied. In practice, this means that code in `_FIXTURE` files must abide by the following rules:
- **MUST NOT** refer to, or make use of any [Test262-Defined Bindings](https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md#test262-defined-bindings) in any way.
- **MUST NOT** refer to, or make use of any [Host-Defined Functions](https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md#host-defined-functions) in any way.

View File

@ -138,7 +138,7 @@ This must precede any additional text modifications described by test metadata.
### Modules
Test262 includes tests for ECMAScript 2015 module code, denoted by the "module"
metadata flag. Files bearing a name ending in `_FIXTURE.js` **MUST NOT** be interpreted as standalone tests; they are intended to be referenced by test files. Realm modifications, including [Test262-Defined Bindings](#test262-defined-bindings) and [Host-Defined Functions](#host-defined-functions), are not applied to code executed from `_FIXTURE.js` files. See the [**Rules For Module `_FIXTURE.js` Files** section of CONTRIBUTING.md](https://github.com/tc39/test262/blob/HEAD/CONTRIBUTING.md#rules-for-module-fixturejs-files) for more information.
metadata flag. Files bearing a name which includes the sequence `_FIXTURE` **MUST NOT** be interpreted as standalone tests; they are intended to be referenced by test files. Realm modifications, including [Test262-Defined Bindings](#test262-defined-bindings) and [Host-Defined Functions](#host-defined-functions), are not applied to code executed from `_FIXTURE` files. See the [**Rules For Module `_FIXTURE` Files** section of CONTRIBUTING.md](https://github.com/tc39/test262/blob/HEAD/CONTRIBUTING.md#rules-for-module-fixturejs-files) for more information.
All module specifiers used by Test262 begin with the character sequence `./`.
The remaining characters should be interpreted as the name of a file within the
@ -157,6 +157,8 @@ import * as ns from './dep.js';
Implementers should attempt to resolve this module specifier by loading a file
located at `test/language/import/nested/dep.js`.
Files bearing a name ending in `.json` are intended to be interpreted as JSON.
## Test Results
By default, tests signal failure by generating an uncaught exception. If

View File

@ -315,3 +315,7 @@ error-cause
# Import Assertions
# https://github.com/tc39/proposal-import-assertions/
import-assertions
# JSON modules
# https://github.com/tc39/proposal-json-modules
json-modules

View File

@ -1,6 +1,6 @@
{
"name": "test262",
"version": "4.0.0",
"version": "5.0.0",
"description": "Test262 tests conformance to the continually maintained draft future ECMAScript standard found at http://tc39.github.io/ecma262/ , together with any Stage 3 or later TC39 proposals.",
"repository": {
"type": "git",

View File

@ -12,7 +12,7 @@ class CheckFrontmatter(Check):
ID = 'FRONTMATTER'
def run(self, name, meta, source):
if name.endswith('_FIXTURE.js'):
if '_FIXTURE' in name:
if meta is not None:
return '"Fixture" files cannot specify metadata'
return

View File

@ -23,6 +23,9 @@ class CheckLicense(Check):
ID = 'LICENSE'
def run(self, name, meta, source):
if name.endswith('.json'):
return
if meta and 'flags' in meta and 'generated' in meta['flags']:
return

View File

@ -0,0 +1,2 @@
^ expected errors | v input
"Neither frontmatter nor copyright are required for JSON files because those would invalidate the content."

View File

@ -92,11 +92,10 @@ def create_file_test(name, fspath):
test.__name__ = 'test_' + file_name.split('.')[0]
return test
dirname = os.path.join(os.path.abspath(testDir), 'fixtures')
dirname = os.path.join(os.path.abspath(testDir), 'fixtures', 'test')
for file_name in os.listdir(dirname):
full_path = os.path.join(dirname, file_name)
if (not os.path.isfile(full_path) or file_name.startswith('.') or
not file_name.endswith('.js')):
if (not os.path.isfile(full_path) or file_name.startswith('.')):
continue
t = create_file_test(file_name, full_path)