-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
279 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# Creates a JS smoke test to be compiled into Hermes bytecode (hbc). | ||
# | ||
# Usage: scripts/hermes-test.sh | ||
|
||
set -ueo pipefail | ||
|
||
DIR=$(dirname -- "${BASH_SOURCE[0]}") | ||
cd "$DIR/.." | ||
|
||
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 | ||
|
||
HERMESC="../../node_modules/hermes-engine-cli/$OS_DIR/hermesc" | ||
HERMES="../../node_modules/hermes-engine-cli/$OS_DIR/hermes" | ||
|
||
echo "Concatenating: dist/ses-hermes.cjs + test/_hermes-smoke.js" | ||
cat dist/ses-hermes.cjs test/_hermes-smoke.js > test/_hermes-smoke-dist.js | ||
echo "Generated: test/_hermes-smoke-dist.js" | ||
|
||
# Errors on async arrow functions and async generators | ||
# Both are unsupported on Hermes | ||
echo "Executing: test/_hermes-smoke-dist.js on Hermes compiler" | ||
$HERMESC test/_hermes-smoke-dist.js -emit-binary -out test/_hermes-smoke-dist.hbc | ||
echo "Generated: test/_hermes-smoke-dist.hbc" | ||
echo "Hermes compiler done" | ||
|
||
# TODO: Disabled until https://github.com/endojs/endo/issues/1891 complete | ||
# echo "Executing generated bytecode file on Hermes VM" | ||
# $HERMES -b test/_hermes-smoke-dist.hbc | ||
# echo "Hermes VM done" | ||
echo "Skipping: Hermes VM" | ||
|
||
echo "Hermes tests complete" | ||
|
||
echo "Removing: test/_hermes-smoke-dist.js" | ||
rm test/_hermes-smoke-dist.js | ||
echo "Removing: test/_hermes-smoke-dist.hbc" | ||
rm test/_hermes-smoke-dist.hbc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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(); | ||
}; | ||
|
||
/** | ||
* 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(); | ||
}; | ||
|
||
/** | ||
* 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); | ||
} | ||
|
||
testLockdown(); |
Oops, something went wrong.