mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
chore: speed up compat tests (#12884)
This commit speeds up compat tests by using local copy of "deno_std" instead of downloading it from https://deno.land for each test. Additionally type checking is skipped.
This commit is contained in:
parent
41e9f16290
commit
a3cacb0059
2 changed files with 32 additions and 8 deletions
|
@ -1,40 +1,58 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::itest;
|
use crate::itest;
|
||||||
|
use deno_core::url::Url;
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
|
||||||
|
/// Tests in this file should use `std_file_url` to override `DENO_NODE_COMPAT_URL`
|
||||||
|
/// env variable. This speeds up tests significantly as they no longer
|
||||||
|
/// download contents of `deno_std` from `https://deno.land` in each test.
|
||||||
|
|
||||||
|
/// Return a file URL pointing to "std" submodule
|
||||||
|
/// in "test_util" directory. It must have a trailing slash.
|
||||||
|
fn std_file_url() -> String {
|
||||||
|
let u = Url::from_directory_path(util::std_path()).unwrap();
|
||||||
|
u.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
itest!(globals {
|
itest!(globals {
|
||||||
args: "run --compat --unstable --allow-read --allow-env compat/globals.ts",
|
args: "run --compat --no-check --unstable --allow-read --allow-env compat/globals.ts",
|
||||||
output: "compat/globals.out",
|
output: "compat/globals.out",
|
||||||
|
envs: vec![("DENO_NODE_COMPAT_URL".to_string(), std_file_url())],
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(fs_promises {
|
itest!(fs_promises {
|
||||||
args: "run --compat --unstable -A compat/fs_promises.mjs",
|
args: "run --compat --no-check --unstable -A compat/fs_promises.mjs",
|
||||||
output: "compat/fs_promises.out",
|
output: "compat/fs_promises.out",
|
||||||
|
envs: vec![("DENO_NODE_COMPAT_URL".to_string(), std_file_url())],
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(node_prefix_fs_promises {
|
itest!(node_prefix_fs_promises {
|
||||||
args: "run --compat --unstable -A compat/node_fs_promises.mjs",
|
args: "run --compat --no-check --unstable -A compat/node_fs_promises.mjs",
|
||||||
output: "compat/fs_promises.out",
|
output: "compat/fs_promises.out",
|
||||||
|
envs: vec![("DENO_NODE_COMPAT_URL".to_string(), std_file_url())],
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(compat_with_import_map_and_https_imports {
|
itest!(compat_with_import_map_and_https_imports {
|
||||||
args: "run --quiet --compat --unstable -A --import-map=compat/import_map.json compat/import_map_https_imports.mjs",
|
args: "run --quiet --no-check --compat --unstable -A --import-map=compat/import_map.json compat/import_map_https_imports.mjs",
|
||||||
output: "compat/import_map_https_imports.out",
|
output: "compat/import_map_https_imports.out",
|
||||||
|
envs: vec![("DENO_NODE_COMPAT_URL".to_string(), std_file_url())],
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(compat_dyn_import_rejects_with_node_compatible_error {
|
itest!(compat_dyn_import_rejects_with_node_compatible_error {
|
||||||
args: "run --quiet --compat --unstable -A compat/dyn_import_reject.js",
|
args:
|
||||||
|
"run --quiet --no-check --compat --unstable -A compat/dyn_import_reject.js",
|
||||||
output: "compat/dyn_import_reject.out",
|
output: "compat/dyn_import_reject.out",
|
||||||
|
envs: vec![("DENO_NODE_COMPAT_URL".to_string(), std_file_url())],
|
||||||
});
|
});
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn globals_in_repl() {
|
fn globals_in_repl() {
|
||||||
let (out, _err) = util::run_and_collect_output_with_args(
|
let (out, _err) = util::run_and_collect_output_with_args(
|
||||||
true,
|
true,
|
||||||
vec!["repl", "--compat", "--unstable", "--quiet"],
|
vec!["repl", "--compat", "--unstable", "--no-check", "--quiet"],
|
||||||
Some(vec!["global == window"]),
|
Some(vec!["global == window"]),
|
||||||
None,
|
Some(vec![("DENO_NODE_COMPAT_URL".to_string(), std_file_url())]),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
assert!(out.contains("true"));
|
assert!(out.contains("true"));
|
||||||
|
@ -44,7 +62,7 @@ fn globals_in_repl() {
|
||||||
fn node_compat_url() {
|
fn node_compat_url() {
|
||||||
let (out, err) = util::run_and_collect_output_with_args(
|
let (out, err) = util::run_and_collect_output_with_args(
|
||||||
false,
|
false,
|
||||||
vec!["repl", "--compat", "--unstable", "--quiet"],
|
vec!["repl", "--compat", "--unstable", "--no-check", "--quiet"],
|
||||||
None,
|
None,
|
||||||
Some(vec![(
|
Some(vec![(
|
||||||
"DENO_NODE_COMPAT_URL".to_string(),
|
"DENO_NODE_COMPAT_URL".to_string(),
|
||||||
|
|
|
@ -105,6 +105,10 @@ pub fn third_party_path() -> PathBuf {
|
||||||
root_path().join("third_party")
|
root_path().join("third_party")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn std_path() -> PathBuf {
|
||||||
|
root_path().join("test_util").join("std")
|
||||||
|
}
|
||||||
|
|
||||||
pub fn target_dir() -> PathBuf {
|
pub fn target_dir() -> PathBuf {
|
||||||
let current_exe = std::env::current_exe().unwrap();
|
let current_exe = std::env::current_exe().unwrap();
|
||||||
let target_dir = current_exe.parent().unwrap().parent().unwrap();
|
let target_dir = current_exe.parent().unwrap().parent().unwrap();
|
||||||
|
@ -1655,6 +1659,7 @@ pub struct CheckOutputIntegrationTest {
|
||||||
pub output_str: Option<&'static str>,
|
pub output_str: Option<&'static str>,
|
||||||
pub exit_code: i32,
|
pub exit_code: i32,
|
||||||
pub http_server: bool,
|
pub http_server: bool,
|
||||||
|
pub envs: Vec<(String, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckOutputIntegrationTest {
|
impl CheckOutputIntegrationTest {
|
||||||
|
@ -1675,6 +1680,7 @@ impl CheckOutputIntegrationTest {
|
||||||
println!("deno_exe args {}", self.args);
|
println!("deno_exe args {}", self.args);
|
||||||
println!("deno_exe testdata path {:?}", &testdata_dir);
|
println!("deno_exe testdata path {:?}", &testdata_dir);
|
||||||
command.args(args);
|
command.args(args);
|
||||||
|
command.envs(self.envs.clone());
|
||||||
command.current_dir(&testdata_dir);
|
command.current_dir(&testdata_dir);
|
||||||
command.stdin(Stdio::piped());
|
command.stdin(Stdio::piped());
|
||||||
let writer_clone = writer.try_clone().unwrap();
|
let writer_clone = writer.try_clone().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue