summaryrefslogtreecommitdiff
path: root/cli/tests/integration
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-08-11 10:20:47 -0400
committerGitHub <noreply@github.com>2021-08-11 10:20:47 -0400
commit15a763152f9d392cb80692262f8de5ef8ae15495 (patch)
treefcd1a59777f95920bf3502519983d6cc0d882a9a /cli/tests/integration
parenta0285e2eb88f6254f6494b0ecd1878db3a3b2a58 (diff)
chore: move test files to testdata directory (#11601)
Diffstat (limited to 'cli/tests/integration')
-rw-r--r--cli/tests/integration/bundle_tests.rs62
-rw-r--r--cli/tests/integration/cache_tests.rs6
-rw-r--r--cli/tests/integration/compile_tests.rs40
-rw-r--r--cli/tests/integration/coverage_tests.rs24
-rw-r--r--cli/tests/integration/fmt_tests.rs23
-rw-r--r--cli/tests/integration/info_tests.rs10
-rw-r--r--cli/tests/integration/inspector_tests.rs18
-rw-r--r--cli/tests/integration/install_tests.rs6
-rw-r--r--cli/tests/integration/lsp_tests.rs20
-rw-r--r--cli/tests/integration/mod.rs120
-rw-r--r--cli/tests/integration/repl_tests.rs3
-rw-r--r--cli/tests/integration/run_tests.rs113
-rw-r--r--cli/tests/integration/watcher_tests.rs24
-rw-r--r--cli/tests/integration/worker_tests.rs2
14 files changed, 229 insertions, 242 deletions
diff --git a/cli/tests/integration/bundle_tests.rs b/cli/tests/integration/bundle_tests.rs
index 1ef1a39f5..4e68af0b1 100644
--- a/cli/tests/integration/bundle_tests.rs
+++ b/cli/tests/integration/bundle_tests.rs
@@ -7,12 +7,12 @@ use test_util as util;
#[test]
fn bundle_exports() {
// First we have to generate a bundle of some module that has exports.
- let mod1 = util::root_path().join("cli/tests/subdir/mod1.ts");
+ let mod1 = util::testdata_path().join("subdir/mod1.ts");
assert!(mod1.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("mod1.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(mod1)
.arg(&bundle)
@@ -33,7 +33,7 @@ fn bundle_exports() {
.expect("error writing file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
@@ -49,12 +49,12 @@ fn bundle_exports() {
#[test]
fn bundle_exports_no_check() {
// First we have to generate a bundle of some module that has exports.
- let mod1 = util::root_path().join("cli/tests/subdir/mod1.ts");
+ let mod1 = util::testdata_path().join("subdir/mod1.ts");
assert!(mod1.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("mod1.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg("--no-check")
.arg(mod1)
@@ -76,7 +76,7 @@ fn bundle_exports_no_check() {
.expect("error writing file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
@@ -92,12 +92,12 @@ fn bundle_exports_no_check() {
#[test]
fn bundle_circular() {
// First we have to generate a bundle of some module that has exports.
- let circular1 = util::root_path().join("cli/tests/subdir/circular1.ts");
+ let circular1 = util::testdata_path().join("subdir/circular1.ts");
assert!(circular1.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("circular1.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(circular1)
.arg(&bundle)
@@ -108,7 +108,7 @@ fn bundle_circular() {
assert!(bundle.is_file());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&bundle)
.output()
@@ -124,13 +124,12 @@ fn bundle_circular() {
#[test]
fn bundle_single_module() {
// First we have to generate a bundle of some module that has exports.
- let single_module =
- util::root_path().join("cli/tests/subdir/single_module.ts");
+ let single_module = util::testdata_path().join("subdir/single_module.ts");
assert!(single_module.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("single_module.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(single_module)
.arg(&bundle)
@@ -141,7 +140,7 @@ fn bundle_single_module() {
assert!(bundle.is_file());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&bundle)
.output()
@@ -157,12 +156,12 @@ fn bundle_single_module() {
#[test]
fn bundle_tla() {
// First we have to generate a bundle of some module that has exports.
- let tla_import = util::root_path().join("cli/tests/subdir/tla.ts");
+ let tla_import = util::testdata_path().join("subdir/tla.ts");
assert!(tla_import.is_file());
let t = tempfile::TempDir::new().expect("tempdir fail");
let bundle = t.path().join("tla.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(tla_import)
.arg(&bundle)
@@ -183,7 +182,7 @@ fn bundle_tla() {
.expect("error writing file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
@@ -199,12 +198,12 @@ fn bundle_tla() {
#[test]
fn bundle_js() {
// First we have to generate a bundle of some module that has exports.
- let mod6 = util::root_path().join("cli/tests/subdir/mod6.js");
+ let mod6 = util::testdata_path().join("subdir/mod6.js");
assert!(mod6.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("mod6.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(mod6)
.arg(&bundle)
@@ -215,7 +214,7 @@ fn bundle_js() {
assert!(bundle.is_file());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&bundle)
.output()
@@ -227,13 +226,12 @@ fn bundle_js() {
#[test]
fn bundle_dynamic_import() {
let _g = util::http_server();
- let dynamic_import =
- util::root_path().join("cli/tests/bundle_dynamic_import.ts");
+ let dynamic_import = util::testdata_path().join("bundle_dynamic_import.ts");
assert!(dynamic_import.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("bundle_dynamic_import.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(dynamic_import)
.arg(&bundle)
@@ -244,7 +242,7 @@ fn bundle_dynamic_import() {
assert!(bundle.is_file());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--allow-net")
.arg("--quiet")
@@ -261,13 +259,13 @@ fn bundle_dynamic_import() {
#[test]
fn bundle_import_map() {
- let import = util::root_path().join("cli/tests/bundle_im.ts");
- let import_map_path = util::root_path().join("cli/tests/bundle_im.json");
+ let import = util::testdata_path().join("bundle_im.ts");
+ let import_map_path = util::testdata_path().join("bundle_im.json");
assert!(import.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("import_map.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg("--import-map")
.arg(import_map_path)
@@ -290,7 +288,7 @@ fn bundle_import_map() {
.expect("error writing file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
@@ -305,13 +303,13 @@ fn bundle_import_map() {
#[test]
fn bundle_import_map_no_check() {
- let import = util::root_path().join("cli/tests/bundle_im.ts");
- let import_map_path = util::root_path().join("cli/tests/bundle_im.json");
+ let import = util::testdata_path().join("bundle_im.ts");
+ let import_map_path = util::testdata_path().join("bundle_im.json");
assert!(import.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("import_map.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg("--no-check")
.arg("--import-map")
@@ -335,7 +333,7 @@ fn bundle_import_map_no_check() {
.expect("error writing file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
@@ -349,7 +347,7 @@ fn bundle_import_map_no_check() {
}
itest!(lock_check_err_with_bundle {
- args: "bundle --lock=lock_check_err_with_bundle.json http://127.0.0.1:4545/cli/tests/subdir/mod1.ts",
+ args: "bundle --lock=lock_check_err_with_bundle.json http://127.0.0.1:4545/subdir/mod1.ts",
output: "lock_check_err_with_bundle.out",
exit_code: 10,
http_server: true,
diff --git a/cli/tests/integration/cache_tests.rs b/cli/tests/integration/cache_tests.rs
index c97741a13..1fc035b9b 100644
--- a/cli/tests/integration/cache_tests.rs
+++ b/cli/tests/integration/cache_tests.rs
@@ -21,13 +21,13 @@ itest!(_095_cache_with_bare_import {
});
itest!(cache_extensionless {
- args: "cache --reload http://localhost:4545/cli/tests/subdir/no_js_ext",
+ args: "cache --reload http://localhost:4545/subdir/no_js_ext",
output: "cache_extensionless.out",
http_server: true,
});
itest!(cache_random_extension {
- args: "cache --reload http://localhost:4545/cli/tests/subdir/no_js_ext@1.0.0",
+ args: "cache --reload http://localhost:4545/subdir/no_js_ext@1.0.0",
output: "cache_random_extension.out",
http_server: true,
});
@@ -39,7 +39,7 @@ itest!(performance_stats {
itest!(redirect_cache {
http_server: true,
- args: "cache --reload http://localhost:4548/cli/tests/subdir/redirects/a.ts",
+ args: "cache --reload http://localhost:4548/subdir/redirects/a.ts",
output: "redirect_cache.out",
});
diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs
index 0748821dd..067f6b9eb 100644
--- a/cli/tests/integration/compile_tests.rs
+++ b/cli/tests/integration/compile_tests.rs
@@ -71,12 +71,12 @@ fn standalone_args() {
dir.path().join("args")
};
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/028_args.ts")
+ .arg("./028_args.ts")
.arg("a")
.arg("b")
.stdout(std::process::Stdio::piped())
@@ -107,12 +107,12 @@ fn standalone_error() {
dir.path().join("error")
};
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/standalone_error.ts")
+ .arg("./standalone_error.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -143,12 +143,12 @@ fn standalone_no_module_load() {
dir.path().join("hello")
};
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/standalone_import.ts")
+ .arg("./standalone_import.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -178,12 +178,12 @@ fn standalone_load_datauri() {
dir.path().join("load_datauri")
};
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/standalone_import_datauri.ts")
+ .arg("./standalone_import_datauri.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -210,12 +210,12 @@ fn standalone_compiler_ops() {
dir.path().join("standalone_compiler_ops")
};
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/standalone_compiler_ops.ts")
+ .arg("./standalone_compiler_ops.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -243,12 +243,12 @@ fn compile_with_directory_exists_error() {
};
std::fs::create_dir(&exe).expect("cannot create directory");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/028_args.ts")
+ .arg("./028_args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -272,12 +272,12 @@ fn compile_with_conflict_file_exists_error() {
std::fs::write(&exe, b"SHOULD NOT BE OVERWRITTEN")
.expect("cannot create file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/028_args.ts")
+ .arg("./028_args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -303,12 +303,12 @@ fn compile_and_overwrite_file() {
dir.path().join("args")
};
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/028_args.ts")
+ .arg("./028_args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -318,12 +318,12 @@ fn compile_and_overwrite_file() {
assert!(&exe.exists());
let recompile_output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/028_args.ts")
+ .arg("./028_args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -341,7 +341,7 @@ fn standalone_runtime_flags() {
dir.path().join("flags")
};
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("compile")
.arg("--unstable")
.arg("--allow-read")
@@ -349,7 +349,7 @@ fn standalone_runtime_flags() {
.arg("1")
.arg("--output")
.arg(&exe)
- .arg("./cli/tests/standalone_runtime_flags.ts")
+ .arg("./standalone_runtime_flags.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs
index dce3fb38c..4580b5cec 100644
--- a/cli/tests/integration/coverage_tests.rs
+++ b/cli/tests/integration/coverage_tests.rs
@@ -9,12 +9,12 @@ fn branch() {
let tempdir = TempDir::new().expect("tempdir fail");
let tempdir = tempdir.path().join("cov");
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("test")
.arg("--quiet")
.arg("--unstable")
.arg(format!("--coverage={}", tempdir.to_str().unwrap()))
- .arg("cli/tests/coverage/branch_test.ts")
+ .arg("coverage/branch_test.ts")
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::inherit())
.status()
@@ -23,7 +23,7 @@ fn branch() {
assert!(status.success());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("coverage")
.arg("--quiet")
.arg("--unstable")
@@ -38,7 +38,7 @@ fn branch() {
.to_string();
let expected = fs::read_to_string(
- util::root_path().join("cli/tests/coverage/expected_branch.out"),
+ util::testdata_path().join("coverage/expected_branch.out"),
)
.unwrap();
@@ -51,7 +51,7 @@ fn branch() {
assert!(output.status.success());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("coverage")
.arg("--quiet")
.arg("--unstable")
@@ -67,7 +67,7 @@ fn branch() {
.to_string();
let expected = fs::read_to_string(
- util::root_path().join("cli/tests/coverage/expected_branch.lcov"),
+ util::testdata_path().join("coverage/expected_branch.lcov"),
)
.unwrap();
@@ -84,12 +84,12 @@ fn branch() {
fn complex() {
let tempdir = TempDir::new().expect("tempdir fail");
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("test")
.arg("--quiet")
.arg("--unstable")
.arg(format!("--coverage={}", tempdir.path().to_str().unwrap()))
- .arg("cli/tests/coverage/complex_test.ts")
+ .arg("coverage/complex_test.ts")
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::inherit())
.status()
@@ -98,7 +98,7 @@ fn complex() {
assert!(status.success());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("coverage")
.arg("--quiet")
.arg("--unstable")
@@ -113,7 +113,7 @@ fn complex() {
.to_string();
let expected = fs::read_to_string(
- util::root_path().join("cli/tests/coverage/expected_complex.out"),
+ util::testdata_path().join("coverage/expected_complex.out"),
)
.unwrap();
@@ -126,7 +126,7 @@ fn complex() {
assert!(output.status.success());
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("coverage")
.arg("--quiet")
.arg("--unstable")
@@ -142,7 +142,7 @@ fn complex() {
.to_string();
let expected = fs::read_to_string(
- util::root_path().join("cli/tests/coverage/expected_complex.lcov"),
+ util::testdata_path().join("coverage/expected_complex.lcov"),
)
.unwrap();
diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs
index 4aab38fcf..00565a5d0 100644
--- a/cli/tests/integration/fmt_tests.rs
+++ b/cli/tests/integration/fmt_tests.rs
@@ -7,33 +7,32 @@ use test_util as util;
#[test]
fn fmt_test() {
let t = TempDir::new().expect("tempdir fail");
- let fixed_js = util::root_path().join("cli/tests/badly_formatted_fixed.js");
+ let fixed_js = util::testdata_path().join("badly_formatted_fixed.js");
let badly_formatted_original_js =
- util::root_path().join("cli/tests/badly_formatted.mjs");
+ util::testdata_path().join("badly_formatted.mjs");
let badly_formatted_js = t.path().join("badly_formatted.js");
let badly_formatted_js_str = badly_formatted_js.to_str().unwrap();
std::fs::copy(&badly_formatted_original_js, &badly_formatted_js)
.expect("Failed to copy file");
- let fixed_md = util::root_path().join("cli/tests/badly_formatted_fixed.md");
+ let fixed_md = util::testdata_path().join("badly_formatted_fixed.md");
let badly_formatted_original_md =
- util::root_path().join("cli/tests/badly_formatted.md");
+ util::testdata_path().join("badly_formatted.md");
let badly_formatted_md = t.path().join("badly_formatted.md");
let badly_formatted_md_str = badly_formatted_md.to_str().unwrap();
std::fs::copy(&badly_formatted_original_md, &badly_formatted_md)
.expect("Failed to copy file");
- let fixed_json =
- util::root_path().join("cli/tests/badly_formatted_fixed.json");
+ let fixed_json = util::testdata_path().join("badly_formatted_fixed.json");
let badly_formatted_original_json =
- util::root_path().join("cli/tests/badly_formatted.json");
+ util::testdata_path().join("badly_formatted.json");
let badly_formatted_json = t.path().join("badly_formatted.json");
let badly_formatted_json_str = badly_formatted_json.to_str().unwrap();
std::fs::copy(&badly_formatted_original_json, &badly_formatted_json)
.expect("Failed to copy file");
// First, check formatting by ignoring the badly formatted file.
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("fmt")
.arg(format!(
"--ignore={},{},{}",
@@ -52,7 +51,7 @@ fn fmt_test() {
// Check without ignore.
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("fmt")
.arg("--check")
.arg(badly_formatted_js_str)
@@ -66,7 +65,7 @@ fn fmt_test() {
// Format the source file.
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("fmt")
.arg(badly_formatted_js_str)
.arg(badly_formatted_md_str)
@@ -91,7 +90,7 @@ fn fmt_test() {
fn fmt_stdin_error() {
use std::io::Write;
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("fmt")
.arg("-")
.stdin(std::process::Stdio::piped())
@@ -112,7 +111,7 @@ fn fmt_stdin_error() {
#[test]
fn fmt_ignore_unexplicit_files() {
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.env("NO_COLOR", "1")
.arg("fmt")
.arg("--check")
diff --git a/cli/tests/integration/info_tests.rs b/cli/tests/integration/info_tests.rs
index af0f259ea..9e7dbda5b 100644
--- a/cli/tests/integration/info_tests.rs
+++ b/cli/tests/integration/info_tests.rs
@@ -7,12 +7,12 @@ use test_util as util;
#[test]
fn info_with_compiled_source() {
let _g = util::http_server();
- let module_path = "http://127.0.0.1:4545/cli/tests/048_media_types_jsx.ts";
+ let module_path = "http://127.0.0.1:4545/048_media_types_jsx.ts";
let t = TempDir::new().expect("tempdir fail");
let mut deno = util::deno_cmd()
.env("DENO_DIR", t.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("cache")
.arg(&module_path)
.spawn()
@@ -23,7 +23,7 @@ fn info_with_compiled_source() {
let output = util::deno_cmd()
.env("DENO_DIR", t.path())
.env("NO_COLOR", "1")
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("info")
.arg(&module_path)
.output()
@@ -37,7 +37,7 @@ fn info_with_compiled_source() {
}
itest!(_022_info_flag_script {
- args: "info http://127.0.0.1:4545/cli/tests/019_media_types.ts",
+ args: "info http://127.0.0.1:4545/019_media_types.ts",
output: "022_info_flag_script.out",
http_server: true,
});
@@ -68,7 +68,7 @@ itest!(info_json_location {
});
itest!(_049_info_flag_script_jsx {
- args: "info http://127.0.0.1:4545/cli/tests/048_media_types_jsx.ts",
+ args: "info http://127.0.0.1:4545/048_media_types_jsx.ts",
output: "049_info_flag_script_jsx.out",
http_server: true,
});
diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs
index edc18b8d7..520a5b4f7 100644
--- a/cli/tests/integration/inspector_tests.rs
+++ b/cli/tests/integration/inspector_tests.rs
@@ -30,7 +30,7 @@ fn extract_ws_url_from_stderr(
#[tokio::test]
async fn inspector_connect() {
- let script = util::tests_path().join("inspector1.js");
+ let script = util::testdata_path().join("inspector1.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect"))
@@ -64,7 +64,7 @@ enum TestStep {
#[tokio::test]
async fn inspector_break_on_first_line() {
- let script = util::tests_path().join("inspector2.js");
+ let script = util::testdata_path().join("inspector2.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect-brk"))
@@ -132,7 +132,7 @@ async fn inspector_break_on_first_line() {
#[tokio::test]
async fn inspector_pause() {
- let script = util::tests_path().join("inspector1.js");
+ let script = util::testdata_path().join("inspector1.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect"))
@@ -202,7 +202,7 @@ async fn inspector_port_collision() {
return;
}
- let script = util::tests_path().join("inspector1.js");
+ let script = util::testdata_path().join("inspector1.js");
let inspect_flag = inspect_flag_with_unique_port("--inspect");
let mut child1 = util::deno_cmd()
@@ -242,7 +242,7 @@ async fn inspector_port_collision() {
#[tokio::test]
async fn inspector_does_not_hang() {
- let script = util::tests_path().join("inspector3.js");
+ let script = util::testdata_path().join("inspector3.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect-brk"))
@@ -330,7 +330,7 @@ async fn inspector_does_not_hang() {
#[tokio::test]
async fn inspector_without_brk_runs_code() {
- let script = util::tests_path().join("inspector4.js");
+ let script = util::testdata_path().join("inspector4.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect"))
@@ -438,7 +438,7 @@ async fn inspector_runtime_evaluate_does_not_crash() {
#[tokio::test]
async fn inspector_json() {
- let script = util::tests_path().join("inspector1.js");
+ let script = util::testdata_path().join("inspector1.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect"))
@@ -467,7 +467,7 @@ async fn inspector_json() {
#[tokio::test]
async fn inspector_json_list() {
- let script = util::tests_path().join("inspector1.js");
+ let script = util::testdata_path().join("inspector1.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect"))
@@ -498,7 +498,7 @@ async fn inspector_json_list() {
async fn inspector_connect_non_ws() {
// https://github.com/denoland/deno/issues/11449
// Verify we don't panic if non-WS connection is being established
- let script = util::tests_path().join("inspector1.js");
+ let script = util::testdata_path().join("inspector1.js");
let mut child = util::deno_cmd()
.arg("run")
.arg(inspect_flag_with_unique_port("--inspect"))
diff --git a/cli/tests/integration/install_tests.rs b/cli/tests/integration/install_tests.rs
index e5229df8f..ff93c157f 100644
--- a/cli/tests/integration/install_tests.rs
+++ b/cli/tests/integration/install_tests.rs
@@ -16,7 +16,7 @@ fn installer_test_local_module_run() {
.arg("echo_test")
.arg("--root")
.arg(temp_dir.path())
- .arg(util::tests_path().join("echo.ts"))
+ .arg(util::testdata_path().join("echo.ts"))
.arg("hello")
.spawn()
.unwrap()
@@ -47,13 +47,13 @@ fn installer_test_remote_module_run() {
let bin_dir = temp_dir.path().join("bin");
std::fs::create_dir(&bin_dir).unwrap();
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("install")
.arg("--name")
.arg("echo_test")
.arg("--root")
.arg(temp_dir.path())
- .arg("http://localhost:4545/cli/tests/echo.ts")
+ .arg("http://localhost:4545/echo.ts")
.arg("hello")
.spawn()
.unwrap()
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 518dfe850..f0cb6d4b8 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -12,17 +12,17 @@ use tempfile::TempDir;
use test_util::deno_exe_path;
use test_util::http_server;
use test_util::lsp::LspClient;
-use test_util::root_path;
+use test_util::testdata_path;
fn load_fixture(path: &str) -> Value {
- let fixtures_path = root_path().join("cli/tests/lsp");
+ let fixtures_path = testdata_path().join("lsp");
let path = fixtures_path.join(path);
let fixture_str = fs::read_to_string(path).unwrap();
serde_json::from_str(&fixture_str).unwrap()
}
fn load_fixture_str(path: &str) -> String {
- let fixtures_path = root_path().join("cli/tests/lsp");
+ let fixtures_path = testdata_path().join("lsp");
let path = fixtures_path.join(path);
fs::read_to_string(path).unwrap()
}
@@ -921,7 +921,7 @@ fn lsp_hover_dependency() {
Some(json!({
"contents": {
"kind": "markdown",
- "value": "**Resolved Dependency**\n\n**Code**: http&#8203;://127.0.0.1:4545/cli/tests/subdir/type_reference.js\n"
+ "value": "**Resolved Dependency**\n\n**Code**: http&#8203;://127.0.0.1:4545/subdir/type_reference.js\n"
},
"range": {
"start": {
@@ -930,7 +930,7 @@ fn lsp_hover_dependency() {
},
"end":{
"line": 3,
- "character": 76
+ "character": 66
}
}
}))
@@ -955,7 +955,7 @@ fn lsp_hover_dependency() {
Some(json!({
"contents": {
"kind": "markdown",
- "value": "**Resolved Dependency**\n\n**Code**: http&#8203;://127.0.0.1:4545/cli/tests/subdir/mod1.ts\n"
+ "value": "**Resolved Dependency**\n\n**Code**: http&#8203;://127.0.0.1:4545/subdir/mod1.ts\n"
},
"range": {
"start": {
@@ -964,7 +964,7 @@ fn lsp_hover_dependency() {
},
"end":{
"line": 4,
- "character": 66
+ "character": 56
}
}
}))
@@ -2713,7 +2713,7 @@ fn lsp_diagnostics_warn() {
"uri": "file:///a/file.ts",
"languageId": "typescript",
"version": 1,
- "text": "import * as a from \"http://127.0.0.1:4545/cli/tests/x_deno_warning.js\";\n\nconsole.log(a)\n",
+ "text": "import * as a from \"http://127.0.0.1:4545/x_deno_warning.js\";\n\nconsole.log(a)\n",
},
}),
);
@@ -2726,7 +2726,7 @@ fn lsp_diagnostics_warn() {
},
"uris": [
{
- "uri": "http://127.0.0.1:4545/cli/tests/x_deno_warning.js",
+ "uri": "http://127.0.0.1:4545/x_deno_warning.js",
}
],
}),
@@ -2755,7 +2755,7 @@ fn lsp_diagnostics_warn() {
},
end: lsp::Position {
line: 0,
- character: 70
+ character: 60
}
},
severity: Some(lsp::DiagnosticSeverity::Warning),
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index b8917fc91..1d6555ff7 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -74,7 +74,7 @@ mod worker;
#[test]
fn help_flag() {
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("--help")
.spawn()
.unwrap()
@@ -86,7 +86,7 @@ fn help_flag() {
#[test]
fn version_short_flag() {
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("-V")
.spawn()
.unwrap()
@@ -98,7 +98,7 @@ fn version_short_flag() {
#[test]
fn version_long_flag() {
let status = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("--version")
.spawn()
.unwrap()
@@ -117,11 +117,10 @@ fn cache_test() {
let _g = util::http_server();
let deno_dir = TempDir::new().expect("tempdir fail");
let module_url =
- url::Url::parse("http://localhost:4545/cli/tests/006_url_imports.ts")
- .unwrap();
+ url::Url::parse("http://localhost:4545/006_url_imports.ts").unwrap();
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("cache")
.arg("-L")
.arg("debug")
@@ -141,7 +140,7 @@ fn cache_test() {
.env("DENO_DIR", deno_dir.path())
.env("HTTP_PROXY", "http://nil")
.env("NO_COLOR", "1")
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(module_url.to_string())
.output()
@@ -149,8 +148,7 @@ fn cache_test() {
let str_output = std::str::from_utf8(&output.stdout).unwrap();
- let module_output_path =
- util::root_path().join("cli/tests/006_url_imports.ts.out");
+ let module_output_path = util::testdata_path().join("006_url_imports.ts.out");
let mut module_output = String::new();
let mut module_output_file = fs::File::open(module_output_path).unwrap();
module_output_file
@@ -173,7 +171,7 @@ fn cache_invalidation_test() {
}
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(fixture_path.to_str().unwrap())
.output()
@@ -190,7 +188,7 @@ fn cache_invalidation_test() {
}
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(fixture_path.to_str().unwrap())
.output()
@@ -213,7 +211,7 @@ fn cache_invalidation_test_no_check() {
}
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--no-check")
.arg(fixture_path.to_str().unwrap())
@@ -231,7 +229,7 @@ fn cache_invalidation_test_no_check() {
}
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--no-check")
.arg(fixture_path.to_str().unwrap())
@@ -269,7 +267,7 @@ fn ts_dependency_recompilation() {
.unwrap();
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.env("NO_COLOR", "1")
.arg("run")
.arg(&ats)
@@ -291,7 +289,7 @@ fn ts_dependency_recompilation() {
.expect("error writing file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.env("NO_COLOR", "1")
.arg("run")
.arg(&ats)
@@ -312,12 +310,12 @@ fn ts_no_recheck_on_redirect() {
let deno_dir = util::new_deno_dir();
let e = util::deno_exe_path();
- let redirect_ts = util::root_path().join("cli/tests/017_import_redirect.ts");
+ let redirect_ts = util::testdata_path().join("017_import_redirect.ts");
assert!(redirect_ts.is_file());
let mut cmd = Command::new(e.clone());
cmd.env("DENO_DIR", deno_dir.path());
let mut initial = cmd
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(redirect_ts.clone())
.spawn()
@@ -329,7 +327,7 @@ fn ts_no_recheck_on_redirect() {
let mut cmd = Command::new(e);
cmd.env("DENO_DIR", deno_dir.path());
let output = cmd
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(redirect_ts)
.output()
@@ -340,12 +338,12 @@ fn ts_no_recheck_on_redirect() {
#[test]
fn ts_reload() {
- let hello_ts = util::root_path().join("cli/tests/002_hello.ts");
+ let hello_ts = util::testdata_path().join("002_hello.ts");
assert!(hello_ts.is_file());
let deno_dir = TempDir::new().expect("tempdir fail");
let mut initial = util::deno_cmd_with_deno_dir(deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("cache")
.arg(&hello_ts)
.spawn()
@@ -355,7 +353,7 @@ fn ts_reload() {
assert!(status_initial.success());
let output = util::deno_cmd_with_deno_dir(deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("cache")
.arg("--reload")
.arg("-L")
@@ -391,7 +389,7 @@ console.log("finish");
"#;
let mut p = util::deno_cmd()
- .current_dir(util::tests_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("-")
.stdin(std::process::Stdio::piped())
@@ -411,7 +409,7 @@ console.log("finish");
#[test]
fn compiler_api() {
let status = util::deno_cmd()
- .current_dir(util::tests_path())
+ .current_dir(util::testdata_path())
.arg("test")
.arg("--unstable")
.arg("--reload")
@@ -431,7 +429,7 @@ fn broken_stdout() {
drop(reader);
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("eval")
.arg("console.log(3.14)")
.stdout(writer)
@@ -461,14 +459,14 @@ itest!(cafile_ts_fetch {
});
itest!(cafile_eval {
- args: "eval --cert tls/RootCA.pem fetch('https://localhost:5545/cli/tests/cafile_ts_fetch.ts.out').then(r=>r.text()).then(t=>console.log(t.trimEnd()))",
+ args: "eval --cert tls/RootCA.pem fetch('https://localhost:5545/cafile_ts_fetch.ts.out').then(r=>r.text()).then(t=>console.log(t.trimEnd()))",
output: "cafile_ts_fetch.ts.out",
http_server: true,
});
itest!(cafile_info {
args:
- "info --quiet --cert tls/RootCA.pem https://localhost:5545/cli/tests/cafile_info.ts",
+ "info --quiet --cert tls/RootCA.pem https://localhost:5545/cafile_info.ts",
output: "cafile_info.ts.out",
http_server: true,
});
@@ -506,13 +504,12 @@ fn cafile_env_fetch() {
let _g = util::http_server();
let deno_dir = TempDir::new().expect("tempdir fail");
let module_url =
- Url::parse("https://localhost:5545/cli/tests/cafile_url_imports.ts")
- .unwrap();
- let cafile = util::root_path().join("cli/tests/tls/RootCA.pem");
+ Url::parse("https://localhost:5545/cafile_url_imports.ts").unwrap();
+ let cafile = util::testdata_path().join("tls/RootCA.pem");
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
.env("DENO_CERT", cafile)
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("cache")
.arg(module_url.to_string())
.output()
@@ -526,12 +523,11 @@ fn cafile_fetch() {
let _g = util::http_server();
let deno_dir = TempDir::new().expect("tempdir fail");
let module_url =
- Url::parse("http://localhost:4545/cli/tests/cafile_url_imports.ts")
- .unwrap();
- let cafile = util::root_path().join("cli/tests/tls/RootCA.pem");
+ Url::parse("http://localhost:4545/cafile_url_imports.ts").unwrap();
+ let cafile = util::testdata_path().join("tls/RootCA.pem");
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("cache")
.arg("--cert")
.arg(cafile)
@@ -550,11 +546,11 @@ fn cafile_install_remote_module() {
let bin_dir = temp_dir.path().join("bin");
std::fs::create_dir(&bin_dir).unwrap();
let deno_dir = TempDir::new().expect("tempdir fail");
- let cafile = util::root_path().join("cli/tests/tls/RootCA.pem");
+ let cafile = util::testdata_path().join("tls/RootCA.pem");
let install_output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("install")
.arg("--cert")
.arg(cafile)
@@ -562,7 +558,7 @@ fn cafile_install_remote_module() {
.arg(temp_dir.path())
.arg("-n")
.arg("echo_test")
- .arg("https://localhost:5545/cli/tests/echo.ts")
+ .arg("https://localhost:5545/echo.ts")
.output()
.expect("Failed to spawn script");
println!("{}", std::str::from_utf8(&install_output.stdout).unwrap());
@@ -590,12 +586,12 @@ fn cafile_bundle_remote_exports() {
let _g = util::http_server();
// First we have to generate a bundle of some remote module that has exports.
- let mod1 = "https://localhost:5545/cli/tests/subdir/mod1.ts";
- let cafile = util::root_path().join("cli/tests/tls/RootCA.pem");
+ let mod1 = "https://localhost:5545/subdir/mod1.ts";
+ let cafile = util::testdata_path().join("tls/RootCA.pem");
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("mod1.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg("--cert")
.arg(cafile)
@@ -618,7 +614,7 @@ fn cafile_bundle_remote_exports() {
.expect("error writing file");
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
@@ -635,8 +631,8 @@ fn cafile_bundle_remote_exports() {
fn websocket() {
let _g = util::http_server();
- let script = util::tests_path().join("websocket_test.ts");
- let root_ca = util::tests_path().join("tls/RootCA.pem");
+ let script = util::testdata_path().join("websocket_test.ts");
+ let root_ca = util::testdata_path().join("tls/RootCA.pem");
let status = util::deno_cmd()
.arg("test")
.arg("--unstable")
@@ -656,8 +652,8 @@ fn websocket() {
fn websocketstream() {
let _g = util::http_server();
- let script = util::tests_path().join("websocketstream_test.ts");
- let root_ca = util::tests_path().join("tls/RootCA.pem");
+ let script = util::testdata_path().join("websocketstream_test.ts");
+ let root_ca = util::testdata_path().join("tls/RootCA.pem");
let status = util::deno_cmd()
.arg("test")
.arg("--unstable")
@@ -872,7 +868,7 @@ async fn test_resolve_dns() {
// Pass: `--allow-net`
{
let output = util::deno_cmd()
- .current_dir(util::tests_path())
+ .current_dir(util::testdata_path())
.env("NO_COLOR", "1")
.arg("run")
.arg("--allow-net")
@@ -890,7 +886,7 @@ async fn test_resolve_dns() {
assert!(err.starts_with("Check file"));
let expected =
- std::fs::read_to_string(util::tests_path().join("resolve_dns.ts.out"))
+ std::fs::read_to_string(util::testdata_path().join("resolve_dns.ts.out"))
.unwrap();
assert_eq!(expected, out);
}
@@ -898,7 +894,7 @@ async fn test_resolve_dns() {
// Pass: `--allow-net=127.0.0.1:4553`
{
let output = util::deno_cmd()
- .current_dir(util::tests_path())
+ .current_dir(util::testdata_path())
.env("NO_COLOR", "1")
.arg("run")
.arg("--allow-net=127.0.0.1:4553")
@@ -916,7 +912,7 @@ async fn test_resolve_dns() {
assert!(err.starts_with("Check file"));
let expected =
- std::fs::read_to_string(util::tests_path().join("resolve_dns.ts.out"))
+ std::fs::read_to_string(util::testdata_path().join("resolve_dns.ts.out"))
.unwrap();
assert_eq!(expected, out);
}
@@ -924,7 +920,7 @@ async fn test_resolve_dns() {
// Permission error: `--allow-net=deno.land`
{
let output = util::deno_cmd()
- .current_dir(util::tests_path())
+ .current_dir(util::testdata_path())
.env("NO_COLOR", "1")
.arg("run")
.arg("--allow-net=deno.land")
@@ -947,7 +943,7 @@ async fn test_resolve_dns() {
// Permission error: no permission specified
{
let output = util::deno_cmd()
- .current_dir(util::tests_path())
+ .current_dir(util::testdata_path())
.env("NO_COLOR", "1")
.arg("run")
.arg("--unstable")
@@ -1001,7 +997,7 @@ fn js_unit_tests_lint() {
let status = util::deno_cmd()
.arg("lint")
.arg("--unstable")
- .arg(util::root_path().join("cli/tests/unit"))
+ .arg(util::tests_path().join("unit"))
.spawn()
.unwrap()
.wait()
@@ -1022,7 +1018,7 @@ fn js_unit_tests() {
.arg("--unstable")
.arg("--location=http://js-unit-tests/foo/bar")
.arg("-A")
- .arg("cli/tests/unit")
+ .arg(util::tests_path().join("unit"))
.spawn()
.expect("failed to spawn script");
@@ -1038,13 +1034,13 @@ async fn listen_tls_alpn() {
LocalSet::new()
.run_until(async {
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--unstable")
.arg("--quiet")
.arg("--allow-net")
.arg("--allow-read")
- .arg("./cli/tests/listen_tls_alpn.ts")
+ .arg("./listen_tls_alpn.ts")
.arg("4504")
.stdout(std::process::Stdio::piped())
.spawn()
@@ -1057,8 +1053,9 @@ async fn listen_tls_alpn() {
assert_eq!(msg, "READY");
let mut cfg = rustls::ClientConfig::new();
- let reader =
- &mut BufReader::new(Cursor::new(include_bytes!("../tls/RootCA.crt")));
+ let reader = &mut BufReader::new(Cursor::new(include_bytes!(
+ "../testdata/tls/RootCA.crt"
+ )));
cfg.root_store.add_pem_file(reader).unwrap();
cfg.alpn_protocols.push("foobar".as_bytes().to_vec());
let cfg = Arc::new(cfg);
@@ -1090,13 +1087,13 @@ async fn listen_tls_alpn_fail() {
LocalSet::new()
.run_until(async {
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--unstable")
.arg("--quiet")
.arg("--allow-net")
.arg("--allow-read")
- .arg("./cli/tests/listen_tls_alpn.ts")
+ .arg("./listen_tls_alpn.ts")
.arg("4505")
.stdout(std::process::Stdio::piped())
.spawn()
@@ -1109,8 +1106,9 @@ async fn listen_tls_alpn_fail() {
assert_eq!(msg, "READY");
let mut cfg = rustls::ClientConfig::new();
- let reader =
- &mut BufReader::new(Cursor::new(include_bytes!("../tls/RootCA.crt")));
+ let reader = &mut BufReader::new(Cursor::new(include_bytes!(
+ "../testdata/tls/RootCA.crt"
+ )));
cfg.root_store.add_pem_file(reader).unwrap();
cfg.alpn_protocols.push("boofar".as_bytes().to_vec());
let cfg = Arc::new(cfg);
diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs
index 7ce91d406..20dfccb7e 100644
--- a/cli/tests/integration/repl_tests.rs
+++ b/cli/tests/integration/repl_tests.rs
@@ -549,8 +549,7 @@ fn lexical_scoped_variable() {
fn missing_deno_dir() {
use std::fs::{read_dir, remove_dir_all};
const DENO_DIR: &str = "nonexistent";
- let test_deno_dir =
- util::root_path().join("cli").join("tests").join(DENO_DIR);
+ let test_deno_dir = test_util::testdata_path().join(DENO_DIR);
let (out, err) = util::run_and_collect_output(
true,
"repl",
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 4ca0616f7..f5ac82e9c 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -144,7 +144,7 @@ itest!(_033_import_map {
itest!(_033_import_map_remote {
args:
- "run --quiet --reload --import-map=http://127.0.0.1:4545/cli/tests/import_maps/import_map_remote.json --unstable import_maps/test_remote.ts",
+ "run --quiet --reload --import-map=http://127.0.0.1:4545/import_maps/import_map_remote.json --unstable import_maps/test_remote.ts",
output: "033_import_map_remote.out",
http_server: true,
});
@@ -155,8 +155,7 @@ itest!(_034_onload {
});
itest!(_035_cached_only_flag {
- args:
- "run --reload --cached-only http://127.0.0.1:4545/cli/tests/019_media_types.ts",
+ args: "run --reload --cached-only http://127.0.0.1:4545/019_media_types.ts",
output: "035_cached_only_flag.out",
exit_code: 1,
http_server: true,
@@ -203,8 +202,7 @@ itest!(_048_media_types_jsx {
});
itest!(_052_no_remote_flag {
- args:
- "run --reload --no-remote http://127.0.0.1:4545/cli/tests/019_media_types.ts",
+ args: "run --reload --no-remote http://127.0.0.1:4545/019_media_types.ts",
output: "052_no_remote_flag.out",
exit_code: 1,
http_server: true,
@@ -239,7 +237,7 @@ itest!(_071_location_unset {
});
itest!(_072_location_relative_fetch {
- args: "run --location http://127.0.0.1:4545/cli/tests/ --allow-net 072_location_relative_fetch.ts",
+ args: "run --location http://127.0.0.1:4545/ --allow-net 072_location_relative_fetch.ts",
output: "072_location_relative_fetch.ts.out",
http_server: true,
});
@@ -288,18 +286,17 @@ itest!(_082_prepare_stack_trace_throw {
fn _083_legacy_external_source_map() {
let _g = util::http_server();
let deno_dir = TempDir::new().expect("tempdir fail");
- let module_url = url::Url::parse(
- "http://localhost:4545/cli/tests/083_legacy_external_source_map.ts",
- )
- .unwrap();
+ let module_url =
+ url::Url::parse("http://localhost:4545/083_legacy_external_source_map.ts")
+ .unwrap();
// Write a faulty old external source map.
let faulty_map_path = deno_dir.path().join("gen/http/localhost_PORT4545/9576bd5febd0587c5c4d88d57cb3ac8ebf2600c529142abe3baa9a751d20c334.js.map");
std::fs::create_dir_all(faulty_map_path.parent().unwrap())
.expect("Failed to create faulty source map dir.");
- std::fs::write(faulty_map_path, "{\"version\":3,\"file\":\"\",\"sourceRoot\":\"\",\"sources\":[\"http://localhost:4545/cli/tests/083_legacy_external_source_map.ts\"],\"names\":[],\"mappings\":\";AAAA,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC\"}").expect("Failed to write faulty source map.");
+ std::fs::write(faulty_map_path, "{\"version\":3,\"file\":\"\",\"sourceRoot\":\"\",\"sources\":[\"http://localhost:4545/083_legacy_external_source_map.ts\"],\"names\":[],\"mappings\":\";AAAA,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC\"}").expect("Failed to write faulty source map.");
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg(module_url.to_string())
.output()
@@ -394,10 +391,11 @@ itest!(lock_write_fetch {
});
itest!(lock_check_ok {
- args: "run --lock=lock_check_ok.json http://127.0.0.1:4545/cli/tests/003_relative_import.ts",
- output: "003_relative_import.ts.out",
- http_server: true,
- });
+ args:
+ "run --lock=lock_check_ok.json http://127.0.0.1:4545/003_relative_import.ts",
+ output: "003_relative_import.ts.out",
+ http_server: true,
+});
itest!(lock_check_ok2 {
args: "run --lock=lock_check_ok2.json 019_media_types.ts",
@@ -406,14 +404,14 @@ itest!(lock_check_ok2 {
});
itest!(lock_dynamic_imports {
- args: "run --lock=lock_dynamic_imports.json --allow-read --allow-net http://127.0.0.1:4545/cli/tests/013_dynamic_import.ts",
+ args: "run --lock=lock_dynamic_imports.json --allow-read --allow-net http://127.0.0.1:4545/013_dynamic_import.ts",
output: "lock_dynamic_imports.out",
exit_code: 10,
http_server: true,
});
itest!(lock_check_err {
- args: "run --lock=lock_check_err.json http://127.0.0.1:4545/cli/tests/003_relative_import.ts",
+ args: "run --lock=lock_check_err.json http://127.0.0.1:4545/003_relative_import.ts",
output: "lock_check_err.out",
exit_code: 10,
http_server: true,
@@ -452,7 +450,7 @@ itest!(config_types_remote {
itest!(empty_typescript {
args: "run --reload subdir/empty.ts",
- output_str: Some("Check file:[WILDCARD]tests/subdir/empty.ts\n"),
+ output_str: Some("Check file:[WILDCARD]/subdir/empty.ts\n"),
});
itest!(error_001 {
@@ -649,14 +647,14 @@ itest!(error_type_definitions {
});
itest!(error_local_static_import_from_remote_ts {
- args: "run --reload http://localhost:4545/cli/tests/error_local_static_import_from_remote.ts",
+ args: "run --reload http://localhost:4545/error_local_static_import_from_remote.ts",
exit_code: 1,
http_server: true,
output: "error_local_static_import_from_remote.ts.out",
});
itest!(error_local_static_import_from_remote_js {
- args: "run --reload http://localhost:4545/cli/tests/error_local_static_import_from_remote.js",
+ args: "run --reload http://localhost:4545/error_local_static_import_from_remote.js",
exit_code: 1,
http_server: true,
output: "error_local_static_import_from_remote.js.out",
@@ -938,14 +936,14 @@ itest!(_053_import_compression {
});
itest!(disallow_http_from_https_js {
- args: "run --quiet --reload --cert tls/RootCA.pem https://localhost:5545/cli/tests/disallow_http_from_https.js",
+ args: "run --quiet --reload --cert tls/RootCA.pem https://localhost:5545/disallow_http_from_https.js",
output: "disallow_http_from_https_js.out",
http_server: true,
exit_code: 1,
});
itest!(disallow_http_from_https_ts {
- args: "run --quiet --reload --cert tls/RootCA.pem https://localhost:5545/cli/tests/disallow_http_from_https.ts",
+ args: "run --quiet --reload --cert tls/RootCA.pem https://localhost:5545/disallow_http_from_https.ts",
output: "disallow_http_from_https_ts.out",
http_server: true,
exit_code: 1,
@@ -1175,9 +1173,9 @@ itest!(worker_close_race {
#[test]
fn no_validate_asm() {
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
- .arg("cli/tests/no_validate_asm.js")
+ .arg("no_validate_asm.js")
.stderr(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.spawn()
@@ -1192,10 +1190,10 @@ fn no_validate_asm() {
#[test]
fn exec_path() {
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--allow-read")
- .arg("cli/tests/exec_path.ts")
+ .arg("exec_path.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -1223,7 +1221,7 @@ fn run_deno_script_constrained(
script_path: std::path::PathBuf,
constraints: WinProcConstraints,
) -> Result<(), i64> {
- let file_path = "cli/tests/DenoWinRunner.ps1";
+ let file_path = "DenoWinRunner.ps1";
let constraints = match constraints {
WinProcConstraints::NoStdIn => "1",
WinProcConstraints::NoStdOut => "2",
@@ -1244,7 +1242,7 @@ fn run_deno_script_constrained(
#[test]
fn should_not_panic_on_no_stdin() {
let output = run_deno_script_constrained(
- util::tests_path().join("echo.ts"),
+ util::testdata_path().join("echo.ts"),
WinProcConstraints::NoStdIn,
);
output.unwrap();
@@ -1254,7 +1252,7 @@ fn should_not_panic_on_no_stdin() {
#[test]
fn should_not_panic_on_no_stdout() {
let output = run_deno_script_constrained(
- util::tests_path().join("echo.ts"),
+ util::testdata_path().join("echo.ts"),
WinProcConstraints::NoStdOut,
);
output.unwrap();
@@ -1264,7 +1262,7 @@ fn should_not_panic_on_no_stdout() {
#[test]
fn should_not_panic_on_no_stderr() {
let output = run_deno_script_constrained(
- util::tests_path().join("echo.ts"),
+ util::testdata_path().join("echo.ts"),
WinProcConstraints::NoStdErr,
);
output.unwrap();
@@ -1274,9 +1272,9 @@ fn should_not_panic_on_no_stderr() {
#[test]
fn should_not_panic_on_undefined_home_environment_variable() {
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
- .arg("cli/tests/echo.ts")
+ .arg("echo.ts")
.env_remove("HOME")
.spawn()
.unwrap()
@@ -1288,9 +1286,9 @@ fn should_not_panic_on_undefined_home_environment_variable() {
#[test]
fn should_not_panic_on_undefined_deno_dir_environment_variable() {
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
- .arg("cli/tests/echo.ts")
+ .arg("echo.ts")
.env_remove("DENO_DIR")
.spawn()
.unwrap()
@@ -1303,9 +1301,9 @@ fn should_not_panic_on_undefined_deno_dir_environment_variable() {
#[test]
fn should_not_panic_on_undefined_deno_dir_and_home_environment_variables() {
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
- .arg("cli/tests/echo.ts")
+ .arg("echo.ts")
.env_remove("DENO_DIR")
.env_remove("HOME")
.spawn()
@@ -1319,9 +1317,9 @@ fn should_not_panic_on_undefined_deno_dir_and_home_environment_variables() {
fn rust_log() {
// Without RUST_LOG the stderr is empty.
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
- .arg("cli/tests/001_hello.js")
+ .arg("001_hello.js")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -1332,9 +1330,9 @@ fn rust_log() {
// With RUST_LOG the stderr is not empty.
let output = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
- .arg("cli/tests/001_hello.js")
+ .arg("001_hello.js")
.env("RUST_LOG", "debug")
.stderr(std::process::Stdio::piped())
.spawn()
@@ -1352,7 +1350,7 @@ mod permissions {
fn with_allow() {
for permission in &util::PERMISSION_VARIANTS {
let status = util::deno_cmd()
- .current_dir(&util::tests_path())
+ .current_dir(&util::testdata_path())
.arg("run")
.arg(format!("--allow-{0}", permission))
.arg("permission_test.ts")
@@ -1384,12 +1382,15 @@ mod permissions {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
for permission in &PERMISSION_VARIANTS {
let status = util::deno_cmd()
- .current_dir(&util::tests_path())
+ .current_dir(&util::testdata_path())
.arg("run")
.arg(format!(
"--allow-{0}={1}",
permission,
- util::root_path().into_os_string().into_string().unwrap()
+ util::testdata_path()
+ .into_os_string()
+ .into_string()
+ .unwrap()
))
.arg("complex_permissions_test.ts")
.arg(permission)
@@ -1411,9 +1412,7 @@ mod permissions {
&format!(
"run --allow-{0}={1} complex_permissions_test.ts {0} {2}",
permission,
- util::root_path()
- .join("cli")
- .join("tests")
+ util::testdata_path()
.into_os_string()
.into_string()
.unwrap(),
@@ -1436,14 +1435,12 @@ mod permissions {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
for permission in &PERMISSION_VARIANTS {
let status = util::deno_cmd()
- .current_dir(&util::tests_path())
+ .current_dir(&util::testdata_path())
.arg("run")
.arg(format!(
"--allow-{0}={1}",
permission,
- util::root_path()
- .join("cli")
- .join("tests")
+ util::testdata_path()
.into_os_string()
.into_string()
.unwrap()
@@ -1462,9 +1459,7 @@ mod permissions {
#[test]
fn rw_outside_test_and_js_dir() {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
- let test_dir = util::root_path()
- .join("cli")
- .join("tests")
+ let test_dir = util::testdata_path()
.into_os_string()
.into_string()
.unwrap();
@@ -1498,9 +1493,7 @@ mod permissions {
#[test]
fn rw_inside_test_and_js_dir() {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
- let test_dir = util::root_path()
- .join("cli")
- .join("tests")
+ let test_dir = util::testdata_path()
.into_os_string()
.into_string()
.unwrap();
@@ -1511,7 +1504,7 @@ mod permissions {
.unwrap();
for permission in &PERMISSION_VARIANTS {
let status = util::deno_cmd()
- .current_dir(&util::tests_path())
+ .current_dir(&util::testdata_path())
.arg("run")
.arg(format!("--allow-{0}={1},{2}", permission, test_dir, js_dir))
.arg("complex_permissions_test.ts")
@@ -1530,7 +1523,7 @@ mod permissions {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
for permission in &PERMISSION_VARIANTS {
let status = util::deno_cmd()
- .current_dir(&util::tests_path())
+ .current_dir(&util::testdata_path())
.arg("run")
.arg(format!("--allow-{0}=.", permission))
.arg("complex_permissions_test.ts")
@@ -1549,7 +1542,7 @@ mod permissions {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
for permission in &PERMISSION_VARIANTS {
let status = util::deno_cmd()
- .current_dir(&util::tests_path())
+ .current_dir(&util::testdata_path())
.arg("run")
.arg(format!("--allow-{0}=tls/../", permission))
.arg("complex_permissions_test.ts")
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs
index ed574a0bf..8b03ae470 100644
--- a/cli/tests/integration/watcher_tests.rs
+++ b/cli/tests/integration/watcher_tests.rs
@@ -50,15 +50,15 @@ fn wait_for_process_failed(
#[test]
fn fmt_watch_test() {
let t = TempDir::new().expect("tempdir fail");
- let fixed = util::root_path().join("cli/tests/badly_formatted_fixed.js");
+ let fixed = util::testdata_path().join("badly_formatted_fixed.js");
let badly_formatted_original =
- util::root_path().join("cli/tests/badly_formatted.mjs");
+ util::testdata_path().join("badly_formatted.mjs");
let badly_formatted = t.path().join("badly_formatted.js");
std::fs::copy(&badly_formatted_original, &badly_formatted)
.expect("Failed to copy file");
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("fmt")
.arg(&badly_formatted)
.arg("--watch")
@@ -109,7 +109,7 @@ fn bundle_js_watch() {
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("mod6.bundle.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(&file_to_watch)
.arg(&bundle)
@@ -173,7 +173,7 @@ fn bundle_watch_not_exit() {
let target_file = t.path().join("target.js");
let mut deno = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("bundle")
.arg(&file_to_watch)
.arg(&target_file)
@@ -224,7 +224,7 @@ fn run_watch() {
.expect("error writing file");
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--watch")
.arg("--unstable")
@@ -330,7 +330,7 @@ fn run_watch_not_exit() {
.expect("error writing file");
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--watch")
.arg("--unstable")
@@ -377,14 +377,14 @@ fn run_watch_with_import_map_and_relative_paths() {
let absolute_path = directory.path().join(filename);
std::fs::write(&absolute_path, filecontent).expect("error writing file");
let relative_path = absolute_path
- .strip_prefix(util::root_path())
+ .strip_prefix(util::testdata_path())
.expect("unable to create relative temporary file")
.to_owned();
assert!(relative_path.is_relative());
relative_path
}
let temp_directory =
- TempDir::new_in(util::root_path()).expect("tempdir fail");
+ TempDir::new_in(util::testdata_path()).expect("tempdir fail");
let file_to_watch = create_relative_tmp_file(
&temp_directory,
"file_to_watch.js",
@@ -397,7 +397,7 @@ fn run_watch_with_import_map_and_relative_paths() {
);
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("run")
.arg("--unstable")
.arg("--watch")
@@ -443,7 +443,7 @@ fn test_watch() {
let t = TempDir::new().expect("tempdir fail");
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("test")
.arg("--watch")
.arg("--unstable")
@@ -612,7 +612,7 @@ fn test_watch_doc() {
let t = TempDir::new().expect("tempdir fail");
let mut child = util::deno_cmd()
- .current_dir(util::root_path())
+ .current_dir(util::testdata_path())
.arg("test")
.arg("--watch")
.arg("--doc")
diff --git a/cli/tests/integration/worker_tests.rs b/cli/tests/integration/worker_tests.rs
index 2340fa705..c158776ee 100644
--- a/cli/tests/integration/worker_tests.rs
+++ b/cli/tests/integration/worker_tests.rs
@@ -3,7 +3,7 @@
use crate::itest;
itest!(workers {
- args: "test --reload --location http://127.0.0.1:4545/cli/tests/ --allow-net --allow-read --unstable workers/test.ts",
+ args: "test --reload --location http://127.0.0.1:4545/ --allow-net --allow-read --unstable workers/test.ts",
output: "workers/test.ts.out",
http_server: true,
});