mirror of
https://github.com/tc39/test262.git
synced 2025-08-31 23:08:23 +02:00
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
32 lines
999 B
Python
32 lines
999 B
Python
from ..check import Check
|
|
|
|
_REQUIRED_FIELDS = set(['description'])
|
|
_OPTIONAL_FIELDS = set([
|
|
'author', 'es5id', 'es6id', 'esid', 'features', 'flags', 'includes',
|
|
'info', 'locale', 'negative', 'timeout'
|
|
])
|
|
_VALID_FIELDS = _REQUIRED_FIELDS | _OPTIONAL_FIELDS
|
|
|
|
class CheckFrontmatter(Check):
|
|
'''Ensure tests have the expected YAML-formatted metadata.'''
|
|
ID = 'FRONTMATTER'
|
|
|
|
def run(self, name, meta, source):
|
|
if '_FIXTURE' in name:
|
|
if meta is not None:
|
|
return '"Fixture" files cannot specify metadata'
|
|
return
|
|
|
|
if meta is None:
|
|
return 'No valid YAML-formatted frontmatter'
|
|
|
|
fields = set(meta.keys())
|
|
|
|
missing = _REQUIRED_FIELDS - fields
|
|
if len(missing) > 0:
|
|
return 'Required fields missing: %s' % ', '.join(list(missing))
|
|
|
|
unrecognized = fields - _VALID_FIELDS
|
|
if len(unrecognized) > 0:
|
|
return 'Unrecognized fields: %s' % ', '.join(list(unrecognized))
|