chore: continue tests/ re-org (#22396)

Split `node_compat_tests` into its own top-level test so its stdout
doesn't stomp on the remainder of the tests.
This commit is contained in:
Matt Mastracci 2024-02-12 17:13:14 -07:00 committed by GitHub
parent 49d82e609f
commit 3d2e52ae7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 148 additions and 116 deletions

View File

@ -4,10 +4,8 @@
name = "deno" name = "deno"
version = "1.40.4" version = "1.40.4"
authors.workspace = true authors.workspace = true
autotests = false
default-run = "deno" default-run = "deno"
edition.workspace = true edition.workspace = true
exclude = ["tests/testdata/npm/registry/*"]
license.workspace = true license.workspace = true
repository.workspace = true repository.workspace = true
description = "Provides the deno executable" description = "Provides the deno executable"
@ -19,7 +17,7 @@ doc = false
[[test]] [[test]]
name = "integration" name = "integration"
path = "../tests/integration_tests_runner.rs" path = "integration_tests_runner.rs"
harness = false harness = false
[[bench]] [[bench]]

View File

@ -29,6 +29,7 @@ pub mod factory;
mod fs; mod fs;
mod https; mod https;
pub mod lsp; pub mod lsp;
mod macros;
mod npm; mod npm;
pub mod pty; pub mod pty;
pub mod servers; pub mod servers;

86
test_util/src/macros.rs Normal file
View File

@ -0,0 +1,86 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
#[macro_export]
macro_rules! itest(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[test]
fn $name() {
let test = $crate::CheckOutputIntegrationTest {
$(
$key: $value,
)*
.. Default::default()
};
let output = test.output();
output.assert_exit_code(test.exit_code);
if !test.output.is_empty() {
assert!(test.output_str.is_none());
output.assert_matches_file(test.output);
} else {
output.assert_matches_text(test.output_str.unwrap_or(""));
}
}
}
);
#[macro_export]
macro_rules! itest_flaky(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[flaky_test::flaky_test]
fn $name() {
let test = $crate::CheckOutputIntegrationTest {
$(
$key: $value,
)*
.. Default::default()
};
let output = test.output();
output.assert_exit_code(test.exit_code);
if !test.output.is_empty() {
assert!(test.output_str.is_none());
output.assert_matches_file(test.output);
} else {
output.assert_matches_text(test.output_str.unwrap_or(""));
}
}
}
);
#[macro_export]
macro_rules! context(
({$( $key:ident: $value:expr,)*}) => {
$crate::TestContext::create($crate::TestContextOptions {
$(
$key: $value,
)*
.. Default::default()
})
}
);
#[macro_export]
macro_rules! itest_steps(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[test]
fn $name() {
($crate::CheckOutputIntegrationTestSteps {
$(
$key: $value,
)*
.. Default::default()
}).run()
}
}
);
#[macro_export]
macro_rules! command_step(
({$( $key:ident: $value:expr,)*}) => {
$crate::CheckOutputIntegrationTestCommandStep {
$(
$key: $value,
)*
.. Default::default()
}
}
);

View File

@ -17,7 +17,12 @@ run = []
[[test]] [[test]]
name = "integration_tests" name = "integration_tests"
path = "integration_tests.rs" path = "integration/mod.rs"
required-features = ["run"]
[[test]]
name = "node_compat_tests"
path = "node_compat/test_runner.rs"
required-features = ["run"] required-features = ["run"]
[dev-dependencies] [dev-dependencies]

1
tests/README.md Normal file
View File

@ -0,0 +1 @@
# Deno Integration Tests

View File

@ -2,6 +2,8 @@
use deno_core::url::Url; use deno_core::url::Url;
use test_util as util; use test_util as util;
use test_util::itest;
use test_util::itest_flaky;
use util::assert_contains; use util::assert_contains;
use util::assert_not_contains; use util::assert_not_contains;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;

View File

@ -3,6 +3,7 @@
use test_util as util; use test_util as util;
use test_util::assert_contains; use test_util::assert_contains;
use test_util::assert_ends_with; use test_util::assert_ends_with;
use test_util::itest;
use test_util::TempDir; use test_util::TempDir;
#[test] #[test]

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util::env_vars_for_npm_tests; use test_util::env_vars_for_npm_tests;
use test_util::itest;
use test_util::TestContext; use test_util::TestContext;
use test_util::TestContextBuilder; use test_util::TestContextBuilder;

View File

