bterlson / eshost-cli Goto Github PK
View Code? Open in Web Editor NEWRun ECMAScript code uniformly across any ECMAScript host
Run ECMAScript code uniformly across any ECMAScript host
d8 -e
treats its argument as if it's a script to execute. Although eshost -e
is more convenient for a lot of things by evaluating and printing the expression, it would also be nice to have a lightweight way to run statements without writing them in a file
Hi everyone,
A few days ago, I discovered this tool to help us on differential testing across engines.
I executed eshost
with a code that throws a Fatal error and the output is nothing.
To explain I removed the icudtl.dat from V8 directory and use a test that call Date methods.
#### Chakra, SpiderMonkey, V8
#
# Fatal error in , line 0
# Failed to create ICU date format, are ICU data files missing?
#
#
#
#FailureMessage Object: 0x7ffd9ff07310
==== C stack trace ===============================
/home/.jsvu/engines/v8/v8(+0x2f5383) [0x56124b1dc383]
/home/.jsvu/engines/v8/v8(+0x2f47fb) [0x56124b1db7fb]
/home/.jsvu/engines/v8/v8(+0x2f0928) [0x56124b1d7928]
/home/.jsvu/engines/v8/v8(+0x74b4df) [0x56124b6324df]
/home/.jsvu/engines/v8/v8(+0x88c045) [0x56124b773045]
/home/.jsvu/engines/v8/v8(+0xbb9049) [0x56124baa0049]
Received signal 4 ILL_ILLOPN 56124b1d86f2
/home/.jsvu/v8: linha 2: 12233 Instrução ilegal (imagem do núcleo gravada) "/home/.jsvu/engines/v8/v8" --natives_blob="/home/.jsvu/engines/v8/natives_blob.bin" --snapshot_blob="/home/.jsvu/engines/v8/snapshot_blob.bin" "$@"
The same occurs with core dumps
examples.
Should these engines be included when running esvu --engines=all
? Presently they do not install:
$ cat status.json
{
"selectedEngines": [
"ch",
"engine262",
"jsc",
"jsshell",
"v8",
"xs"
],
"installed": {
"ch": {
"version": "1_11_16",
"binEntries": [
"chakra"
]
},
"engine262": {
"version": "0.0.1-587a1fa64b42201eccc48280a07b36bbb4f40b7e",
"binEntries": [
"engine262"
]
},
"jsc": {
"version": "257719",
"binEntries": [
"javascriptcore",
"jsc"
]
},
"jsshell": {
"version": "74.0b9",
"binEntries": [
"sm",
"spidermonkey"
]
},
"v8": {
"version": "8.2.230",
"binEntries": [
"v8"
]
},
"xs": {
"version": "10.0.0",
"binEntries": [
"xs"
]
}
}
}
rwaldron in ~/.esvu/engines
$ ls
.
├── [drwxr-xr-x rwaldron staff 96 Mar 2 14:25] ch/
├── [drwxr-xr-x rwaldron staff 96 Mar 2 14:25] engine262/
├── [drwxr-xr-x rwaldron staff 96 Mar 2 14:25] jsc/
├── [drwxr-xr-x rwaldron staff 160 Mar 2 14:26] jsshell/
├── [drwxr-xr-x rwaldron staff 160 Mar 2 14:26] v8/
└── [drwxr-xr-x rwaldron staff 96 Mar 2 14:26] xs/
@mathiasbynens has an agenda item for the upcoming TC39 meeting, but I'm not sure that's necessary—I think we can get that started without using committee time.
Hi everyone,
any chance to add a feature that shows the complete stack output?
In some cases, I must to check if an issue violate an internal function or a test condition.
Example with eshost: $> eshost test.js
#### V8
RangeError: Offset is outside the bounds of the DataView
Example with V8 binary: $> ./v8 test.js
RangeError: Offset is outside the bounds of the DataView
at DataView.getInt8 (<anonymous>)
at test (.../test.js:6:13)
at test.js:10:6
In second example we know that it was violated a pre-condition of DataView.getInt8
.
Maybe the arg "--stack" can show to the user the stack output of each engine.
➜ eshost -itsx 'function identity(x) {return x}; print(identity(-0))'
## Source
function identity(x) {return x}; print(identity(-0))
## Source
function identity(x) {return x}; print(identity(-0))
┌─────┬───┐
│ ch │ 0 │
│ jsc │ │
│ sm │ │
│ v8 │ │
│ xs │ │
└─────┴───┘
In fact result should be -0
for all engines
> function ident(n) {return n}
< undefined
> ident(-0)
< -0
It seems that -0
coerces to String
Verified that the latest eshost is installed (3.8.0 at time of writing) and the jsvu binary is up-to-date (latest):
> eshost -ie "42"
## Source
print(42)
#### jsvu-d8
SyntaxError: Unexpected end of input
The same script runs just fine directly under the jsvu d8 binary.
>where d8
C:\Users\doilij\.jsvu\d8.cmd
>d8 -e "print(42)"
42
Is there some d8 support change that is needed in eshost-cli or eshost or both?
Since we've merged a number of features and created tests and increased test coverage, I'd like to update eshost-cli. Here's a draft of the release message:
--list
learned to sort by name (@dilijev #34)--edit
: allows modifying --args
or --tags
of a host (@dilijev #36)--unanimous, -u
: exit(0) and print nothing if all hosts agree, otherwise exit(1). (@dilijev #35, @rwaldron #37)Did I miss anything we should call out? Anything blocking?
My rough plan:
eshost /path.js
looks in the current directory for a file named path.js
, which is not the usual behavior.
pnpm i -g eshost-cli
Packages: +414
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 509, reused 509, downloaded 0, added 0, done
node_modules/.pnpm/[email protected]/node_modules/publish-please: Running preinstall script, failed in 80ms
.../node_modules/publish-please preinstall$ node lib/pre-install.js
│ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
│ !! Starting from v2.0.0 publish-please can't be installed globally. !!
│ !! Use local installation instead : 'npm install --save-dev publish-please', !!
│ !! Or use npx if you do not want to install publish-please as a dependency. !!
│ !! (learn more: https://github.com/inikulin/publish-please#readme). !!
│ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
└─ Failed in 80ms
ERROR Command failed with exit code 1.
We should be able to detect the locations of implementations through something similar to which js
, which d8
, etc. We should also probably run the --version
to make sure it is compatible before adding it. This is slightly dangerous because we could be running things that are not ECMAScript implementations.
When I npm install -g eshost
and then eshost host
I get env: node\r: No such file or directory
- it seems the file is full of Windows newline characters.
My guess is that this is breaking it on non-Windows systems - when I remove the ^M
chars, it seems to execute fine.
>eshost -is -h d8,sm,ch-dev E:\work\_curiosity_misc\out-err.js
## Source
print(42);
throw TypeError("blah");
#### d8, sm, ch-dev
42TypeError: blah
(Colors are correct, though.)
Note that table output shows them on separate lines:
eshost -its -h d8,sm,ch-dev E:\work\_curiosity_misc\out-err.js
## Source
print(42);
throw TypeError("blah");
┌────────┬─────────────────┐
│ d8 │ 42 │
│ sm │ TypeError: blah │
│ ch-dev │ │
└────────┴─────────────────┘
The current behavior is a bit opaque.
$ eshost -h fake -se true
(node:9811) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'name' of undefined
at /usr/lib/node_modules/eshost-cli/bin/eshost.js:385:17
at Array.map (<anonymous>)
at runInEachHost (/usr/lib/node_modules/eshost-cli/bin/eshost.js:383:11)
at Object.<anonymous> (/usr/lib/node_modules/eshost-cli/bin/eshost.js:318:5)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
(node:9811) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9811) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
It looks like eshost
supports modules per bterlson/eshost#61. It would be great to have this functionality available in eshost-cli
as well!
In the Install and Configure Hosts section of the README document. The "eshost --add" command cannot be used When installing eshost instead of eshost-cli with npm. So the correct installation command is "npm install -g eshost-cli"?
It appears they are ordered in the order the results come back which makes the order inconsistent between runs, but it would be easier to compare between runs at a glance if the order was consistent.
Config-order is a nice, easy way to order the hosts. Perhaps easier is alphabetical order. Obviously respect output grouping first (--coalesce
).
$ eshost host --list
┌──────────────┬─────────┬───────────────────────────────────────────────┬──────┐
│ name │ type │ path │ args │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ nashorn │ nashorn │ /usr/java/jdk1.8.0_66/bin/jjs │ │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ jsc │ jsc │ /usr/bin/jsc │ │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ node │ node │ /home/----/.nvm/versions/node/v5.4.1/bin/node │ │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ SpiderMonkey │ jsshell │ /usr/bin/js │ │
└──────────────┴─────────┴───────────────────────────────────────────────┴──────┘
$ eshost host --delete SpiderMonkey
$ eshost host --list
┌──────────────┬─────────┬───────────────────────────────────────────────┬──────┐
│ name │ type │ path │ args │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ nashorn │ nashorn │ /usr/java/jdk1.8.0_66/bin/jjs │ │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ jsc │ jsc │ /usr/bin/jsc │ │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ node │ node │ /home/----/.nvm/versions/node/v5.4.1/bin/node │ │
├──────────────┼─────────┼───────────────────────────────────────────────┼──────┤
│ SpiderMonkey │ jsshell │ /usr/bin/js │ │
└──────────────┴─────────┴───────────────────────────────────────────────┴──────┘
$
Sitting here with an empty eshost config, I feel like modifying the users config file is prone to failure. Can we add the appropriate test hooks to set the config path in Config.js instead?
It's a little weird to run the same command twice and get output in a different order.
This means delaying results from fast engines to wait for slower ones, but does not increase total runtime.
To help with automatic comparative testing between engines, add a -q|--quorum
flag. Behavior will be as follows:
0
.1
(1 + the index of the engine in the config file)
to more easily identify which engine disagreed. Perhaps -1
if more than one engine disagrees or there is a greater than 2-way split on the outputs./cc @bterlson
Would be nice if colors were configurable (right now I just pipe through cat)...
Since this commit:
[ 5632a72 ] 2017-08-23 10:52 waldron... Restore default behavior; ensure correct conditions for --unanimous
Output e.g.:
>es --tags council -its -e "42"
## Source
print(42)
## Source
print(42)
┌──────────┬────┐
│ ch-1.7.1 │ 42 │
│ d8 │ │
│ node │ │
│ node-ch │ │
│ sm │ │
└──────────┴────┘
Using default formatter, source is only shown once:
>es --tags council -is -e "42"
## Source
print(42)
#### ch-1.7.1, d8, node, node-ch, sm
42
Looks like part of the change was to restore the old behavior whereby start()
prints the source and end()
does not, but the change did not remove that block from end()
in table.js
, resulting in the double print.
Before resolving this I want to visit the design here.
As I envisioned, the design of --unanimous
would be to print absolutely nothing (including source) and exit(0) if all engines agree on the input. Useful for scripting over a large number of test cases while easily being able to see the cases that disagreed and without having to route any output to /dev/null
.
If --unanimous
is specified, we should display source from end()
and do so IFF there is NOT unanimous agreement (i.e. there is any output at all).
To preserve original behavior otherwise, print from start()
IFF --unanimous
is not specified.
(I'm not sure if this is an issue with eshost-cli or with GraalJS. If this is a Graal issue, I'm happy to move the discussion over there.)
I just tried to install GraalJS using eshost on a fresh Ubuntu 22.04 LTS box. I was able to install a few engines, but not GraalJS 21.3.3.1, the version available at the time. Here are the results:
$ npm install esvu -g
# snip successful install output
$ which esvu
/usr/local/bin/esvu
$ esvu --engines=all
esvu ❯ version 1.2.9
# snip
GraalJS ❯ Checking version...
GraalJS ❯ Installing version 21.3.3.1
GraalJS ❯ Downloading https://github.com/oracle/graaljs/releases/download/vm-21.3.3.1/graaljs-21.3.3.1-linux-amd64.tar.gz
GraalJS ❯ Extracting /tmp/esvu-ddf2ac3d55c5d5465e2a64c5ee2ee159
GraalJS ❯ Installing /tmp/esvu-ddf2ac3d55c5d5465e2a64c5ee2ee159-extracted
esvu ✖ Fatal error installing GraalJS [Error: ENOENT: no such file or directory, copyfile '/tmp/esvu-ddf2ac3d55c5d5465e2a64c5ee2ee159-extracted/graaljs-21.3.3.1-linux-amd64/lib/libjsvm.so' -> '/root/.esvu/engines/graaljs/graaljs-21.3.3.1-linux-amd64/lib/libjsvm.so'] {
errno: -2,
code: 'ENOENT',
syscall: 'copyfile',
path: '/tmp/esvu-ddf2ac3d55c5d5465e2a64c5ee2ee159-extracted/graaljs-21.3.3.1-linux-amd64/lib/libjsvm.so',
dest: '/root/.esvu/engines/graaljs/graaljs-21.3.3.1-linux-amd64/lib/libjsvm.so'
}
Somehow we're trying to install a shared library that doesn't exist. I can confirm, though, that Graal's js
binary is available, sitting uninstalled in that temprary directory:
$ ls /tmp/esvu-ddf2ac3d55c5d5465e2a64c5ee2ee159-extracted/graaljs-21.3.3.1-linux-amd64/
bin LICENSE.txt native-image.properties README.md release THIRD_PARTY_LICENSE.txt
$ /tmp/esvu-ddf2ac3d55c5d5465e2a64c5ee2ee159-extracted/graaljs-21.3.3.1-linux-amd64/bin/js
> "2" + "2" - "2"
20
Any idea what might be going on?
For chars with more than one byte, it looks like the table formatting is based on number of bytes rather than number of visible characters.
>eshost -its toLocaleDateString.js
## Source
let culture = ['zh-CN'];
print(Intl.DateTimeFormat.supportedLocalesOf(culture));
let str = new Date().toLocaleDateString(culture, { year: "numeric", month: "short", day: "numeric" });
print(str);
print(str.length);
┌──────────────┬──────────────────┐
│ d8 │ zh-CN │
│ sm │ 2017年5月17日 │
│ │ 10 │
├──────────────┼──────────────────┤
│ ch-1.4.3 │ zh-Hans-CN │
│ ch-1.3.2 │ ?2017???5??17?? │
│ ch-1.2.3 │ 15 │
│ ch-master │ │
│ ch-2.0-pre │ │
│ ch-intl-gcl │ │
│ ch-dev │ │
├──────────────┼──────────────────┤
│ node │ [] │
│ node-nightly │ May 17, 2017 │
│ │ 12 │
├──────────────┼──────────────────┤
│ node-ch │ [ 'zh-Hans-CN' ] │
│ │ 2017年5月17日 │
│ │ 15 │
└──────────────┴──────────────────┘
For d8
and sm
the line is too short because the Chinese characters have 2 bytes each.
For node-ch
the line is too short because it displays bidi markers as 0-width (you can see from the question marks under ch).
Other test cases:
eshost -its -e "'2017\u{10401}'" # surrogate pair
eshost -its -e "'2017\u{5e74}'" # 年 CJK glyph for "year"
> eshost -its -e "'2017\u{10401}'"
## Source
print('2017\u{10401}')
┌──────────────┬────────┐
│ sm │ 2017𐐁 │
│ d8 │ │
│ node-ch │ │
│ node │ │
│ node-nightly │ │
├──────────────┼────────┤
│ ch-1.4.3 │ 2017?? │
│ ch-1.3.2 │ │
│ ch-1.2.3 │ │
│ ch-2.0-pre │ │
│ ch-intl-gcl │ │
│ ch-dev │ │
│ ch-master │ │
└──────────────┴────────┘
> eshost -its -e "'2017\u{5e74}'"
## Source
print('2017\u{5e74}')
┌──────────────┬───────┐
│ d8 │ 2017年 │
│ sm │ │
│ node-ch │ │
│ node │ │
│ node-nightly │ │
├──────────────┼───────┤
│ ch-1.4.3 │ 2017? │
│ ch-1.2.3 │ │
│ ch-1.3.2 │ │
│ ch-2.0-pre │ │
│ ch-intl-gcl │ │
│ ch-master │ │
│ ch-dev │ │
└──────────────┴───────┘
eshost --configure-jsvu
Using config "C:\Users\Jack\.eshost-config.json"
Configuring jsvu host with name "ChakraCore" (type "ch") at "C:\Users\Jack\.jsvu\chakra.cmd"
Host "ChakraCore" already exists
C:\Users\Jack\AppData\Roaming\npm\node_modules\eshost-cli\lib\host-manager.js:172
] = VU_HOST_DETAILS[vu][engine];
^
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at Object.exports.configureFromVersionUpdater (C:\Users\Jack\AppData\Roaming\npm\node_modules\eshost-cli\lib\host-manager.js:172:9)
at Object.<anonymous> (C:\Users\Jack\AppData\Roaming\npm\node_modules\eshost-cli\bin\eshost.js:294:15)
Default:
>eshost --tags council -is -x "print('a'); print(123);"
## Source
print('a'); print(123);
#### ch-1.7.1, d8, sm
a
123
#### node, node-ch
a
123
Table:
>eshost --tags council -its -x "print('a'); print(123);"
## Source
print('a'); print(123);
┌──────────┬─────┐
│ ch-1.7.1 │ a │
│ d8 │ 123 │
│ node │ │
│ node-ch │ │
│ sm │ │
└──────────┴─────┘
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.