mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 05:42:25 -05:00
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:
parent
49d82e609f
commit
3d2e52ae7e
33 changed files with 148 additions and 116 deletions
|
@ -4,10 +4,8 @@
|
|||
name = "deno"
|
||||
version = "1.40.4"
|
||||
authors.workspace = true
|
||||
autotests = false
|
||||
default-run = "deno"
|
||||
edition.workspace = true
|
||||
exclude = ["tests/testdata/npm/registry/*"]
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Provides the deno executable"
|
||||
|
@ -19,7 +17,7 @@ doc = false
|
|||
|
||||
[[test]]
|
||||
name = "integration"
|
||||
path = "../tests/integration_tests_runner.rs"
|
||||
path = "integration_tests_runner.rs"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
|
|
|
@ -29,6 +29,7 @@ pub mod factory;
|
|||
mod fs;
|
||||
mod https;
|
||||
pub mod lsp;
|
||||
mod macros;
|
||||
mod npm;
|
||||
pub mod pty;
|
||||
pub mod servers;
|
||||
|
|
86
test_util/src/macros.rs
Normal file
86
test_util/src/macros.rs
Normal 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()
|
||||
}
|
||||
}
|
||||
);
|
|
@ -17,7 +17,12 @@ run = []
|
|||
|
||||
[[test]]
|
||||
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"]
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
1
tests/README.md
Normal file
1
tests/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
# Deno Integration Tests
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use deno_core::url::Url;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use test_util::itest_flaky;
|
||||
use util::assert_contains;
|
||||
use util::assert_not_contains;
|
||||
use util::env_vars_for_npm_tests;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use test_util as util;
|
||||
use test_util::assert_contains;
|
||||
use test_util::assert_ends_with;
|
||||
use test_util::itest;
|
||||
use test_util::TempDir;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util::env_vars_for_npm_tests;
|
||||
use test_util::itest;
|
||||
use test_util::TestContext;
|
||||
use test_util::TestContextBuilder;
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ use std::io::Cursor;
|
|||
use std::io::Read;
|
||||
use std::sync::Arc;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use test_util::itest_flaky;
|
||||
use url::Url;
|
||||
use util::testdata_path;
|
||||
use util::TestContext;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::env_vars_for_npm_tests;
|
||||
use util::TestContext;
|
||||
use util::TestContextBuilder;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use deno_core::serde_json;
|
||||
use std::fs;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use test_util::TempDir;
|
||||
use util::assert_starts_with;
|
||||
use util::env_vars_for_npm_tests;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::assert_contains;
|
||||
use util::TestContext;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
|
||||
#[test]
|
||||
fn eval_p() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::assert_contains;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::assert_contains;
|
||||
use util::PathRef;
|
||||
use util::TestContext;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::env_vars_for_npm_tests;
|
||||
use util::TestContextBuilder;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
use std::time::Duration;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use deno_core::serde_json::Value;
|
||||
use deno_lockfile::Lockfile;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use url::Url;
|
||||
use util::env_vars_for_jsr_tests;
|
||||
use util::TestContextBuilder;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util::itest;
|
||||
|
||||
itest!(jupyter_install_command_not_exists {
|
||||
args: "jupyter --install",
|
||||
output: "jupyter/install_command_not_exists.out",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util::assert_contains;
|
||||
use test_util::itest;
|
||||
use test_util::TestContextBuilder;
|
||||
|
||||
itest!(ignore_unexplicit_files {
|
||||
|
|
|
@ -1,90 +1,5 @@
|
|||
// 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
|
||||
// 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
|
||||
|
|
|
@ -1,28 +1,9 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use util::deno_config_path;
|
||||
use test_util::itest;
|
||||
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 {
|
||||
args: "test node/test.js",
|
||||
output: "node/test.out",
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::deno_config_path;
|
||||
use util::env_vars_for_npm_tests;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ use deno_core::serde_json::json;
|
|||
use deno_core::serde_json::Value;
|
||||
use pretty_assertions::assert_eq;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::assert_contains;
|
||||
use util::env_vars_for_npm_tests;
|
||||
use util::http_server;
|
||||
|
|
|
@ -5,6 +5,7 @@ use test_util::assert_contains;
|
|||
use test_util::assert_not_contains;
|
||||
use test_util::env_vars_for_jsr_tests;
|
||||
use test_util::env_vars_for_npm_tests;
|
||||
use test_util::itest;
|
||||
use test_util::TestContextBuilder;
|
||||
|
||||
itest!(no_token {
|
||||
|
|
|
@ -11,6 +11,7 @@ use std::process::Command;
|
|||
use std::process::Stdio;
|
||||
use std::time::Duration;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use test_util::TempDir;
|
||||
use trust_dns_client::serialize::txt::Lexer;
|
||||
use trust_dns_client::serialize::txt::Parser;
|
||||
|
@ -2652,6 +2653,7 @@ fn dont_cache_on_check_fail() {
|
|||
|
||||
mod permissions {
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::TestContext;
|
||||
|
||||
// TODO(bartlomieju): remove --unstable once Deno.Command is stabilized
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use deno_core::serde_json::json;
|
||||
use test_util::env_vars_for_npm_tests;
|
||||
use test_util::itest;
|
||||
use test_util::TestContext;
|
||||
use test_util::TestContextBuilder;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use deno_core::url::Url;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::assert_contains;
|
||||
use util::assert_not_contains;
|
||||
use util::env_vars_for_npm_tests;
|
||||
|
|
|
@ -6,6 +6,7 @@ use pretty_assertions::assert_eq;
|
|||
use std::fmt::Write as _;
|
||||
use std::path::PathBuf;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use test_util::TempDir;
|
||||
use util::http_server;
|
||||
use util::new_deno_dir;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util::itest;
|
||||
|
||||
itest!(worker_error {
|
||||
args: "run -A workers/worker_error.ts",
|
||||
output: "workers/worker_error.ts.out",
|
||||
|
|
|
@ -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;
|
23
tests/node_compat/test_runner.rs
Normal file
23
tests/node_compat/test_runner.rs
Normal 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());
|
||||
}
|
Loading…
Reference in a new issue