Skip to content

Commit f5bbaf3

Browse files
committed
Added code and readme
1 parent eb3e77b commit f5bbaf3

File tree

5 files changed

+516
-18
lines changed

5 files changed

+516
-18
lines changed

LICENSE

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
MIT License
1+
BSD 3-Clause License
22

33
Copyright (c) 2022 js-temporal
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Redistribution and use in source and binary forms, with or without modification,
6+
are permitted provided that the following conditions are met:
117

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
1410

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
1-
# temporal-test262-runner
2-
Lightweight runner for ECMAScript Temporal's Test262 tests
1+
2+
# Lightweight runner for ECMAScript Temporal's Test262 tests
3+
4+
This package provides a fast way for polyfills of ECMAScript
5+
[`Temporal`](https://github.com/tc39/proposal-temporal) to run Temporal's 5,000+
6+
Test262 tests. Test262 (https://github.com/tc39/test262) is the official
7+
conformance test suite for ECMAScript, and this package quickly runs a subset of
8+
those tests that are specific to Temporal. All Temporal polyfills should pass
9+
Test262.
10+
11+
This runner is much faster than
12+
[`test262-harness`](https://github.com/bterlson/test262-harness) (the default
13+
Test262 harness) because:
14+
* It runs only 5000+ Temporal-specific tests, instead of the full suite.
15+
* It pre-parses the Temporal polyfill into a
16+
[`vm.Script`](https://nodejs.org/api/vm.html#class-vmscript), instead of
17+
reading and parsing the whole file once for each test like the prelude option
18+
of `test262-harness` does.
19+
20+
For code coverage, set the environment variable `NODE_V8_COVERAGE` to the path
21+
(relative to the working directory) where coverage metrics should be output.
22+
These can be processed with the [`c8`](https://github.com/bcoe/c8) tool. NOTE:
23+
as of Node 18.7 there is a memory leak that makes it impossible to run the
24+
entire suite with NODE_V8_COVERAGE, so for code coverage tests you should run it
25+
in chunks.
26+
27+
## Example Usage
28+
29+
```js
30+
import runTest262 from 'temporal-test262-runner';
31+
32+
const result = runTest262({
33+
test262Dir: 'test262',
34+
polyfillCodeFile: 'dist/script.js',
35+
expectedFailureFiles: ['test/expected-failures.txt'],
36+
testGlobs: process.argv.slice(2)
37+
});
38+
39+
// if result is `true`, all tests succeeded
40+
process.exit(result ? 0 : 1);
41+
```
42+
43+
## Options
44+
45+
* `polyfillCodeFile: string` - Filename of the Temporal polyfill. Must
46+
be a single ECMAScript file that contains the Temporal object injected into
47+
the global namespace, as well as Temporal-related changes polyfilled into
48+
`Intl` and `Date` built-in objects.
49+
* `test262Dir: string` - Root directory of the test262 submodule repo.
50+
* `testGlobs?: string[]` - If omitted, all tests will be run. This option
51+
provides glob patterns that specify a subset of tests to be run. Example:
52+
`[ 'PlainDateTime/**', 'prototype/with/*.js' ]` Globs are resolved relative
53+
to `test/**∕Temporal/` subdirectories of `test262Dir`. If a pattern doesn't
54+
match any files relative to `test/**∕Temporal/`, it will also try to match
55+
relative to the current working directory, so that tab completion works.
56+
* `expectedFailureFiles?: string[]` Optional array of text filenames
57+
that each contain a list of test files (relative to the `test` subdirectory
58+
of `test262Dir`) that are expected to fail. Lines starting with `#` and
59+
blank lines are ignored. Lines from multiple files will be concatenated and
60+
de-duped. Example:
61+
```
62+
# https://github.com/tc39/test262/pull/3548
63+
built-ins/Temporal/Duration/compare/argument-string-negative-fractional-units.js
64+
built-ins/Temporal/Duration/from/argument-string-negative-fractional-units.js
65+
```

0 commit comments

Comments
 (0)