diff options
Diffstat (limited to 'cli/tests/integration/mod.rs')
-rw-r--r-- | cli/tests/integration/mod.rs | 120 |
1 files changed, 59 insertions, 61 deletions
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); |