Skip to content

Commit

Permalink
feat(test262-runner): Revitalize test262 runner (merge #1847)
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal authored Feb 14, 2024
2 parents 4e5a88b + 8bc474e commit c819dca
Show file tree
Hide file tree
Showing 268 changed files with 30,538 additions and 347 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ bundles
dist
fixtures
/packages/ses-integration-test/transform-tests/output
/packages/test262-runner/prelude
test262

*.html
Expand Down
7 changes: 7 additions & 0 deletions packages/ses/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
User-visible changes in SES:

# Next release

- Exports `ses/lockdown-shim.js`, `ses/compartment-shim.js`, and
`ses/assert-shim.js` for piecemeal usage.
This change is motivated by the need to omit `ses/assert-shim.js` in Test262
environments.

# v1.1.0 (2024-01-17)

- The [iterators-helpers](https://github.com/tc39/proposal-iterator-helpers)
Expand Down
1 change: 1 addition & 0 deletions packages/ses/assert-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/assert-shim.js';
1 change: 1 addition & 0 deletions packages/ses/compartment-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/compartment-shim.js';
1 change: 1 addition & 0 deletions packages/ses/lockdown-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/lockdown-shim.js';
3 changes: 3 additions & 0 deletions packages/ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"require": "./dist/ses.cjs"
},
"./tools.js": "./tools.js",
"./assert-shim.js": "./assert-shim.js",
"./lockdown-shim.js": "./lockdown-shim.js",
"./compartment-shim.js": "./compartment-shim.js",
"./package.json": "./package.json"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/static-module-record/src/transform-analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const makeCreateStaticRecord = transformSource =>
liveVar: ${h.HIDDEN_LIVE}, \
onceVar: ${h.HIDDEN_ONCE}, \
importMeta: ${h.HIDDEN_META}, \
}) => (function () { \
}) => (function () { 'use strict'; \
${preamble} \
${scriptSource}
})()
Expand Down
1 change: 1 addition & 0 deletions packages/test262-runner/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prelude
1 change: 1 addition & 0 deletions packages/test262-runner/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prelude
12 changes: 10 additions & 2 deletions packages/test262-runner/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# test262-runner

Run ECMAScript compliance tests on `node` using native ESM support.
Run ECMAScript compliance tests on Node.js, XS, and potentially others, with a
prelude that shims Hardened JavaScript on these platforms.

## Test262 subset

The `test262` directory contains a copy of the `tests` and `harness` directories from https://github.com/tc39/test262.
The `test262` directory contains

* a copy of the `tests` and `harness` directories from https://github.com/tc39/test262.
* additional tests from https://github.com/Moddable-OpenSource/moddable
* additional Hardened JavaScript tests

We currently only run tests expressly marked with the `ses-xs-parity` feature
in their front-matter.

## Justification

Expand Down
49 changes: 35 additions & 14 deletions packages/test262-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,52 @@
"name": "@endo/test262-runner",
"version": "0.1.32",
"private": true,
"description": "Test262 Runner",
"author": "Agoric",
"description": "Hardened JavaScript Test262 Runner",
"keywords": [],
"author": "Endo contributors",
"license": "Apache-2.0",
"homepage": "https://github.com/endojs/endo/tree/master/packages/skel#readme",
"repository": {
"directory": "packages/test262-runner"
},
"bugs": {
"url": "https://github.com/endojs/endo/issues"
},
"type": "module",
"main": "./src/main.js",
"main": "./index.js",
"module": "./index.js",
"exports": {
"./package.json": "./package.json"
},
"scripts": {
"build": "exit 0",
"build": "node scripts/generate-preludes.js",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
"lint": "eslint ."
"lint:js": "eslint .",
"lint:types": "tsc",
"test": "exit 0",
"test262": "yarn build && yarn test262:xs && yarn test262:node",
"test262:xs": "test262-harness --host-type xs --host-path xst --test262-dir test262 --prelude prelude/xs.js 'test262/test/**/*.js' --features-include ses-xs-parity",
"test262:node": "test262-harness --host-type node --host-path node --test262-dir test262 --prelude prelude/node.js 'test262/test/**/*.js' --features-include ses-xs-parity"
},
"dependencies": {
"test262-parser": "^2.2.0"
"@endo/compartment-mapper": "^1.1.0",
"ses": "^1.1.0",
"test262-harness": "^10.0.0"
},
"ava": {
"files": [
"*test*/**/test-*.js"
],
"require": []
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^8.46.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-import": "^2.27.5",
"prettier": "^3.0.0",
"typescript": "~5.2.2"
},
"eslintConfig": {
"extends": [
"plugin:@endo/internal"
]
},
"repository": {
"directory": "packages/test262-runner"
}
}
36 changes: 36 additions & 0 deletions packages/test262-runner/scripts/generate-preludes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* global process */
import 'ses';
import fs from 'fs';
import { makeBundle } from '@endo/compartment-mapper/bundle.js';
import { fileURLToPath, pathToFileURL } from 'url';

const resolve = (rel, abs) => fileURLToPath(new URL(rel, abs).toString());
const root = new URL('..', import.meta.url).toString();

const read = async location => fs.promises.readFile(fileURLToPath(location));
const write = async (target, content) => {
const location = resolve(target, root);
await fs.promises.writeFile(location, content);
};

const main = async () => {
const nodePrelude = await makeBundle(
read,
pathToFileURL(
resolve('../src/node-prelude.js', import.meta.url),
).toString(),
);
const xsPrelude = await makeBundle(
read,
pathToFileURL(resolve('../src/xs-prelude.js', import.meta.url)).toString(),
);

await fs.promises.mkdir('prelude', { recursive: true });
await write('prelude/node.js', nodePrelude);
await write('prelude/xs.js', xsPrelude);
};

main().catch(err => {
console.error('Error running main:', err);
process.exitCode = 1;
});
79 changes: 0 additions & 79 deletions packages/test262-runner/src/checks.js

This file was deleted.

57 changes: 0 additions & 57 deletions packages/test262-runner/src/file.js

This file was deleted.

36 changes: 0 additions & 36 deletions packages/test262-runner/src/harness.js

This file was deleted.

32 changes: 0 additions & 32 deletions packages/test262-runner/src/main.js

This file was deleted.

2 changes: 2 additions & 0 deletions packages/test262-runner/src/node-prelude.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import 'ses/lockdown-shim.js';
import 'ses/compartment-shim.js';
Loading

0 comments on commit c819dca

Please sign in to comment.