@ -8,6 +8,8 @@ use std::io::Cursor;
use std::io::Read; use std::io::Read;
use std::sync::Arc; use std::sync::Arc;
use test_util as util; use test_util as util;
use test_util::itest;
use test_util::itest_flaky;
use url::Url; use url::Url;
use util::testdata_path; use util::testdata_path;
use util::TestContext; use util::TestContext;

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util; use test_util as util;
use test_util::itest;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;
use util::TestContext; use util::TestContext;
use util::TestContextBuilder; use util::TestContextBuilder;

View File

@ -3,6 +3,7 @@
use deno_core::serde_json; use deno_core::serde_json;
use std::fs; use std::fs;
use test_util as util; use test_util as util;
use test_util::itest;
use test_util::TempDir; use test_util::TempDir;
use util::assert_starts_with; use util::assert_starts_with;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util; use test_util as util;
use test_util::itest;
use util::assert_contains; use util::assert_contains;
use util::TestContext; use util::TestContext;

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util; use test_util as util;
use test_util::itest;
#[test] #[test]
fn eval_p() { fn eval_p() {

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util; use test_util as util;
use test_util::itest;
use util::assert_contains; use util::assert_contains;
#[test] #[test]

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util; use test_util as util;
use test_util::itest;
use util::assert_contains; use util::assert_contains;
use util::PathRef; use util::PathRef;
use util::TestContext; use util::TestContext;

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util; use test_util as util;
use test_util::itest;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;
use util::TestContextBuilder; use util::TestContextBuilder;

View File

@ -1,4 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use std::io::BufRead; use std::io::BufRead;
use std::io::BufReader; use std::io::BufReader;
use std::time::Duration; use std::time::Duration;

View File

@ -3,6 +3,7 @@
use deno_core::serde_json::Value; use deno_core::serde_json::Value;
use deno_lockfile::Lockfile; use deno_lockfile::Lockfile;
use test_util as util; use test_util as util;
use test_util::itest;
use url::Url; use url::Url;
use util::env_vars_for_jsr_tests; use util::env_vars_for_jsr_tests;
use util::TestContextBuilder; use util::TestContextBuilder;

View File

@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util::itest;
itest!(jupyter_install_command_not_exists { itest!(jupyter_install_command_not_exists {
args: "jupyter --install", args: "jupyter --install",
output: "jupyter/install_command_not_exists.out", output: "jupyter/install_command_not_exists.out",

View File

@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util::assert_contains; use test_util::assert_contains;
use test_util::itest;
use test_util::TestContextBuilder; use test_util::TestContextBuilder;
itest!(ignore_unexplicit_files { itest!(ignore_unexplicit_files {

View File

@ -1,90 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
#[macro_export]
macro_rules! itest(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[test]
fn $name() {
let test = test_util::CheckOutputIntegrationTest {
$(
$key: $value,
)*
.. Default::default()
};
let output = test.output();
output.assert_exit_code(test.exit_code);
if !test.output.is_empty() {
assert!(test.output_str.is_none());
output.assert_matches_file(test.output);
} else {
output.assert_matches_text(test.output_str.unwrap_or(""));
}
}
}
);
#[macro_export]
macro_rules! itest_flaky(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[flaky_test::flaky_test]
fn $name() {
let test = test_util::CheckOutputIntegrationTest {
$(
$key: $value,
)*
.. Default::default()
};
let output = test.output();
output.assert_exit_code(test.exit_code);
if !test.output.is_empty() {
assert!(test.output_str.is_none());
output.assert_matches_file(test.output);
} else {
output.assert_matches_text(test.output_str.unwrap_or(""));
}
}
}
);
#[macro_export]
macro_rules! context(
({$( $key:ident: $value:expr,)*}) => {
test_util::TestContext::create(test_util::TestContextOptions {
$(
$key: $value,
)*
.. Default::default()
})
}
);
#[macro_export]
macro_rules! itest_steps(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[test]
fn $name() {
(test_util::CheckOutputIntegrationTestSteps {
$(
$key: $value,
)*
.. Default::default()
}).run()
}
}
);
#[macro_export]
macro_rules! command_step(
({$( $key:ident: $value:expr,)*}) => {
test_util::CheckOutputIntegrationTestCommandStep {
$(
$key: $value,
)*
.. Default::default()
}
}
);
// These files have `_tests.rs` suffix to make it easier to tell which file is // These files have `_tests.rs` suffix to make it easier to tell which file is
// the test (ex. `lint_tests.rs`) and which is the implementation (ex. `lint.rs`) // the test (ex. `lint_tests.rs`) and which is the implementation (ex. `lint.rs`)
// when both are open, especially for two tabs in VS Code // when both are open, especially for two tabs in VS Code

View File

@ -1,28 +1,9 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util; use test_util as util;
use util::deno_config_path; use test_util::itest;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;
#[test]
fn node_compat_tests() {
let mut deno = util::deno_cmd()
.current_dir(util::root_path())
.arg("test")
.arg("--config")
.arg(deno_config_path())
.arg("--no-lock")
.arg("--unstable")
.arg("-A")
.arg(util::tests_path().join("node_compat"))
.spawn()
.expect("failed to spawn script");
let status = deno.wait().expect("failed to wait for the child process");
assert_eq!(Some(0), status.code());
assert!(status.success());
}
itest!(node_test_module { itest!(node_test_module {
args: "test node/test.js", args: "test node/test.js",
output: "node/test.out", output: "node/test.out",

View File

@ -1,9 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use std::io::BufRead; use std::io::BufRead;
use std::io::BufReader; use std::io::BufReader;
use std::time::Duration; use std::time::Duration;
use std::time::Instant; use std::time::Instant;
use test_util as util; use test_util as util;
use test_util::itest;
use util::deno_config_path; use util::deno_config_path;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;

View File

@ -5,6 +5,7 @@ use deno_core::serde_json::json;
use deno_core::serde_json::Value; use deno_core::serde_json::Value;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use test_util as util; use test_util as util;
use test_util::itest;
use util::assert_contains; use util::assert_contains;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;
use util::http_server; use util::http_server;

View File

@ -5,6 +5,7 @@ use test_util::assert_contains;
use test_util::assert_not_contains; use test_util::assert_not_contains;
use test_util::env_vars_for_jsr_tests; use test_util::env_vars_for_jsr_tests;
use test_util::env_vars_for_npm_tests; use test_util::env_vars_for_npm_tests;
use test_util::itest;
use test_util::TestContextBuilder; use test_util::TestContextBuilder;
itest!(no_token { itest!(no_token {

View File

@ -11,6 +11,7 @@ use std::process::Command;
use std::process::Stdio; use std::process::Stdio;
use std::time::Duration; use std::time::Duration;
use test_util as util; use test_util as util;
use test_util::itest;
use test_util::TempDir; use test_util::TempDir;
use trust_dns_client::serialize::txt::Lexer; use trust_dns_client::serialize::txt::Lexer;
use trust_dns_client::serialize::txt::Parser; use trust_dns_client::serialize::txt::Parser;
@ -2652,6 +2653,7 @@ fn dont_cache_on_check_fail() {
mod permissions { mod permissions {
use test_util as util; use test_util as util;
use test_util::itest;
use util::TestContext; use util::TestContext;
// TODO(bartlomieju): remove --unstable once Deno.Command is stabilized // TODO(bartlomieju): remove --unstable once Deno.Command is stabilized

View File

@ -5,6 +5,7 @@
use deno_core::serde_json::json; use deno_core::serde_json::json;
use test_util::env_vars_for_npm_tests; use test_util::env_vars_for_npm_tests;
use test_util::itest;
use test_util::TestContext; use test_util::TestContext;
use test_util::TestContextBuilder; use test_util::TestContextBuilder;

View File

@ -2,6 +2,7 @@
use deno_core::url::Url; use deno_core::url::Url;
use test_util as util; use test_util as util;
use test_util::itest;
use util::assert_contains; use util::assert_contains;
use util::assert_not_contains; use util::assert_not_contains;
use util::env_vars_for_npm_tests; use util::env_vars_for_npm_tests;

View File

@ -6,6 +6,7 @@ use pretty_assertions::assert_eq;
use std::fmt::Write as _; use std::fmt::Write as _;
use std::path::PathBuf; use std::path::PathBuf;
use test_util as util; use test_util as util;
use test_util::itest;
use test_util::TempDir; use test_util::TempDir;
use util::http_server; use util::http_server;
use util::new_deno_dir; use util::new_deno_dir;

View File

@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util::itest;
itest!(worker_error { itest!(worker_error {
args: "run -A workers/worker_error.ts", args: "run -A workers/worker_error.ts",
output: "workers/worker_error.ts.out", output: "workers/worker_error.ts.out",

View File

@ -1,7 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// The tests exist in a sub folder instead of as separate files in
// this directory so that cargo doesn't compile each file as a new crate.
#[cfg(test)]
mod integration;

View File

@ -0,0 +1,23 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util;
use util::deno_config_path;
#[test]
fn node_compat_tests() {
let mut deno = util::deno_cmd()
.current_dir(util::root_path())
.arg("test")
.arg("--config")
.arg(deno_config_path())
.arg("--no-lock")
.arg("--unstable")
.arg("-A")
.arg(util::tests_path().join("node_compat"))
.spawn()
.expect("failed to spawn script");
let status = deno.wait().expect("failed to wait for the child process");
assert_eq!(Some(0), status.code());
assert!(status.success());
}