From dcbbcd23f5dd8601e2851aded4cabc6557164363 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Fri, 9 Feb 2024 13:33:05 -0700 Subject: refactor: split integration tests from CLI (part 1) (#22308) This PR separates integration tests from CLI tests into a new project named `cli_tests`. This is a prerequisite for an integration test runner that can work with either the CLI binary in the current project, or one that is built ahead of time. ## Background Rust does not have the concept of artifact dependencies yet (https://github.com/rust-lang/cargo/issues/9096). Because of this, the only way we can ensure a binary is built before running associated tests is by hanging tests off the crate with the binary itself. Unfortunately this means that to run those tests, you _must_ build the binary and in the case of the deno executable that might be a 10 minute wait in release mode. ## Implementation To allow for tests to run with and without the requirement that the binary is up-to-date, we split the integration tests into a project of their own. As these tests would not require the binary to build itself before being run as-is, we add a stub integration `[[test]]` target in the `cli` project that invokes these tests using `cargo test`. The stub test runner we add has `harness = false` so that we can get access to a `main` function. This `main` function's sole job is to `execvp` the command `cargo test -p deno_cli`, effectively "calling" another cargo target. This ensures that the deno executable is always correctly rebuilt before running the stub test runner from `cli`, and gets us closer to be able to run the entire integration test suite on arbitrary deno executables (and therefore split the build into multiple phases). The new `cli_tests` project lives within `cli` to avoid a large PR. In later PRs, the test data will be split from the `cli` project. As there are a few thousand files, it'll be better to do this as a completely separate PR to avoid noise. --- cli/tests/integration/cert_tests.rs | 8 ++++---- cli/tests/integration/inspector_tests.rs | 2 +- cli/tests/integration/js_unit_tests.rs | 2 +- cli/tests/integration/node_unit_tests.rs | 2 +- cli/tests/integration/run_tests.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'cli/tests/integration') diff --git a/cli/tests/integration/cert_tests.rs b/cli/tests/integration/cert_tests.rs index 484d053f8..9e89a9f3e 100644 --- a/cli/tests/integration/cert_tests.rs +++ b/cli/tests/integration/cert_tests.rs @@ -1,14 +1,14 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_runtime::deno_net::ops_tls::TlsStream; -use deno_runtime::deno_tls::rustls; -use deno_runtime::deno_tls::rustls_pemfile; -use lsp_types::Url; +use deno_tls::rustls; +use deno_tls::rustls_pemfile; +use deno_tls::rustls_tokio_stream::TlsStream; use std::io::BufReader; use std::io::Cursor; use std::io::Read; use std::sync::Arc; use test_util as util; +use url::Url; use util::testdata_path; use util::TestContext; diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs index 872f9e3d2..bbe70ae5e 100644 --- a/cli/tests/integration/inspector_tests.rs +++ b/cli/tests/integration/inspector_tests.rs @@ -6,7 +6,7 @@ use deno_core::error::AnyError; use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::url; -use deno_runtime::deno_fetch::reqwest; +use deno_fetch::reqwest; use fastwebsockets::FragmentCollector; use fastwebsockets::Frame; use fastwebsockets::WebSocket; diff --git a/cli/tests/integration/js_unit_tests.rs b/cli/tests/integration/js_unit_tests.rs index 748c0fe5a..0e3a1a118 100644 --- a/cli/tests/integration/js_unit_tests.rs +++ b/cli/tests/integration/js_unit_tests.rs @@ -7,7 +7,7 @@ use test_util as util; util::unit_test_factory!( js_unit_test, - "tests/unit", + "../tests/unit", "*.ts", [ abort_controller_test, diff --git a/cli/tests/integration/node_unit_tests.rs b/cli/tests/integration/node_unit_tests.rs index b0259663d..5afaf48c5 100644 --- a/cli/tests/integration/node_unit_tests.rs +++ b/cli/tests/integration/node_unit_tests.rs @@ -8,7 +8,7 @@ use util::env_vars_for_npm_tests; util::unit_test_factory!( node_unit_test, - "tests/unit_node", + "../tests/unit_node", "**/*_test.ts", [ _fs_access_test = _fs / _fs_access_test, diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 3d14bb0bb..428de3238 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -3,7 +3,7 @@ use bytes::Bytes; use deno_core::serde_json::json; use deno_core::url; -use deno_runtime::deno_fetch::reqwest; +use deno_fetch::reqwest; use pretty_assertions::assert_eq; use std::io::Read; use std::io::Write; -- cgit v1.2.3