2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2021-06-27 13:27:36 -04:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! itest(
|
|
|
|
($name:ident {$( $key:ident: $value:expr,)*}) => {
|
|
|
|
#[test]
|
|
|
|
fn $name() {
|
2023-02-27 15:52:49 -05:00
|
|
|
let test = test_util::CheckOutputIntegrationTest {
|
2021-06-27 13:27:36 -04:00
|
|
|
$(
|
|
|
|
$key: $value,
|
|
|
|
)*
|
|
|
|
.. Default::default()
|
2023-02-27 15:52:49 -05:00
|
|
|
};
|
|
|
|
let output = test.output();
|
2023-02-28 14:10:12 -05:00
|
|
|
output.assert_exit_code(test.exit_code);
|
2023-02-27 15:52:49 -05:00
|
|
|
if !test.output.is_empty() {
|
|
|
|
assert!(test.output_str.is_none());
|
2023-02-28 14:10:12 -05:00
|
|
|
output.assert_matches_file(test.output);
|
2023-02-27 15:52:49 -05:00
|
|
|
} else {
|
2023-02-28 14:10:12 -05:00
|
|
|
output.assert_matches_text(test.output_str.unwrap_or(""));
|
2023-02-27 15:52:49 -05:00
|
|
|
}
|
2021-06-27 13:27:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
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() {
|
2023-02-27 15:52:49 -05:00
|
|
|
let test = test_util::CheckOutputIntegrationTest {
|
|
|
|
$(
|
|
|
|
$key: $value,
|
|
|
|
)*
|
|
|
|
.. Default::default()
|
|
|
|
};
|
|
|
|
let output = test.output();
|
2023-02-28 14:10:12 -05:00
|
|
|
output.assert_exit_code(test.exit_code);
|
2023-02-27 15:52:49 -05:00
|
|
|
if !test.output.is_empty() {
|
|
|
|
assert!(test.output_str.is_none());
|
2023-02-28 14:10:12 -05:00
|
|
|
output.assert_matches_file(test.output);
|
2023-02-27 15:52:49 -05:00
|
|
|
} else {
|
2023-02-28 14:10:12 -05:00
|
|
|
output.assert_matches_text(test.output_str.unwrap_or(""));
|
2023-02-27 15:52:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
#[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 {
|
2021-08-11 11:38:07 -04:00
|
|
|
$(
|
|
|
|
$key: $value,
|
|
|
|
)*
|
|
|
|
.. Default::default()
|
|
|
|
}).run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2023-01-12 20:59:13 -05:00
|
|
|
|
2023-02-27 15:52:49 -05:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! command_step(
|
|
|
|
({$( $key:ident: $value:expr,)*}) => {
|
|
|
|
test_util::CheckOutputIntegrationTestCommandStep {
|
|
|
|
$(
|
|
|
|
$key: $value,
|
|
|
|
)*
|
|
|
|
.. Default::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-03-17 01:41:17 -04:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
#[test]
|
|
|
|
// https://github.com/denoland/deno/issues/18243
|
|
|
|
fn macos_shared_libraries() {
|
|
|
|
use test_util as util;
|
|
|
|
|
|
|
|
// target/release/deno:
|
|
|
|
// /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1953.255.0)
|
|
|
|
// /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1228.0.0)
|
|
|
|
// /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60420.60.24)
|
|
|
|
// /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
|
|
|
|
// /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
|
2023-03-17 07:51:32 -04:00
|
|
|
const EXPECTED: [&str; 5] =
|
2023-03-17 01:41:17 -04:00
|
|
|
["/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation",
|
|
|
|
"/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices",
|
|
|
|
"/System/Library/Frameworks/Security.framework/Versions/A/Security",
|
|
|
|
"/usr/lib/libiconv.2.dylib",
|
|
|
|
"/usr/lib/libSystem.B.dylib"];
|
|
|
|
|
|
|
|
let otool = std::process::Command::new("otool")
|
|
|
|
.arg("-L")
|
|
|
|
.arg(util::deno_exe_path())
|
|
|
|
.output()
|
|
|
|
.expect("Failed to execute otool");
|
|
|
|
|
|
|
|
let output = std::str::from_utf8(&otool.stdout).unwrap();
|
|
|
|
// Ensure that the output contains only the expected shared libraries.
|
|
|
|
for line in output.lines().skip(1) {
|
2023-03-17 07:51:32 -04:00
|
|
|
let path = line.split_whitespace().next().unwrap();
|
2023-03-17 01:41:17 -04:00
|
|
|
assert!(
|
|
|
|
EXPECTED.contains(&path),
|
|
|
|
"Unexpected shared library: {}",
|
|
|
|
path
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-12 20:59:13 -05: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
|
|
|
|
|
|
|
|
#[path = "bench_tests.rs"]
|
|
|
|
mod bench;
|
|
|
|
#[path = "bundle_tests.rs"]
|
|
|
|
mod bundle;
|
|
|
|
#[path = "cache_tests.rs"]
|
|
|
|
mod cache;
|
|
|
|
#[path = "cert_tests.rs"]
|
|
|
|
mod cert;
|
|
|
|
#[path = "check_tests.rs"]
|
|
|
|
mod check;
|
|
|
|
#[path = "compile_tests.rs"]
|
|
|
|
mod compile;
|
|
|
|
#[path = "coverage_tests.rs"]
|
|
|
|
mod coverage;
|
|
|
|
#[path = "doc_tests.rs"]
|
|
|
|
mod doc;
|
|
|
|
#[path = "eval_tests.rs"]
|
|
|
|
mod eval;
|
|
|
|
#[path = "flags_tests.rs"]
|
|
|
|
mod flags;
|
|
|
|
#[path = "fmt_tests.rs"]
|
|
|
|
mod fmt;
|
|
|
|
#[path = "info_tests.rs"]
|
|
|
|
mod info;
|
|
|
|
#[path = "init_tests.rs"]
|
|
|
|
mod init;
|
|
|
|
#[path = "inspector_tests.rs"]
|
|
|
|
mod inspector;
|
|
|
|
#[path = "install_tests.rs"]
|
|
|
|
mod install;
|
|
|
|
#[path = "js_unit_tests.rs"]
|
|
|
|
mod js_unit_tests;
|
|
|
|
#[path = "lint_tests.rs"]
|
|
|
|
mod lint;
|
|
|
|
#[path = "lsp_tests.rs"]
|
|
|
|
mod lsp;
|
2023-02-17 09:58:52 -05:00
|
|
|
#[path = "node_compat_tests.rs"]
|
|
|
|
mod node_compat_tests;
|
2023-02-16 08:30:14 -05:00
|
|
|
#[path = "node_unit_tests.rs"]
|
|
|
|
mod node_unit_tests;
|
2023-01-12 20:59:13 -05:00
|
|
|
#[path = "npm_tests.rs"]
|
|
|
|
mod npm;
|
|
|
|
#[path = "repl_tests.rs"]
|
|
|
|
mod repl;
|
|
|
|
#[path = "run_tests.rs"]
|
|
|
|
mod run;
|
|
|
|
#[path = "task_tests.rs"]
|
|
|
|
mod task;
|
|
|
|
#[path = "test_tests.rs"]
|
|
|
|
mod test;
|
|
|
|
#[path = "upgrade_tests.rs"]
|
|
|
|
mod upgrade;
|
|
|
|
#[path = "vendor_tests.rs"]
|
|
|
|
mod vendor;
|
|
|
|
#[path = "watcher_tests.rs"]
|
|
|
|
mod watcher;
|
|
|
|
#[path = "worker_tests.rs"]
|
|
|
|
mod worker;
|