Skip to content

Commit

Permalink
refactor(test262-runner): Pivot to test262-harness for XS parity chec…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
kriskowal committed Feb 14, 2024
1 parent 14c5643 commit f4368ee
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 14 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
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
46 changes: 35 additions & 11 deletions packages/test262-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,48 @@
"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": [
Expand Down
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;
});
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';
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*---
description:
includes: [propertyHelper.js]
features: [Symbol.toStringTag,Compartment,lockdown,ses-xs-parity]
---*/

lockdown();

assert.sameValue(Compartment.prototype[Symbol.toStringTag], 'Compartment');

verifyNotEnumerable(Compartment.prototype, Symbol.toStringTag);
verifyNotWritable(Compartment.prototype, Symbol.toStringTag);
verifyNotConfigurable(Compartment.prototype, Symbol.toStringTag);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*---
description:
includes: [propertyHelper.js]
features: [Symbol.toStringTag,Compartment]
features: [Symbol.toStringTag,Compartment,ses-xs-parity]
---*/

assert.sameValue(Compartment.prototype[Symbol.toStringTag], 'Compartment');
Expand Down
12 changes: 12 additions & 0 deletions packages/test262-runner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.eslint-base.json",
"compilerOptions": {
"allowJs": true
},
"include": [
"*.js",
"*.ts",
"src/**/*.js",
"src/**/*.ts"
]
}

0 comments on commit f4368ee

Please sign in to comment.