summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-04-05 13:15:57 +0200
committerGitHub <noreply@github.com>2023-04-05 13:15:57 +0200
commitdb39855fcb9e90131432d1c03bd5c16263addb3e (patch)
tree09cd26c1c2fcee6ceb7a9872abca545a0110c651 /cli/tests
parent686fe477496cf6eee398eb8ac195692528d3f427 (diff)
tests: cleanup "node_compat_tests" (#18594)
A few drive-by cleanup while I'm working on the "crypto" module. It makes it easier and faster to debug the failing test case.
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/node_compat_tests.rs6
-rw-r--r--cli/tests/node_compat/import_map.json5
-rw-r--r--cli/tests/node_compat/test.ts61
3 files changed, 36 insertions, 36 deletions
diff --git a/cli/tests/integration/node_compat_tests.rs b/cli/tests/integration/node_compat_tests.rs
index 7617b7037..b5fd7b1b3 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 ccdef1e00..000000000
--- 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 4ab703576..896b88bcf 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 -- <test-names>
-// Use the test-names as filters
+// Use the <test-names> 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<void> {
"--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<void> {
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<void> {
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.