diff --git a/.dprint.json b/.dprint.json index 64e78ae13c..ab12459e4f 100644 --- a/.dprint.json +++ b/.dprint.json @@ -45,7 +45,7 @@ "cli/tsc/*typescript.js", "gh-pages", "target", - "test_ffi/tests/test.js", + "tests/ffi/tests/test.js", "test_util/std", "test_util/wpt", "third_party", diff --git a/.gitignore b/.gitignore index eab627b387..37f568324f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,9 @@ gclient_config.py_entries /std/hash/_wasm/target /tools/wpt/manifest.json /third_party/ -/test_napi/node_modules -/test_napi/build -/test_napi/third_party_tests/node_modules +/tests/napi/node_modules +/tests/napi/build +/tests/napi/third_party_tests/node_modules # MacOS generated files .DS_Store diff --git a/Cargo.toml b/Cargo.toml index 1c9d311091..c76dd166cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,10 +28,10 @@ members = [ "ext/websocket", "ext/webstorage", "runtime", - "test_ffi", - "test_napi", "test_util", "tests", + "tests/ffi", + "tests/napi", ] exclude = ["test_util/std/hash/_wasm"] diff --git a/cli/bench/napi/bench.js b/cli/bench/napi/bench.js index d2aac63df7..c12c7aacbc 100644 --- a/cli/bench/napi/bench.js +++ b/cli/bench/napi/bench.js @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { loadTestLibrary } from "../../../test_napi/common.js"; +import { loadTestLibrary } from "../../../tests/napi/common.js"; const lib = loadTestLibrary(); diff --git a/cli/bench/napi/bench_node.mjs b/cli/bench/napi/bench_node.mjs index 2593aadd28..82e06f08fb 100644 --- a/cli/bench/napi/bench_node.mjs +++ b/cli/bench/napi/bench_node.mjs @@ -2,7 +2,7 @@ import { bench, run } from "mitata"; import { createRequire } from "module"; const require = createRequire(import.meta.url); -const lib = require("../../../test_napi.node"); +const lib = require("../../../tests/napi.node"); bench("warmup", () => {}); bench("napi_get_undefined", () => lib.test_get_undefined(0)); diff --git a/cli/napi/README.md b/cli/napi/README.md index e40d4719d7..ec637e1bd2 100644 --- a/cli/napi/README.md +++ b/cli/napi/README.md @@ -50,11 +50,11 @@ Update the generated symbol lists using the script: deno run --allow-write tools/napi/generate_symbols_lists.js ``` -Add a test in [`/test_napi`](../../test_napi/). You can also refer to Node.js +Add a test in [`/tests/napi`](../../tests/napi/). You can also refer to Node.js test suite for Node-API. ```js -// test_napi/boolean_test.js +// tests/napi/boolean_test.js import { assertEquals, loadTestLibrary } from "./common.js"; const lib = loadTestLibrary(); Deno.test("napi get boolean", function () { @@ -64,7 +64,7 @@ Deno.test("napi get boolean", function () { ``` ```rust -// test_napi/src/boolean.rs +// tests/napi/src/boolean.rs use napi_sys::Status::napi_ok; use napi_sys::ValueType::napi_boolean; @@ -96,7 +96,7 @@ pub fn init(env: napi_env, exports: napi_value) { ``` ```diff -// test_napi/src/lib.rs +// tests/napi/src/lib.rs + mod boolean; @@ -114,4 +114,4 @@ unsafe extern "C" fn napi_register_module_v1( } ``` -Run the test using `cargo test -p test_napi`. +Run the test using `cargo test -p tests/napi`. diff --git a/ext/ffi/README.md b/ext/ffi/README.md index a821a39818..f2283c919e 100644 --- a/ext/ffi/README.md +++ b/ext/ffi/README.md @@ -21,5 +21,5 @@ MacOS. To run benchmarks: ```bash -target/release/deno bench --allow-ffi --allow-read --unstable-ffi ./test_ffi/tests/bench.js +target/release/deno bench --allow-ffi --allow-read --unstable-ffi ./tests/ffi/tests/bench.js ``` diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 7bb99a5737..5eef6cf9a0 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -87,8 +87,16 @@ pub fn third_party_path() -> PathRef { root_path().join("third_party") } +pub fn ffi_tests_path() -> PathRef { + root_path().join("tests").join("ffi") +} + pub fn napi_tests_path() -> PathRef { - root_path().join("test_napi") + root_path().join("tests").join("napi") +} + +pub fn deno_config_path() -> PathRef { + root_path().join("tests").join("config").join("deno.json") } /// Test server registry url. diff --git a/tests/config/deno.json b/tests/config/deno.json index ec93111fd4..52538a8123 100644 --- a/tests/config/deno.json +++ b/tests/config/deno.json @@ -1,5 +1,6 @@ { "imports": { - "@test_util/": "../../test_util/" + "@test_util/": "../../test_util/", + "@std/": "../../test_util/std/" } } diff --git a/test_ffi/Cargo.toml b/tests/ffi/Cargo.toml similarity index 100% rename from test_ffi/Cargo.toml rename to tests/ffi/Cargo.toml diff --git a/test_ffi/README.md b/tests/ffi/README.md similarity index 100% rename from test_ffi/README.md rename to tests/ffi/README.md diff --git a/test_ffi/src/lib.rs b/tests/ffi/src/lib.rs similarity index 100% rename from test_ffi/src/lib.rs rename to tests/ffi/src/lib.rs diff --git a/test_ffi/tests/bench.js b/tests/ffi/tests/bench.js similarity index 100% rename from test_ffi/tests/bench.js rename to tests/ffi/tests/bench.js diff --git a/test_ffi/tests/event_loop_integration.ts b/tests/ffi/tests/event_loop_integration.ts similarity index 100% rename from test_ffi/tests/event_loop_integration.ts rename to tests/ffi/tests/event_loop_integration.ts diff --git a/test_ffi/tests/ffi_callback_errors.ts b/tests/ffi/tests/ffi_callback_errors.ts similarity index 100% rename from test_ffi/tests/ffi_callback_errors.ts rename to tests/ffi/tests/ffi_callback_errors.ts diff --git a/test_ffi/tests/ffi_types.ts b/tests/ffi/tests/ffi_types.ts similarity index 100% rename from test_ffi/tests/ffi_types.ts rename to tests/ffi/tests/ffi_types.ts diff --git a/test_ffi/tests/integration_tests.rs b/tests/ffi/tests/integration_tests.rs similarity index 92% rename from test_ffi/tests/integration_tests.rs rename to tests/ffi/tests/integration_tests.rs index 642fbed032..0ad95254ce 100644 --- a/test_ffi/tests/integration_tests.rs +++ b/tests/ffi/tests/integration_tests.rs @@ -3,6 +3,8 @@ use pretty_assertions::assert_eq; use std::process::Command; use test_util::deno_cmd; +use test_util::deno_config_path; +use test_util::ffi_tests_path; #[cfg(debug_assertions)] const BUILD_VARIANT: &str = "debug"; @@ -26,7 +28,11 @@ fn basic() { build(); let output = deno_cmd() + .current_dir(ffi_tests_path()) .arg("run") + .arg("--config") + .arg(deno_config_path()) + .arg("--no-lock") .arg("--allow-ffi") .arg("--allow-read") .arg("--unstable-ffi") @@ -134,7 +140,11 @@ fn symbol_types() { build(); let output = deno_cmd() + .current_dir(ffi_tests_path()) .arg("check") + .arg("--config") + .arg(deno_config_path()) + .arg("--no-lock") .arg("--unstable-ffi") .arg("--quiet") .arg("tests/ffi_types.ts") @@ -157,7 +167,11 @@ fn thread_safe_callback() { build(); let output = deno_cmd() + .current_dir(ffi_tests_path()) .arg("run") + .arg("--config") + .arg(deno_config_path()) + .arg("--no-lock") .arg("--allow-ffi") .arg("--allow-read") .arg("--unstable-ffi") @@ -191,7 +205,11 @@ fn event_loop_integration() { build(); let output = deno_cmd() + .current_dir(ffi_tests_path()) .arg("run") + .arg("--config") + .arg(deno_config_path()) + .arg("--no-lock") .arg("--allow-ffi") .arg("--allow-read") .arg("--unstable-ffi") @@ -243,7 +261,11 @@ fn ffi_callback_errors_test() { build(); let output = deno_cmd() + .current_dir(ffi_tests_path()) .arg("run") + .arg("--config") + .arg(deno_config_path()) + .arg("--no-lock") .arg("--allow-ffi") .arg("--allow-read") .arg("--unstable-ffi") diff --git a/test_ffi/tests/test.js b/tests/ffi/tests/test.js similarity index 99% rename from test_ffi/tests/test.js rename to tests/ffi/tests/test.js index 8e57cd34ba..6b8e509c0f 100644 --- a/test_ffi/tests/test.js +++ b/tests/ffi/tests/test.js @@ -10,7 +10,7 @@ import { assertInstanceOf, assertEquals, assertFalse, -} from "../../test_util/std/assert/mod.ts"; +} from "@std/assert/mod.ts"; const targetDir = Deno.execPath().replace(/[^\/\\]+$/, ""); const [libPrefix, libSuffix] = { diff --git a/test_ffi/tests/thread_safe_test.js b/tests/ffi/tests/thread_safe_test.js similarity index 100% rename from test_ffi/tests/thread_safe_test.js rename to tests/ffi/tests/thread_safe_test.js diff --git a/test_ffi/tests/thread_safe_test_worker.js b/tests/ffi/tests/thread_safe_test_worker.js similarity index 100% rename from test_ffi/tests/thread_safe_test_worker.js rename to tests/ffi/tests/thread_safe_test_worker.js diff --git a/tests/integration/js_unit_tests.rs b/tests/integration/js_unit_tests.rs index 16aebd8c4e..de7108d255 100644 --- a/tests/integration/js_unit_tests.rs +++ b/tests/integration/js_unit_tests.rs @@ -120,7 +120,7 @@ fn js_unit_test(test: String) { .current_dir(util::root_path()) .arg("test") .arg("--config") - .arg("tests/config/deno.json") + .arg(util::deno_config_path()) .arg("--no-lock") .arg("--unstable") .arg("--location=http://127.0.0.1:4545/") diff --git a/tests/integration/node_compat_tests.rs b/tests/integration/node_compat_tests.rs index d592c75a56..e2b3c219cf 100644 --- a/tests/integration/node_compat_tests.rs +++ b/tests/integration/node_compat_tests.rs @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use test_util as util; +use util::deno_config_path; use util::env_vars_for_npm_tests; #[test] @@ -9,7 +10,7 @@ fn node_compat_tests() { .current_dir(util::root_path()) .arg("test") .arg("--config") - .arg("tests/config/deno.json") + .arg(deno_config_path()) .arg("--no-lock") .arg("--unstable") .arg("-A") diff --git a/tests/integration/node_unit_tests.rs b/tests/integration/node_unit_tests.rs index c99586fa10..7c5976bf60 100644 --- a/tests/integration/node_unit_tests.rs +++ b/tests/integration/node_unit_tests.rs @@ -4,6 +4,7 @@ use std::io::BufReader; use std::time::Duration; use std::time::Instant; use test_util as util; +use util::deno_config_path; use util::env_vars_for_npm_tests; util::unit_test_factory!( @@ -97,7 +98,7 @@ fn node_unit_test(test: String) { .current_dir(util::root_path()) .arg("test") .arg("--config") - .arg("tests/config/deno.json") + .arg(deno_config_path()) .arg("--no-lock") .arg("--unstable") // TODO(kt3k): This option is required to pass tls_test.ts, diff --git a/test_napi/.gitignore b/tests/napi/.gitignore similarity index 100% rename from test_napi/.gitignore rename to tests/napi/.gitignore diff --git a/test_napi/Cargo.toml b/tests/napi/Cargo.toml similarity index 100% rename from test_napi/Cargo.toml rename to tests/napi/Cargo.toml diff --git a/test_napi/array_test.js b/tests/napi/array_test.js similarity index 100% rename from test_napi/array_test.js rename to tests/napi/array_test.js diff --git a/test_napi/arraybuffer_test.js b/tests/napi/arraybuffer_test.js similarity index 100% rename from test_napi/arraybuffer_test.js rename to tests/napi/arraybuffer_test.js diff --git a/test_napi/async_test.js b/tests/napi/async_test.js similarity index 100% rename from test_napi/async_test.js rename to tests/napi/async_test.js diff --git a/test_napi/bigint_test.js b/tests/napi/bigint_test.js similarity index 100% rename from test_napi/bigint_test.js rename to tests/napi/bigint_test.js diff --git a/test_napi/build.rs b/tests/napi/build.rs similarity index 100% rename from test_napi/build.rs rename to tests/napi/build.rs diff --git a/test_napi/callback_test.js b/tests/napi/callback_test.js similarity index 100% rename from test_napi/callback_test.js rename to tests/napi/callback_test.js diff --git a/test_napi/cleanup_hook_test.js b/tests/napi/cleanup_hook_test.js similarity index 91% rename from test_napi/cleanup_hook_test.js rename to tests/napi/cleanup_hook_test.js index f1f9161758..0d83bc5b4c 100644 --- a/test_napi/cleanup_hook_test.js +++ b/tests/napi/cleanup_hook_test.js @@ -12,6 +12,9 @@ if (import.meta.main) { const { stdout, stderr, code } = await new Deno.Command(Deno.execPath(), { args: [ "run", + "--config", + Deno.realPathSync("../config/deno.json"), + "--no-lock", "--allow-read", "--allow-run", "--allow-ffi", @@ -20,8 +23,8 @@ if (import.meta.main) { ], }).output(); - assertEquals(code, 0); assertEquals(new TextDecoder().decode(stderr), ""); + assertEquals(code, 0); const stdoutText = new TextDecoder().decode(stdout); const stdoutLines = stdoutText.split("\n"); diff --git a/test_napi/coerce_test.js b/tests/napi/coerce_test.js similarity index 100% rename from test_napi/coerce_test.js rename to tests/napi/coerce_test.js diff --git a/test_napi/common.js b/tests/napi/common.js similarity index 87% rename from test_napi/common.js rename to tests/napi/common.js index 71ac3f0bbd..3a4f253efa 100644 --- a/test_napi/common.js +++ b/tests/napi/common.js @@ -5,8 +5,8 @@ export { assertEquals, assertRejects, assertThrows, -} from "../test_util/std/assert/mod.ts"; -export { fromFileUrl } from "../test_util/std/path/mod.ts"; +} from "@std/assert/mod.ts"; +export { fromFileUrl } from "@std/path/mod.ts"; import process from "node:process"; const targetDir = Deno.execPath().replace(/[^\/\\]+$/, ""); diff --git a/test_napi/date_test.js b/tests/napi/date_test.js similarity index 100% rename from test_napi/date_test.js rename to tests/napi/date_test.js diff --git a/test_napi/env_test.js b/tests/napi/env_test.js similarity index 100% rename from test_napi/env_test.js rename to tests/napi/env_test.js diff --git a/test_napi/error_test.js b/tests/napi/error_test.js similarity index 100% rename from test_napi/error_test.js rename to tests/napi/error_test.js diff --git a/test_napi/init_test.js b/tests/napi/init_test.js similarity index 100% rename from test_napi/init_test.js rename to tests/napi/init_test.js diff --git a/test_napi/make_callback_test.js b/tests/napi/make_callback_test.js similarity index 100% rename from test_napi/make_callback_test.js rename to tests/napi/make_callback_test.js diff --git a/test_napi/mem_test.js b/tests/napi/mem_test.js similarity index 100% rename from test_napi/mem_test.js rename to tests/napi/mem_test.js diff --git a/test_napi/module.c b/tests/napi/module.c similarity index 100% rename from test_napi/module.c rename to tests/napi/module.c diff --git a/test_napi/numbers_test.js b/tests/napi/numbers_test.js similarity index 100% rename from test_napi/numbers_test.js rename to tests/napi/numbers_test.js diff --git a/test_napi/object_wrap_test.js b/tests/napi/object_wrap_test.js similarity index 100% rename from test_napi/object_wrap_test.js rename to tests/napi/object_wrap_test.js diff --git a/test_napi/promise_test.js b/tests/napi/promise_test.js similarity index 100% rename from test_napi/promise_test.js rename to tests/napi/promise_test.js diff --git a/test_napi/properties_test.js b/tests/napi/properties_test.js similarity index 100% rename from test_napi/properties_test.js rename to tests/napi/properties_test.js diff --git a/test_napi/src/array.rs b/tests/napi/src/array.rs similarity index 100% rename from test_napi/src/array.rs rename to tests/napi/src/array.rs diff --git a/test_napi/src/arraybuffer.rs b/tests/napi/src/arraybuffer.rs similarity index 100% rename from test_napi/src/arraybuffer.rs rename to tests/napi/src/arraybuffer.rs diff --git a/test_napi/src/async.rs b/tests/napi/src/async.rs similarity index 100% rename from test_napi/src/async.rs rename to tests/napi/src/async.rs diff --git a/test_napi/src/bigint.rs b/tests/napi/src/bigint.rs similarity index 100% rename from test_napi/src/bigint.rs rename to tests/napi/src/bigint.rs diff --git a/test_napi/src/callback.rs b/tests/napi/src/callback.rs similarity index 100% rename from test_napi/src/callback.rs rename to tests/napi/src/callback.rs diff --git a/test_napi/src/coerce.rs b/tests/napi/src/coerce.rs similarity index 100% rename from test_napi/src/coerce.rs rename to tests/napi/src/coerce.rs diff --git a/test_napi/src/date.rs b/tests/napi/src/date.rs similarity index 100% rename from test_napi/src/date.rs rename to tests/napi/src/date.rs diff --git a/test_napi/src/env.rs b/tests/napi/src/env.rs similarity index 100% rename from test_napi/src/env.rs rename to tests/napi/src/env.rs diff --git a/test_napi/src/error.rs b/tests/napi/src/error.rs similarity index 100% rename from test_napi/src/error.rs rename to tests/napi/src/error.rs diff --git a/test_napi/src/finalizer.rs b/tests/napi/src/finalizer.rs similarity index 100% rename from test_napi/src/finalizer.rs rename to tests/napi/src/finalizer.rs diff --git a/test_napi/src/lib.rs b/tests/napi/src/lib.rs similarity index 100% rename from test_napi/src/lib.rs rename to tests/napi/src/lib.rs diff --git a/test_napi/src/make_callback.rs b/tests/napi/src/make_callback.rs similarity index 100% rename from test_napi/src/make_callback.rs rename to tests/napi/src/make_callback.rs diff --git a/test_napi/src/mem.rs b/tests/napi/src/mem.rs similarity index 100% rename from test_napi/src/mem.rs rename to tests/napi/src/mem.rs diff --git a/test_napi/src/numbers.rs b/tests/napi/src/numbers.rs similarity index 100% rename from test_napi/src/numbers.rs rename to tests/napi/src/numbers.rs diff --git a/test_napi/src/object_wrap.rs b/tests/napi/src/object_wrap.rs similarity index 100% rename from test_napi/src/object_wrap.rs rename to tests/napi/src/object_wrap.rs diff --git a/test_napi/src/primitives.rs b/tests/napi/src/primitives.rs similarity index 100% rename from test_napi/src/primitives.rs rename to tests/napi/src/primitives.rs diff --git a/test_napi/src/promise.rs b/tests/napi/src/promise.rs similarity index 100% rename from test_napi/src/promise.rs rename to tests/napi/src/promise.rs diff --git a/test_napi/src/properties.rs b/tests/napi/src/properties.rs similarity index 100% rename from test_napi/src/properties.rs rename to tests/napi/src/properties.rs diff --git a/test_napi/src/strings.rs b/tests/napi/src/strings.rs similarity index 100% rename from test_napi/src/strings.rs rename to tests/napi/src/strings.rs diff --git a/test_napi/src/symbol.rs b/tests/napi/src/symbol.rs similarity index 100% rename from test_napi/src/symbol.rs rename to tests/napi/src/symbol.rs diff --git a/test_napi/src/tsfn.rs b/tests/napi/src/tsfn.rs similarity index 100% rename from test_napi/src/tsfn.rs rename to tests/napi/src/tsfn.rs diff --git a/test_napi/src/typedarray.rs b/tests/napi/src/typedarray.rs similarity index 100% rename from test_napi/src/typedarray.rs rename to tests/napi/src/typedarray.rs diff --git a/test_napi/strings_test.js b/tests/napi/strings_test.js similarity index 100% rename from test_napi/strings_test.js rename to tests/napi/strings_test.js diff --git a/test_napi/symbol_test.js b/tests/napi/symbol_test.js similarity index 100% rename from test_napi/symbol_test.js rename to tests/napi/symbol_test.js diff --git a/test_napi/tests/napi_tests.rs b/tests/napi/tests/napi_tests.rs similarity index 91% rename from test_napi/tests/napi_tests.rs rename to tests/napi/tests/napi_tests.rs index ce47b1e991..671699651c 100644 --- a/test_napi/tests/napi_tests.rs +++ b/tests/napi/tests/napi_tests.rs @@ -2,8 +2,10 @@ use std::process::Command; use test_util::deno_cmd; +use test_util::deno_config_path; use test_util::env_vars_for_npm_tests; use test_util::http_server; +use test_util::napi_tests_path; #[cfg(debug_assertions)] const BUILD_VARIANT: &str = "debug"; @@ -57,13 +59,17 @@ fn napi_tests() { let _http_guard = http_server(); let output = deno_cmd() - .current_dir(test_util::napi_tests_path()) + .current_dir(napi_tests_path()) .env("RUST_BACKTRACE", "1") .arg("test") .arg("--allow-read") .arg("--allow-env") .arg("--allow-ffi") .arg("--allow-run") + .arg("--config") + .arg(deno_config_path()) + .arg("--no-lock") + .arg(".") .envs(env_vars_for_npm_tests()) .spawn() .unwrap() diff --git a/test_napi/typedarray_test.js b/tests/napi/typedarray_test.js similarity index 100% rename from test_napi/typedarray_test.js rename to tests/napi/typedarray_test.js