summaryrefslogtreecommitdiff
path: root/test/parallel/test-cli-eval.js
AgeCommit message (Collapse)Author
2019-12-06module: fix dynamic import from evalCorey Farrell
This allows dynamic import to work from CLI `--eval` with or without `--input-type=module`. Fixes: https://github.com/nodejs/node/issues/30591 PR-URL: https://github.com/nodejs/node/pull/30624 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
2019-11-12esm: unflag --experimental-modulesGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/29866 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-06-30esm: ensure cwd-relative imports for module --evalGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/28389 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-17test: add eval ESM module testsEvgenii Shchepotev
PR-URL: https://github.com/nodejs/node/pull/27956 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-03-07test: fix tests so they work in worker threadsRichard Lau
Use the `cwd` option for child_process instead of `process.chdir()` to allow tests to work with worker threads. PR-URL: https://github.com/nodejs/node/pull/26453 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-06-06test,tools: enable running tests under workersAnna Henningsen
Enable running tests inside workers by passing `--worker` to `tools/test.py`. A number of tests are marked as skipped, or have been slightly altered to fit the different environment. PR-URL: https://github.com/nodejs/node/pull/20876 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2017-10-13test: escape script filename on WindowsBartosz Sosnowski
Escape backslashes in script filename on Windows in a CLI test. PR-URL: https://github.com/nodejs/node/pull/16124 Fixes: https://github.com/nodejs/node/issues/16057 and #16023 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-08-07test: begin normalizing fixtures useJames M Snell
Adds a new `../common/fixtures' module to begin normalizing `test/fixtures` use. Our test code is a bit inconsistent with regards to use of the fixtures directory. Some code uses `path.join()`, some code uses string concats, some other code uses template strings, etc. In mnay cases, significant duplication of code is seen when accessing fixture files, etc. This updates many (but by no means all) of the tests in the test suite to use the new consistent API. There are still many more to update, which would make an excelent Code-n-Learn exercise. PR-URL: https://github.com/nodejs/node/pull/14332 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-05-14test: make the rest of tests path-independentVse Mozhet Byt
Permit spaces in paths to a Node.js executable and test scripts. PR-URL: https://github.com/nodejs/node/pull/12972 Fixes: https://github.com/nodejs/node/issues/12773 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-05-05test: reduce string concatenationsVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/12735 Refs: https://github.com/nodejs/node/pull/12455 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-05-05test: make tests cwd-independentVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/12812 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-03-24lib: fix event race condition with -eBen Noordhuis
Commit c5b07d4 ("lib: fix beforeExit not working with -e") runs the to-be-evaluated code at a later time than before because it switches from `process.nextTick()` to `setImmediate()`. It affects `-e 'process.on("message", ...)'` because there is now a larger time gap between startup and attaching the event listener, increasing the chances of missing early messages. I'm reasonably sure `process.nextTick()` was also susceptible to that, only less pronounced. Avoid the problem altogether by evaluating the code synchronously. Harmonizes the logic with `Module.runMain()` from lib/module.js which also calls `process._tickCallback()` afterwards. PR-URL: https://github.com/nodejs/node/pull/11958 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
2017-03-17test: add coverage for child_process bounds checkRich Trott
Make sure that monkey-patching process.execArgv doesn't cause child_process to incorrectly munge execArgv in fork(). This basically is adding coverage for an `index > 0` check (see Refs). Previously, that condition was never false in any of the tests. PR-URL: https://github.com/nodejs/node/pull/11800 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
2017-03-10meta: restore original copyright headerJames M Snell
A prior io.js era commit inappropriately removed the original copyright statements from the source. This restores those in any files still remaining from that edit. Ref: https://github.com/nodejs/TSC/issues/174 Ref: https://github.com/nodejs/node/pull/10599 PR-URL: https://github.com/nodejs/node/pull/10155 Note: This PR was required, reviewed-by and approved by the Node.js Foundation Legal Committee and the TSC. There is no `Approved-By:` meta data.
2017-01-25src: support "--" after "-e" as end-of-optionsJohn Barboza
When the double dash "--" appears after "-e <script>" on the command line, it indicates the end of options and the beginning of positional parameters for the script. PR-URL: https://github.com/nodejs/node/pull/10651 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-01-23test: refactor test-cli-eval.jscjihrig
PR-URL: https://github.com/nodejs/node/pull/10898 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-01-17test: fix broken assertioncjihrig
This commit fixes a broken assertion in test-cli-eval.js. PR-URL: https://github.com/nodejs/node/pull/10840 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-01-16test: refactor test-cli-eval.jsSumit Goel
* assert unused vars in test-cli-eval.js * assert in more idiomatic way test-cli-eval * rename status to err in test-cli-eval.js PR-URL: https://github.com/nodejs/node/pull/10759 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-01-11test: use eslint to fix var->const/letGibson Fahnestock
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
2017-01-06benchmark,lib,test: adjust for lintingRich Trott
Formatting changes for upcoming linter update. PR-URL: https://github.com/nodejs/node/pull/10561 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2016-12-05test: use assert.strictEqual in test-cli-evalNigel Kibodeaux
PR-URL: https://github.com/nodejs/node/pull/9919 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-10-24lib: fix beforeExit not working with -eBen Noordhuis
Commit 93a44d5 ("src: fix deferred events not working with -e") defers evaluation of the script to the next tick. A side effect of that change is that 'beforeExit' listeners run before the actual script. 'beforeExit' is emitted when the event loop is empty but process.nextTick() does not ref the event loop. Fix that by using setImmediate(). Because it is implemented in terms of a uv_check_t handle, it interacts with the event loop properly. Fixes: https://github.com/nodejs/node/issues/8534 PR-URL: https://github.com/nodejs/node/pull/8821 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-06-20src: fix Windows segfault with `--eval`Bryce Simonds
When specifing a parameter that requries an additional argument on the command line, node would segfault. This appears to be specific to Windows, adjusted command line argument parsing to hold a nullptr terminal. Adding unit test for crash on missing arguments. PR-URL: https://github.com/nodejs/node/pull/6938 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-04-18node: make builtin libs available for `--eval`Anna Henningsen
Make the builtin libraries available for the `--eval` and `--print` CLI options, using the same mechanism that the REPL uses. This renders workarounds like `node -e 'require("fs").doStuff()'` unnecessary. As part of this, the list of builtin modules and the code for adding the corresponding properties to the target context is moved to `internal/module.js`, and the previously missing `repl` entry is added. PR-URL: https://github.com/nodejs/node/pull/6207 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-01-13test: fix style issues after eslint updateMichaël Zasso
Replace var keyword with const or let. PR-URL: https://github.com/nodejs/io.js/pull/2286 Reviewed-By: Roman Reiss <me@silverwind.io>
2015-10-29child_process: don't fork bomb ourselves from -eBen Noordhuis
Remove the `-e` argument from process.execArgv in child_process.fork() to keep `node -e 'require("child_process").fork("empty.js")'` from spawning itself recursively. Fixes: https://github.com/nodejs/node/issues/3574 PR-URL: https://github.com/nodejs/node/pull/3575 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2015-05-19test: enable linting for testsRoman Reiss
Enable linting for the test directory. A number of changes was made so all tests conform the current rules used by lib and src directories. The only exception for tests is that unreachable (dead) code is allowed. test-fs-non-number-arguments-throw had to be excluded from the changes because of a weird issue on Windows CI. PR-URL: https://github.com/nodejs/io.js/pull/1721 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-22test: common.js -> commonBrendan Ashworth
This commit changes many test styles to change all references from require('./common.js'); to require('./common');. The latter is much more common, with the former only being used in 50 tests. It is just a stylistic change, and it seems that `common.js` was introduced by a rogue test and copied and pasted into the rest. Semver: patch PR-URL: https://github.com/iojs/io.js/pull/917 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12Remove excessive copyright/license boilerplateisaacs
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
2014-12-17test: split test in parallel/sequentialFedor Indutny
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/iojs/io.js/pull/172 Fix: iojs/io.js#139