Skip to content

Commit

Permalink
add Hermes compat tests runner
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jul 3, 2022
1 parent ac364f5 commit 8609355
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Changelog
##### Unreleased
- Nothing
- Added compat data for Hermes

##### [3.23.3 - 2022.06.26](https://github.com/zloirock/core-js/releases/tag/v3.23.3)
- Changed the order of operations in `%TypedArray%.prototype.toSpliced` following [proposal-change-array-by-copy/89](https://github.com/tc39/proposal-change-array-by-copy/issues/89)
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ For updating `core-js-compat` data:
- If you want to add new data for NodeJS, run `npm run compat-node` with the installed required NodeJS version and you will see the results in the console. Use `npm run compat-node-json` if you want to get the result as JSON.
- If you want to add new data for Deno, run `npm run compat-deno` with the installed required Deno version and you will see the results in the console. Use `npm run compat-deno-json` if you want to get the result as JSON.
- If you want to add new data for Rhino, set the required Rhino version in `compat-rhino-prepare` NPM script in [`package.json`](./package.json), run `npm run compat-rhino` and you will see the results in the console.
- If you want to add new data for Hermes, run `npm run compat-hermes -- YOR_PATH_TO_HERMES` and you will see the results in the console.
- After getting this data, add it to [`packages/core-js-compat/src/data.mjs`](./packages/core-js-compat/src/data.mjs).
- If you want to add new mapping (for example, to add a new iOS Safari version based on Safari or NodeJS based on Chrome), add it to [`packages/core-js-compat/src/mapping.mjs`](./packages/core-js-compat/src/mapping.mjs).

Expand All @@ -37,6 +38,7 @@ engine | mandatory check | how to run tests | base data inherits from
`edge` | features | browser runner | `ie` (<=18), `chrome` (>=74) |
`electron` | | browser runner | `chrome` | required
`firefox` | features | browser runner | |
`hermes` | features | hermes runner | |
`ie` | features | browser runner | |
`ios` | | browser runner | `safari` | required
`node` | non-ES features | node runner | `chrome` (only ES) | required
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"compat-node-json": "node tests/compat/node-runner --mode=JSON",
"compat-deno": "deno run --allow-read tests/compat/deno-runner.mjs",
"compat-deno-json": "deno run --allow-read tests/compat/deno-runner.mjs --mode=JSON",
"compat-hermes": "zx tests/compat/hermes-adapter.mjs",
"compat-rhino": "run-s compat-rhino-prepare compat-rhino-run",
"compat-rhino-prepare": "zx tests/compat/rhino-prepare.mjs --version=1.7.14",
"compat-rhino-run": "java -jar tests/compat/rhino.jar -version 200 -require tests/compat/rhino-runner.js",
Expand Down
1 change: 1 addition & 0 deletions packages/core-js-compat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ console.log(targets);
edge: '13', // Edge version
electron: '5.0', // Electron framework version
firefox: '15', // Firefox version
hermes: '0.11', // Hermes version
ie: '8', // Internet Explorer version
ios: '13.0', // iOS Safari version
node: 'current', // NodeJS version, you could use 'current' for set it to currently used
Expand Down
1 change: 1 addition & 0 deletions packages/core-js-compat/targets-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const validTargets = new Set([
'edge',
'electron',
'firefox',
'hermes',
'ie',
'ios',
'node',
Expand Down
1 change: 1 addition & 0 deletions tests/compat/browsers-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var engines = [
'edge',
'electron',
'firefox',
'hermes',
'ie',
'ios',
'node',
Expand Down
3 changes: 3 additions & 0 deletions tests/compat/hermes-adapter.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const [HERMES_PATH] = argv._;

await $`${ HERMES_PATH } -w -commonjs ./tests/compat`;
7 changes: 7 additions & 0 deletions tests/compat/hermes-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require('./tests.js');
require('./compat-data.js');
require('./common-runner.js');

/* global showResults -- safe */
/* eslint-disable-next-line no-restricted-globals -- output */
showResults('hermes', print);
10 changes: 10 additions & 0 deletions tests/compat/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"segments": {
"0": [
"./hermes-runner.js",
"./tests.js",
"./compat-data.js",
"./common-runner.js"
]
}
}
2 changes: 1 addition & 1 deletion tests/compat/rhino-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ require('./tests');
require('./compat-data');
require('./common-runner');

/* eslint-disable no-restricted-globals -- output */
/* eslint-disable-next-line no-restricted-globals -- output */
global.showResults('rhino', print);

0 comments on commit 8609355

Please sign in to comment.