diff --git a/cli/tests/integration/node_compat_tests.rs b/cli/tests/integration/node_compat_tests.rs index 7617b70379..b5fd7b1b39 100644 --- a/cli/tests/integration/node_compat_tests.rs +++ b/cli/tests/integration/node_compat_tests.rs @@ -8,12 +8,6 @@ fn node_compat_tests() { .current_dir(util::root_path()) .arg("test") .arg("--unstable") - .arg("--import-map") - .arg( - util::tests_path() - .join("node_compat") - .join("import_map.json"), - ) .arg("-A") .arg(util::tests_path().join("node_compat")) .spawn() diff --git a/cli/tests/node_compat/import_map.json b/cli/tests/node_compat/import_map.json deleted file mode 100644 index ccdef1e007..0000000000 --- a/cli/tests/node_compat/import_map.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "imports": { - "std/": "../../../test_util/std/" - } -} diff --git a/cli/tests/node_compat/test.ts b/cli/tests/node_compat/test.ts index 4ab7035765..896b88bcf9 100644 --- a/cli/tests/node_compat/test.ts +++ b/cli/tests/node_compat/test.ts @@ -1,8 +1,22 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { magenta } from "std/fmt/colors.ts"; -import { pooledMap } from "std/async/pool.ts"; -import { dirname, fromFileUrl, join } from "std/path/mod.ts"; -import { fail } from "std/testing/asserts.ts"; + +/** + * This script will run the test files specified in the configuration file. + * + * Each test file will be run independently (in a separate process as this is + * what Node.js is doing) and we wait until it completes. If the process reports + * an abnormal code, the test is reported and the test suite will fail + * immediately. + * + * Some tests check for presence of certain `process.exitCode`. + * Some tests depends on directories/files created by other tests - they must + * all share the same working directory. + */ + +import { magenta } from "../../../test_util/std/fmt/colors.ts"; +import { pooledMap } from "../../../test_util/std/async/pool.ts"; +import { dirname, fromFileUrl, join } from "../../../test_util/std/path/mod.ts"; +import { fail } from "../../../test_util/std/testing/asserts.ts"; import { config, getPathsFromTestSuites, @@ -11,24 +25,14 @@ import { // If the test case is invoked like // deno test -A cli/tests/node_compat/test.ts -- -// Use the test-names as filters +// Use the as filters const filters = Deno.args; const hasFilters = filters.length > 0; - -/** - * This script will run the test files specified in the configuration file - * - * Each test file will be run independently and wait until completion, if an abnormal - * code for the test is reported, the test suite will fail immediately - */ - const toolsPath = dirname(fromFileUrl(import.meta.url)); -const stdRootUrl = new URL("../../", import.meta.url).href; const testPaths = partitionParallelTestPaths( getPathsFromTestSuites(config.tests), ); const cwd = new URL(".", import.meta.url); -const importMap = "import_map.json"; const windowsIgnorePaths = new Set( getPathsFromTestSuites(config.windowsIgnore), ); @@ -74,7 +78,7 @@ async function runTest(t: Deno.TestContext, path: string): Promise { "--unstable", //"--unsafely-ignore-certificate-errors", "--v8-flags=" + v8Flags.join(), - testCase.endsWith(".mjs") ? "--import-map=" + importMap : "runner.ts", + "runner.ts", testCase, ]; @@ -83,7 +87,6 @@ async function runTest(t: Deno.TestContext, path: string): Promise { const command = new Deno.Command(Deno.execPath(), { args, env: { - DENO_NODE_COMPAT_URL: stdRootUrl, TEST_SERIAL_ID: String(testSerialId++), }, cwd, @@ -93,15 +96,23 @@ async function runTest(t: Deno.TestContext, path: string): Promise { if (code !== 0) { // If the test case failed, show the stdout, stderr, and instruction // for repeating the single test case. - if (stdout.length) console.log(decoder.decode(stdout)); - console.log(`Error: "${path}" failed`); - console.log( - "You can repeat only this test with the command:", - magenta( - `./target/debug/deno test -A --import-map cli/tests/node_compat/import_map.json cli/tests/node_compat/test.ts -- ${path}`, - ), + if (stdout.length) { + console.log(decoder.decode(stdout)); + } + const stderrOutput = decoder.decode(stderr); + const repeatCmd = magenta( + `./target/debug/deno test -A cli/tests/node_compat/test.ts -- ${path}`, ); - fail(decoder.decode(stderr)); + const msg = `"${magenta(path)}" failed: + +${stderrOutput} + +You can repeat only this test with the command: + + ${repeatCmd} +`; + console.log(msg); + fail(msg); } else if (hasFilters) { // Even if the test case is successful, shows the stdout and stderr // when test case filtering is specified. diff --git a/ext/node/polyfills/README.md b/ext/node/polyfills/README.md index ddad19dd68..11de64bd99 100644 --- a/ext/node/polyfills/README.md +++ b/ext/node/polyfills/README.md @@ -169,25 +169,6 @@ to pass certain tests. However, avoid doing such manual changes to the test files, since that may cover up inconsistencies between the node library and actual node behavior. -### Working with child processes ? Use `DENO_NODE_COMPAT_URL` - -When working with `child_process` modules, you will have to run tests pulled -from Node.js. These tests usually spawn deno child processes via the use of -`process.execPath`. The `deno` executable will use its own embedded version of -std modules, then you may get the impression your code is not really working as -it should. - -To prevent this, set `DENO_NODE_COMPAT_URL` with the absolute path to your -`deno_std` repo, ending with a trailing slash: - -``` -export DENO_NODE_COMPAT_URL=$PWD/ -# or -export DENO_NODE_COMPAT_URL=file:///path/to/deno_std/dir/ -``` - -Then, `deno` will use your local copy of `deno_std` instead of latest version. - ### Best practices When converting from promise-based to callback-based APIs, the most obvious way