Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(ses): Hermes compile and runtime #1

Merged
merged 34 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a5b11b3
test(ses): add hermes smoke test
leotm Jul 24, 2024
8dc9141
test(ses): add hermes compiler test script
leotm Jul 24, 2024
3ed816f
test(ses): add hermes runtime test script
leotm Jul 24, 2024
b5ef4a1
test(ses): add hermes-test CI job
leotm Jul 24, 2024
126a4cc
fix(ses): format
leotm Jul 24, 2024
17ad19b
fix(ses): fix CI tar extraction
leotm Jul 24, 2024
8e0cef6
fix(ses): lint
leotm Jul 24, 2024
86bcb40
fix(ses): use wget
leotm Jul 24, 2024
b446681
fix(ses): update CI ';' to '&&'
leotm Jul 24, 2024
2e64606
refactor(ses): use Node 20 only in CI matrix
leotm Jul 25, 2024
32f32d9
refactor(ses): remove dupe CI node ver step
leotm Jul 25, 2024
4392c6e
fix(ses): Hermes CI tar file extract step
leotm Jul 25, 2024
6731802
fix(ses): Hermes scripts not found
leotm Jul 25, 2024
4ab54d8
fix(ses): Hermes scripts CLI location
leotm Jul 25, 2024
f8135bb
fix(ses): Hermes smoke test
leotm Jul 25, 2024
1247f64
test(ses): add hermes-engine-cli (v0.12.0) as dev dep
leotm Jul 31, 2024
5d4a919
test(ses): create shellscript to run hermesc on any OS
leotm Jul 31, 2024
4fa7963
test(ses): fix Hermes smoke test resolveHook
leotm Jul 31, 2024
0def87d
test(ses): update Hermes smoke test
leotm Jul 31, 2024
4d50584
test(ses): add shellscript to setup Hermes .bin symlinks on any OS
leotm Aug 2, 2024
187face
test(ses): add hermesc.sh comment
leotm Aug 2, 2024
a883b73
test(ses): cat ses and test, use in hermesc.sh
leotm Aug 2, 2024
f5ece78
test(ses): format test
leotm Aug 2, 2024
6928908
test(ses): update test async arrow fn to non-arrow
leotm Aug 2, 2024
6457754
test(ses): update package.json hermesc script to run .sh
leotm Aug 2, 2024
84741ab
test(ses): update comment
leotm Aug 13, 2024
dcf7c62
test(ses): disable Hermes VM test
leotm Aug 13, 2024
e54b773
test(ses): pin hermes-engine-cli
leotm Aug 13, 2024
0b35178
test(ses): add script to run sh to create Hermes bin symlinks
leotm Aug 13, 2024
a10c965
test(ses): move smoke test calls below
leotm Aug 14, 2024
f71f65b
chore(ses): remove wget/extract hermes-cli-linux from CI
leotm Aug 14, 2024
999bbe5
test(ses): merge Hermes compiler and VM sh
leotm Aug 14, 2024
c77e700
chore(ses): improve Hermes test logs
leotm Aug 14, 2024
785a159
test(ses): cleanup after running Hermes tests
leotm Aug 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,56 @@ jobs:
# npm b/c Yarn 4 doesn't work in Node 12
run: cd packages/ses && npm run test:platform-compatibility

hermes-test:
name: hermes-test

# begin macro

runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
node-version: [20.x]
platform: [ubuntu-latest]

steps:
- name: Checkout
uses: actions/checkout@v3

# without this, setup-node errors on mismatched yarn versions
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Echo node version
run: node --version

- name: Install dependencies
run: yarn install --immutable

# end macro

- name: 'build'
run: yarn run build

- name: Fetch Hermes CLI for Linux tar file
run: cd packages/ses && mkdir hermes-cli-linux && cd hermes-cli-linux && wget https://github.com/facebook/hermes/releases/download/v0.12.0/hermes-cli-linux-v0.12.0.tar.gz
leotm marked this conversation as resolved.
Show resolved Hide resolved

- name: Extract Hermes CLI for Linux tar file
run: cd packages/ses/hermes-cli-linux && tar -xzvf hermes-cli-linux-v0.12.0.tar.gz
leotm marked this conversation as resolved.
Show resolved Hide resolved

- name: Run SES smoke test on Hermes JS compiler
run: cd packages/ses/hermes-cli-linux && npm run test:hermesc
# errors on async (arrow) functions and async generators

# - name: Run generated bytecode file on Hermes VM
# run: cd packages/ses/hermes-cli-linux && npm run test:hermes
# SES TypeErrors expected until resolved and hardenIntrinsics loop

viable-release:
name: viable-release

