2022-01-07 22:09:52 -05:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
2021-06-27 13:27:36 -04:00
|
|
|
|
|
|
|
use test_util as util;
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! itest(
|
|
|
|
($name:ident {$( $key:ident: $value:expr,)*}) => {
|
|
|
|
#[test]
|
|
|
|
fn $name() {
|
|
|
|
(test_util::CheckOutputIntegrationTest {
|
|
|
|
$(
|
|
|
|
$key: $value,
|
|
|
|
)*
|
|
|
|
.. Default::default()
|
|
|
|
}).run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-08-11 11:38:07 -04:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! itest_flaky(
|
|
|
|
($name:ident {$( $key:ident: $value:expr,)*}) => {
|
|
|
|
#[flaky_test::flaky_test]
|
|
|
|
fn $name() {
|
|
|
|
(test_util::CheckOutputIntegrationTest {
|
|
|
|
$(
|
|
|
|
$key: $value,
|
|
|
|
)*
|
|
|
|
.. Default::default()
|
|
|
|
}).run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-06-27 13:27:36 -04:00
|
|
|
// 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
|
|
|
|
|
2022-03-11 17:07:02 -05:00
|
|
|
#[path = "bench_tests.rs"]
|
|
|
|
mod bench;
|
2021-06-27 13:27:36 -04:00
|
|
|
#[path = "bundle_tests.rs"]
|
|
|
|
mod bundle;
|
|
|
|
#[path = "cache_tests.rs"]
|
|
|
|
mod cache;
|
2022-09-19 10:32:21 -04:00
|
|
|
#[path = "cert_tests.rs"]
|
|
|
|
mod cert;
|
2022-04-10 19:12:51 -04:00
|
|
|
#[path = "check_tests.rs"]
|
|
|
|
mod check;
|
2021-06-27 13:27:36 -04:00
|
|
|
#[path = "compile_tests.rs"]
|
|
|
|
mod compile;
|
|
|
|
#[path = "coverage_tests.rs"]
|
|
|
|
mod coverage;
|
|
|
|
#[path = "doc_tests.rs"]
|
|
|
|
mod doc;
|
|
|
|
#[path = "eval_tests.rs"]
|
|
|
|
mod eval;
|
2022-09-19 10:32:21 -04:00
|
|
|
#[path = "flags_tests.rs"]
|
|
|
|
mod flags;
|
2021-06-27 13:27:36 -04:00
|
|
|
#[path = "fmt_tests.rs"]
|
|
|
|
mod fmt;
|
|
|
|
#[path = "info_tests.rs"]
|
|
|
|
mod info;
|
2022-08-19 19:37:05 -04:00
|
|
|
#[path = "init_tests.rs"]
|
|
|
|
mod init;
|
2021-06-27 13:27:36 -04:00
|
|
|
#[path = "inspector_tests.rs"]
|
|
|
|
mod inspector;
|
|
|
|
#[path = "install_tests.rs"]
|
|
|
|
mod install;
|
|
|
|
#[path = "lint_tests.rs"]
|
|
|
|
mod lint;
|
|
|
|
#[path = "lsp_tests.rs"]
|
|
|
|
mod lsp;
|
2022-08-20 11:31:33 -04:00
|
|
|
#[path = "npm_tests.rs"]
|
|
|
|
mod npm;
|
2021-06-27 13:27:36 -04:00
|
|
|
#[path = "repl_tests.rs"]
|
|
|
|
mod repl;
|
|
|
|
#[path = "run_tests.rs"]
|
|
|
|
mod run;
|
2022-03-10 20:56:14 -05:00
|
|
|
#[path = "task_tests.rs"]
|
|
|
|
mod task;
|
2021-06-27 13:27:36 -04:00
|
|
|
#[path = "test_tests.rs"]
|
|
|
|
mod test;
|
|
|
|
#[path = "upgrade_tests.rs"]
|
|
|
|
mod upgrade;
|
2022-02-16 13:14:19 -05:00
|
|
|
#[path = "vendor_tests.rs"]
|
|
|
|
mod vendor;
|
2021-06-27 13:27:36 -04:00
|
|
|
#[path = "watcher_tests.rs"]
|
|
|
|
mod watcher;
|
|
|
|
#[path = "worker_tests.rs"]
|
|
|
|
mod worker;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn js_unit_tests_lint() {
|
|
|
|
let status = util::deno_cmd()
|
|
|
|
.arg("lint")
|
|
|
|
.arg("--unstable")
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg(util::tests_path().join("unit"))
|
2021-06-27 13:27:36 -04:00
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait()
|
|
|
|
.unwrap();
|
|
|
|
assert!(status.success());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn js_unit_tests() {
|
|
|
|
let _g = util::http_server();
|
|
|
|
|
|
|
|
// Note that the unit tests are not safe for concurrency and must be run with a concurrency limit
|
|
|
|
// of one because there are some chdir tests in there.
|
|
|
|
// TODO(caspervonb) split these tests into two groups: parallel and serial.
|
|
|
|
let mut deno = util::deno_cmd()
|
|
|
|
.current_dir(util::root_path())
|
|
|
|
.arg("test")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--location=http://js-unit-tests/foo/bar")
|
2022-02-12 22:13:21 -05:00
|
|
|
.arg("--no-prompt")
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("-A")
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg(util::tests_path().join("unit"))
|
2021-06-27 13:27:36 -04:00
|
|
|
.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());
|
|
|
|
}
|