mirror of
https://github.com/tc39/test262.git
synced 2025-06-10 09:00:36 +02:00
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.
This commit is contained in:
parent
f864edbc1c
commit
bd1acb51a4
@ -178,9 +178,15 @@ negative:
|
|||||||
`includes: [file-list]`
|
`includes: [file-list]`
|
||||||
|
|
||||||
This key names a list of files in the `harness/` directory that will be included in the test environment prior to running the test. Filenames **must** include the `.js` extension.
|
This key names a list of files in the `harness/` directory that will be included in the test environment prior to running the test. Filenames **must** include the `.js` extension.
|
||||||
|
Includes should use flow style without line break (separating items by commas and enclosing them in square brackets), block style (one line for each item, each line starting with a dash) isn't allowed.
|
||||||
When some code is used repeatedly across a group of tests, it may be appropriate to define it in a harness file. This practice increases test complexity, so it should be applied sparingly.
|
When some code is used repeatedly across a group of tests, it may be appropriate to define it in a harness file. This practice increases test complexity, so it should be applied sparingly.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
includes: [include1.js, include2.js]
|
||||||
|
```
|
||||||
|
|
||||||
#### author
|
#### author
|
||||||
`author: [string]`
|
`author: [string]`
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Testing descriptor property of Array.from
|
description: Testing descriptor property of Array.from
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
esid: sec-array.from
|
esid: sec-array.from
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Testing descriptor property of Array.isArray
|
description: Testing descriptor property of Array.isArray
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
esid: sec-array.isarray
|
esid: sec-array.isarray
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Intrinsic %FunctionPrototype% has poisoned own property "arguments"
|
description: Intrinsic %FunctionPrototype% has poisoned own property "arguments"
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
es6id: 8.2.2 S12, 9.2.7
|
es6id: 8.2.2 S12, 9.2.7
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Intrinsic %FunctionPrototype% has poisoned own property "caller"
|
description: Intrinsic %FunctionPrototype% has poisoned own property "caller"
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
es6id: 8.2.2 S12, 9.2.7
|
es6id: 8.2.2 S12, 9.2.7
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Testing descriptor property of Object.assign
|
description: Testing descriptor property of Object.assign
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
es6id: 19.1.2.1
|
es6id: 19.1.2.1
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ description: >
|
|||||||
Object.defineProperties - 'P' doesn't exist in 'O', test
|
Object.defineProperties - 'P' doesn't exist in 'O', test
|
||||||
[[Configurable]] of 'P' is set as false value if absent in
|
[[Configurable]] of 'P' is set as false value if absent in
|
||||||
accessor descriptor 'desc' (8.12.9 step 4.b.i)
|
accessor descriptor 'desc' (8.12.9 step 4.b.i)
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
/*---
|
/*---
|
||||||
esid: sec-object.hasown
|
esid: sec-object.hasown
|
||||||
description: Testing descriptor property of Object.hasOwn
|
description: Testing descriptor property of Object.hasOwn
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
author: Jamie Kyle
|
author: Jamie Kyle
|
||||||
features: [Object.hasOwn]
|
features: [Object.hasOwn]
|
||||||
---*/
|
---*/
|
||||||
|
@ -7,8 +7,7 @@ info: |
|
|||||||
es6id: 6.1.5.1
|
es6id: 6.1.5.1
|
||||||
author: Sam Mikes
|
author: Sam Mikes
|
||||||
description: Promise[Symbol.species] exists per spec
|
description: Promise[Symbol.species] exists per spec
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
features: [Symbol.species]
|
features: [Symbol.species]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ info: |
|
|||||||
es6id: 19.4.2.10
|
es6id: 19.4.2.10
|
||||||
author: Sam Mikes
|
author: Sam Mikes
|
||||||
description: Symbol.species exists
|
description: Symbol.species exists
|
||||||
includes:
|
includes: [propertyHelper.js]
|
||||||
- propertyHelper.js
|
|
||||||
features: [Symbol.species]
|
features: [Symbol.species]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -37,10 +37,18 @@ class CheckIncludes(Check):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_includes_flow_list(source):
|
||||||
|
match = re.search(r"includes:\s+\[(?P<includes>.+)\]", source)
|
||||||
|
return [inc.strip() for inc in match.group('includes').split(',') if inc] if match else []
|
||||||
|
|
||||||
def run(self, name, meta, source):
|
def run(self, name, meta, source):
|
||||||
if not meta or 'includes' not in meta:
|
if not meta or 'includes' not in meta:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if meta['includes'] != CheckIncludes._get_includes_flow_list(source):
|
||||||
|
return 'If present, the `includes` tag must use flow style, eg. includes: [include1.js, include2.js]'
|
||||||
|
|
||||||
harness_files = [self._load(name) for name in meta['includes']]
|
harness_files = [self._load(name) for name in meta['includes']]
|
||||||
|
|
||||||
if len(harness_files) == 0:
|
if len(harness_files) == 0:
|
||||||
|
13
tools/lint/test/fixtures/test/includes_invalid_non_flow_list.js
vendored
Normal file
13
tools/lint/test/fixtures/test/includes_invalid_non_flow_list.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
INCLUDES
|
||||||
|
^ expected errors | v input
|
||||||
|
// Copyright (C) 2019 Mike Pennisi. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-assignment-operators-static-semantics-early-errors
|
||||||
|
description: Minimal test
|
||||||
|
includes:
|
||||||
|
- propertyHelper.js
|
||||||
|
---*/
|
||||||
|
|
||||||
|
// This file uses "includes" as non flow style
|
||||||
|
verifyConfigurable(Object, '');
|
Loading…
x
Reference in New Issue
Block a user