Expand Down
6 changes: 5 additions & 1 deletion packages/ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@
"prepare": "npm run clean && npm run build",
"qt": "ava",
"test": "tsd && ava",
"test:platform-compatibility": "node test/package/test.cjs"
"test:platform-compatibility": "node test/package/test.cjs",
"test:create-hermes-bin-symlinks": "./scripts/hermes-bin-symlinks.sh",
"test:hermesc": "./scripts/hermesc.sh",
"test:hermes": "cd hermes-cli-linux && ./hermes -b hermes-smoke.hbc"
},
"dependencies": {
"@endo/env-options": "^1.1.4"
Expand All @@ -91,6 +94,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"hermes-engine-cli": "0.12.0",
"prettier": "^3.2.5",
"sinon": "^15.1.0",
"terser": "^5.16.6",
Expand Down
34 changes: 34 additions & 0 deletions packages/ses/scripts/hermes-bin-symlinks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

OS="$(uname -s)"

case "$OS" in
Linux*)
OS_DIR="linux64-bin"
;;
Darwin*)
OS_DIR="osx-bin"
;;
CYGWIN*|MINGW*|MSYS*)
OS_DIR="win64-bin"
;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac

# Path from 'packages/ses'
cd ../../node_modules/.bin

if [[ "$OS" == linux* || "$OS" == Darwin* ]]; then
ln -s ../hermes-engine-cli/$OS_DIR/hbcdump hbcdump
ln -s ../hermes-engine-cli/$OS_DIR/hdb hdb
ln -s ../hermes-engine-cli/$OS_DIR/hermes hermes
ln -s ../hermes-engine-cli/$OS_DIR/hermesc hermesc
elif [[ "$OS" == CYGWIN* || "$OS" == MINGW* || "$OS" == MSYS* ]]; then
mklink -s ../hermes-engine-cli/$OS_DIR/hbcdump.exe hbcdump
mklink -s ../hermes-engine-cli/$OS_DIR/hdb.exe hdb
mklink -s ../hermes-engine-cli/$OS_DIR/hermes.exe hermes
mklink -s ../hermes-engine-cli/$OS_DIR/hermesc.exe hermesc
fi
26 changes: 26 additions & 0 deletions packages/ses/scripts/hermesc.sh
leotm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

OS="$(uname -s)"

case "$OS" in
Linux*)
OS_DIR="linux64-bin"
;;
Darwin*)
OS_DIR="osx-bin"
;;
CYGWIN*|MINGW*|MSYS*)
OS_DIR="win64-bin"
;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac

# Path relative to 'packages/ses'
HERMESC="../../node_modules/hermes-engine-cli/$OS_DIR/hermesc"

cat dist/ses.cjs test/hermes-smoke.js > test/hermes-smoke-dist.js

$HERMESC -emit-binary -out test/hermes-smoke.hbc test/hermes-smoke-dist.js
53 changes: 53 additions & 0 deletions packages/ses/test/hermes-smoke.js
leotm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Hermes doesn't support native I/O,
// so we concat the SES shim above,
// when running this test on Hermes.

/**
* Test calling SES lockdown.
*/
const testLockdown = () => {
lockdown();
};

testLockdown();

/**
* TODO: Test creating a new Compartment.
*/
// eslint-disable-next-line no-unused-vars
const testCompartment = () => {
// eslint-disable-next-line no-unused-vars
const c = new Compartment();
};

// testCompartment();

/**
* TODO: Test Compartment import hook and resolve hook.
*/
// eslint-disable-next-line no-unused-vars
async function testCompartmentHooks() {
const resolveHook = a => a;

async function importHook() {
return {
imports: [],
exports: ['meaning'],
execute(exports) {
exports.meaning = 42;
},
};
}

const compartment = new Compartment({}, {}, { resolveHook, importHook });

const module = compartment.module('.');

const {
namespace: { _meaning },
} = await compartment.import('.');

assert(module);
}

// testCompartmentHooks();
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6606,6 +6606,13 @@ __metadata:
languageName: node
linkType: hard

"hermes-engine-cli@npm:0.12.0":
version: 0.12.0
resolution: "hermes-engine-cli@npm:0.12.0"
checksum: 10c0/53a00336632cc7a743e9a88a5199865cf922d118f42f15bed4d2ed2fee635acd0d4d8563803b47e7c1bc2d17650281eb9188be8cfdaa25887243cfee840523be
languageName: node
linkType: hard

"hosted-git-info@npm:^2.1.4":
version: 2.8.9
resolution: "hosted-git-info@npm:2.8.9"
Expand Down Expand Up @@ -10523,6 +10530,7 @@ __metadata:
eslint-config-prettier: "npm:^9.1.0"
eslint-plugin-eslint-comments: "npm:^3.2.0"
eslint-plugin-import: "npm:^2.29.1"
hermes-engine-cli: "npm:0.12.0"
prettier: "npm:^3.2.5"
sinon: "npm:^15.1.0"
terser: "npm:^5.16.6"
Expand Down
Loading