diff options
author | haturau <135221985+haturatu@users.noreply.github.com> | 2024-10-13 10:44:12 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-13 10:44:12 +0900 |
commit | cedfd657a6a2f04d841db2b3fc3d7694de95eada (patch) | |
tree | 0d5d1c95cfd35bc46c230ea71f4dbf23aa0aaeea /tests | |
parent | 4da77059dfd5b8d7591aa8e3b9f04386fbdce221 (diff) | |
parent | 64c304a45265705832ebb4ab4e9ef19f899ac911 (diff) |
Merge branch 'denoland:main' into main
Diffstat (limited to 'tests')
17 files changed, 64 insertions, 65 deletions
diff --git a/tests/registry/npm/@denotest/better-say-hello/1.0.0/say-hello.js b/tests/registry/npm/@denotest/better-say-hello/1.0.0/say-hello.js index 0b8d63cf4..5243d4902 100644 --- a/tests/registry/npm/@denotest/better-say-hello/1.0.0/say-hello.js +++ b/tests/registry/npm/@denotest/better-say-hello/1.0.0/say-hello.js @@ -1,2 +1,2 @@ import { sayBetterHello } from "./index.js"; -sayBetterHello();
\ No newline at end of file +sayBetterHello(); diff --git a/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/index.js b/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/index.js index 4eb9b107a..242fe92f5 100644 --- a/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/index.js +++ b/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/index.js @@ -1,5 +1,3 @@ -modules.export = { +module.exports = { value: 42 }; - -console.log('index.js', modules.export.value);
\ No newline at end of file diff --git a/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/package.json b/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/package.json index 3c6fa005f..085ab6414 100644 --- a/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/package.json +++ b/tests/registry/npm/@denotest/node-lifecycle-scripts/1.0.0/package.json @@ -6,6 +6,7 @@ "install": "echo install && cli-esm 'hello from install script'", "postinstall": "echo postinstall && npx cowsay postinstall" }, + "exports": "./index.js", "dependencies": { "@denotest/bin": "1.0.0" } diff --git a/tests/registry/npm/@denotest/say-hello/1.0.0/say-hello.js b/tests/registry/npm/@denotest/say-hello/1.0.0/say-hello.js index 8751b8e47..66d02cde5 100644 --- a/tests/registry/npm/@denotest/say-hello/1.0.0/say-hello.js +++ b/tests/registry/npm/@denotest/say-hello/1.0.0/say-hello.js @@ -1,2 +1,5 @@ import { sayHello } from "./index.js"; -console.log(sayHello());
\ No newline at end of file +console.log(sayHello()); +import path from "node:path"; +import fs from "node:fs"; +fs.writeSync(fs.openSync(path.join(process.env.INIT_CWD, "say-hello-output.txt"), "w"), sayHello()); diff --git a/tests/specs/install/install_entrypoint/lifecycle.out b/tests/specs/install/install_entrypoint/lifecycle.out index 8eae8ee12..2fd279875 100644 --- a/tests/specs/install/install_entrypoint/lifecycle.out +++ b/tests/specs/install/install_entrypoint/lifecycle.out @@ -5,18 +5,7 @@ Download http://localhost:4260/@denotest/node-lifecycle-scripts/1.0.0.tgz Download http://localhost:4260/@denotest/bin/1.0.0.tgz Initialize @denotest/node-lifecycle-scripts@1.0.0 Initialize @denotest/bin@1.0.0 +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'preinstall' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'install' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'postinstall' script [UNORDERED_END] -preinstall -deno preinstall.js -node preinstall.js -install -hello from install script -postinstall[WILDCARD] - _____________ -< postinstall > - ------------- - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || diff --git a/tests/specs/npm/lifecycle_scripts/__test__.jsonc b/tests/specs/npm/lifecycle_scripts/__test__.jsonc index b798b968f..589c131dd 100644 --- a/tests/specs/npm/lifecycle_scripts/__test__.jsonc +++ b/tests/specs/npm/lifecycle_scripts/__test__.jsonc @@ -5,7 +5,7 @@ "steps": [ { "args": "cache --allow-scripts=npm:@denotest/node-addon main.js", - "output": "[WILDCARD]gyp info ok \n" + "output": "[WILDCARD]Initialize @denotest/node-addon@1.0.0: running 'install' script\n" }, { "args": "run -A main.js", @@ -38,7 +38,7 @@ "steps": [ { // without running scripts (should warn) - "args": "cache all_lifecycles.js", + "args": "run all_lifecycles.js", "output": "all_lifecycles_not_run.out" }, { @@ -51,6 +51,23 @@ } ] }, + "deno_run_lifecycle_scripts": { + "steps": [ + { + // without running scripts (should warn) + "args": "run all_lifecycles.js", + "output": "all_lifecycles_not_run.out" + }, + { + // now run scripts + "args": "run --allow-scripts all_lifecycles.js", + // this test package covers running preinstall, install, and postinstall scripts + // it also exercises running bin packages (esbuild in this case), using `node` in a script + // (with and without node-only CLI flags), and using `npx` in a script + "output": "all_lifecycles_deno_run.out" + } + ] + }, "global_lifecycle_scripts": { "steps": [ { @@ -79,14 +96,12 @@ { // without running scripts (should warn) "args": "run all_lifecycles.js", - "output": "only_warns_first1.out", - "exitCode": 1 + "output": "only_warns_first1.out" }, { // without running scripts (does not warn) "args": "run all_lifecycles.js", - "output": "only_warns_first2.out", - "exitCode": 1 + "output": "only_warns_first2.out" }, { // should warn because this is an explicit install @@ -128,6 +143,13 @@ // we run the install script, we should use the correct binary (relative to the package) "args": "cache --allow-scripts conflicting_bin.js", "output": "conflicting_bin.out" + }, + { + "args": [ + "eval", + "console.log(Deno.readTextFileSync('./say-hello-output.txt'))" + ], + "output": "conflicting_bin2.out" } ] }, diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles.out b/tests/specs/npm/lifecycle_scripts/all_lifecycles.out index 956c006dd..bdbb2b08e 100644 --- a/tests/specs/npm/lifecycle_scripts/all_lifecycles.out +++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles.out @@ -1,14 +1,3 @@ -preinstall -deno preinstall.js -node preinstall.js -install -hello from install script -postinstall[WILDCARD] - _____________ -< postinstall > - ------------- - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'preinstall' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'install' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'postinstall' script diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles_deno_run.out b/tests/specs/npm/lifecycle_scripts/all_lifecycles_deno_run.out new file mode 100644 index 000000000..5f06f6214 --- /dev/null +++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles_deno_run.out @@ -0,0 +1,4 @@ +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'preinstall' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'install' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'postinstall' script +value is 42 diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out index 09324c845..cdfdeabe2 100644 --- a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out +++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out @@ -12,3 +12,4 @@ Warning The following packages contained npm lifecycle scripts (preinstall/insta ┠─ This may cause the packages to not work correctly. ┖─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: deno install --allow-scripts=npm:@denotest/node-lifecycle-scripts@1.0.0 +value is 42 diff --git a/tests/specs/npm/lifecycle_scripts/conflicting_bin.out b/tests/specs/npm/lifecycle_scripts/conflicting_bin.out index c70aafdd5..bae5275dc 100644 --- a/tests/specs/npm/lifecycle_scripts/conflicting_bin.out +++ b/tests/specs/npm/lifecycle_scripts/conflicting_bin.out @@ -8,6 +8,5 @@ Download http://localhost:4260/@denotest/say-hello/1.0.0.tgz Initialize @denotest/better-say-hello@1.0.0 Initialize @denotest/say-hello-on-install@1.0.0 Initialize @denotest/say-hello@1.0.0 +Initialize @denotest/say-hello-on-install@1.0.0: running 'install' script [UNORDERED_END] -install script -@denotest/say-hello says hello! diff --git a/tests/specs/npm/lifecycle_scripts/conflicting_bin2.out b/tests/specs/npm/lifecycle_scripts/conflicting_bin2.out new file mode 100644 index 000000000..b4640b02c --- /dev/null +++ b/tests/specs/npm/lifecycle_scripts/conflicting_bin2.out @@ -0,0 +1 @@ +@denotest/say-hello says hello! diff --git a/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles.out b/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles.out index f62079d3f..bdbb2b08e 100644 --- a/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles.out +++ b/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles.out @@ -1,15 +1,3 @@ -preinstall -deno preinstall.js -node preinstall.js -install -hello from install script -postinstall -[WILDCARD] - _____________ -< postinstall > - ------------- - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'preinstall' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'install' script +Initialize @denotest/node-lifecycle-scripts@1.0.0: running 'postinstall' script diff --git a/tests/specs/npm/lifecycle_scripts/no_deno_json.out b/tests/specs/npm/lifecycle_scripts/no_deno_json.out index 38a461449..8509d8f9f 100644 --- a/tests/specs/npm/lifecycle_scripts/no_deno_json.out +++ b/tests/specs/npm/lifecycle_scripts/no_deno_json.out @@ -5,7 +5,6 @@ Download http://localhost:4260/@denotest/lifecycle-scripts-cjs/1.0.0.tgz Download http://localhost:4260/@denotest/bin/1.0.0.tgz Initialize @denotest/lifecycle-scripts-cjs@1.0.0 Initialize @denotest/bin@1.0.0 +Initialize @denotest/lifecycle-scripts-cjs@1.0.0: running 'preinstall' script +Initialize @denotest/lifecycle-scripts-cjs@1.0.0: running 'install' script [UNORDERED_END] -preinstall -install -hello from install script diff --git a/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out b/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out index 06c856cd9..81577e6ba 100644 --- a/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out +++ b/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out @@ -2,8 +2,11 @@ Download http://localhost:4260/@denotest/node-addon-implicit-node-gyp Download http://localhost:4260/@denotest/node-addon-implicit-node-gyp/1.0.0.tgz Initialize @denotest/node-addon-implicit-node-gyp@1.0.0 +Initialize @denotest/node-addon-implicit-node-gyp@1.0.0: running 'install' script [UNORDERED_END] Warning node-gyp was used in a script, but was not listed as a dependency. Either add it as a dependency or install it globally (e.g. `npm install -g node-gyp`) -[WILDCARD] error: script 'install' in '@denotest/node-addon-implicit-node-gyp@1.0.0' failed with exit code 1 +stderr: +Error launching 'node-gyp': [WILDCARD] + error: failed to run scripts for packages: @denotest/node-addon-implicit-node-gyp@1.0.0 diff --git a/tests/specs/npm/lifecycle_scripts/only_warns_first1.out b/tests/specs/npm/lifecycle_scripts/only_warns_first1.out index 947777b5b..cdfdeabe2 100644 --- a/tests/specs/npm/lifecycle_scripts/only_warns_first1.out +++ b/tests/specs/npm/lifecycle_scripts/only_warns_first1.out @@ -12,5 +12,4 @@ Warning The following packages contained npm lifecycle scripts (preinstall/insta ┠─ This may cause the packages to not work correctly. ┖─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: deno install --allow-scripts=npm:@denotest/node-lifecycle-scripts@1.0.0 -error: Uncaught SyntaxError: The requested module 'npm:@denotest/node-lifecycle-scripts' does not provide an export named 'value' -[WILDCARD] +value is 42 diff --git a/tests/specs/npm/lifecycle_scripts/only_warns_first2.out b/tests/specs/npm/lifecycle_scripts/only_warns_first2.out index f6a02c727..9e7806159 100644 --- a/tests/specs/npm/lifecycle_scripts/only_warns_first2.out +++ b/tests/specs/npm/lifecycle_scripts/only_warns_first2.out @@ -1,3 +1 @@ -[# note no warning] -error: Uncaught SyntaxError: The requested module 'npm:@denotest/node-lifecycle-scripts' does not provide an export named 'value' -[WILDCARD] +value is 42 diff --git a/tests/unit_node/util_test.ts b/tests/unit_node/util_test.ts index edd500262..a47c231a1 100644 --- a/tests/unit_node/util_test.ts +++ b/tests/unit_node/util_test.ts @@ -348,3 +348,8 @@ Deno.test("[util] aborted()", async () => { await promise; assertEquals(done, true); }); + +Deno.test("[util] styleText()", () => { + const redText = util.styleText("red", "error"); + assertEquals(redText, "\x1B[31merror\x1B[39m"); +}); |