summaryrefslogtreecommitdiff
path: root/cli/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration')
-rw-r--r--cli/tests/integration/bundle_tests.rs68
-rw-r--r--cli/tests/integration/cache_tests.rs24
-rw-r--r--cli/tests/integration/cert_tests.rs316
-rw-r--r--cli/tests/integration/check_tests.rs108
-rw-r--r--cli/tests/integration/compile_tests.rs30
-rw-r--r--cli/tests/integration/doc_tests.rs9
-rw-r--r--cli/tests/integration/eval_tests.rs14
-rw-r--r--cli/tests/integration/flags_tests.rs45
-rw-r--r--cli/tests/integration/fmt_tests.rs20
-rw-r--r--cli/tests/integration/info_tests.rs70
-rw-r--r--cli/tests/integration/lsp_tests.rs4
-rw-r--r--cli/tests/integration/mod.rs1139
-rw-r--r--cli/tests/integration/repl_tests.rs10
-rw-r--r--cli/tests/integration/run_tests.rs2023
-rw-r--r--cli/tests/integration/vendor_tests.rs1
-rw-r--r--cli/tests/integration/watcher_tests.rs20
-rw-r--r--cli/tests/integration/worker_tests.rs12
17 files changed, 1963 insertions, 1950 deletions
diff --git a/cli/tests/integration/bundle_tests.rs b/cli/tests/integration/bundle_tests.rs
index a2e529000..ff5a51e98 100644
--- a/cli/tests/integration/bundle_tests.rs
+++ b/cli/tests/integration/bundle_tests.rs
@@ -231,27 +231,27 @@ fn bundle_js() {
#[test]
fn bundle_dynamic_import() {
let _g = util::http_server();
- let dynamic_import = util::testdata_path().join("bundle_dynamic_import.ts");
+ let dynamic_import = util::testdata_path().join("bundle/dynamic_import.ts");
assert!(dynamic_import.is_file());
let t = TempDir::new();
- let bundle = t.path().join("bundle_dynamic_import.bundle.js");
+ let output_path = t.path().join("bundle_dynamic_import.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(dynamic_import)
- .arg(&bundle)
+ .arg(&output_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
- assert!(bundle.is_file());
+ assert!(output_path.is_file());
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg("--allow-net")
.arg("--quiet")
- .arg(&bundle)
+ .arg(&output_path)
.output()
.unwrap();
// check the output of the test.ts program.
@@ -264,23 +264,24 @@ fn bundle_dynamic_import() {
#[test]
fn bundle_import_map() {
- let import = util::testdata_path().join("bundle_im.ts");
- let import_map_path = util::testdata_path().join("bundle_im.json");
+ let import = util::testdata_path().join("bundle/import_map/main.ts");
+ let import_map_path =
+ util::testdata_path().join("bundle/import_map/import_map.json");
assert!(import.is_file());
let t = TempDir::new();
- let bundle = t.path().join("import_map.bundle.js");
+ let output_path = t.path().join("import_map.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg("--import-map")
.arg(import_map_path)
.arg(import)
- .arg(&bundle)
+ .arg(&output_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
- assert!(bundle.is_file());
+ assert!(output_path.is_file());
// Now we try to use that bundle from another module.
let test = t.path().join("test.js");
@@ -309,23 +310,24 @@ fn bundle_import_map() {
#[test]
fn bundle_import_map_no_check() {
- let import = util::testdata_path().join("bundle_im.ts");
- let import_map_path = util::testdata_path().join("bundle_im.json");
+ let import = util::testdata_path().join("bundle/import_map/main.ts");
+ let import_map_path =
+ util::testdata_path().join("bundle/import_map/import_map.json");
assert!(import.is_file());
let t = TempDir::new();
- let bundle = t.path().join("import_map.bundle.js");
+ let output_path = t.path().join("import_map.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg("--import-map")
.arg(import_map_path)
.arg(import)
- .arg(&bundle)
+ .arg(&output_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
- assert!(bundle.is_file());
+ assert!(output_path.is_file());
// Now we try to use that bundle from another module.
let test = t.path().join("test.js");
@@ -414,32 +416,32 @@ fn bundle_json_module_escape_sub() {
);
}
-itest!(lock_check_err_with_bundle {
- 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",
+itest!(lockfile_check_error {
+ args: "bundle --lock=bundle/lockfile/check_error.json http://127.0.0.1:4545/subdir/mod1.ts",
+ output: "bundle/lockfile/check_error.out",
exit_code: 10,
http_server: true,
});
itest!(bundle {
args: "bundle subdir/mod1.ts",
- output: "bundle.test.out",
+ output: "bundle/bundle.test.out",
});
itest!(bundle_jsx {
- args: "bundle jsx_import_from_ts.ts",
- output: "bundle_jsx.out",
+ args: "bundle run/jsx_import_from_ts.ts",
+ output: "bundle/jsx.out",
});
-itest!(error_027_bundle_with_bare_import {
- args: "bundle error_027_bundle_with_bare_import.ts",
- output: "error_027_bundle_with_bare_import.ts.out",
+itest!(error_bundle_with_bare_import {
+ args: "bundle bundle/bare_imports/error_with_bare_import.ts",
+ output: "bundle/bare_imports/error_with_bare_import.ts.out",
exit_code: 1,
});
itest!(ts_decorators_bundle {
- args: "bundle ts_decorators_bundle.ts",
- output: "ts_decorators_bundle.out",
+ args: "bundle bundle/decorators/ts_decorators.ts",
+ output: "bundle/decorators/ts_decorators.out",
});
itest!(bundle_export_specifier_with_alias {
@@ -449,18 +451,18 @@ itest!(bundle_export_specifier_with_alias {
itest!(bundle_ignore_directives {
args: "bundle subdir/mod1.ts",
- output: "bundle_ignore_directives.test.out",
+ output: "bundle/ignore_directives.test.out",
});
-itest!(check_local_by_default {
- args: "bundle --quiet bundle/check_local_by_default.ts",
- output: "bundle/check_local_by_default.out",
+itest!(check_local_by_default_no_errors {
+ args: "bundle --quiet bundle/check_local_by_default/no_errors.ts",
+ output: "bundle/check_local_by_default/no_errors.out",
http_server: true,
});
-itest!(check_local_by_default2 {
- args: "bundle --quiet bundle/check_local_by_default2.ts",
- output: "bundle/check_local_by_default2.out",
+itest!(check_local_by_default_type_error {
+ args: "bundle --quiet bundle/check_local_by_default/type_error.ts",
+ output: "bundle/check_local_by_default/type_error.out",
http_server: true,
exit_code: 1,
});
diff --git a/cli/tests/integration/cache_tests.rs b/cli/tests/integration/cache_tests.rs
index 54aea8106..3fca335a9 100644
--- a/cli/tests/integration/cache_tests.rs
+++ b/cli/tests/integration/cache_tests.rs
@@ -5,48 +5,48 @@ use crate::itest;
itest!(_036_import_map_fetch {
args:
"cache --quiet --reload --import-map=import_maps/import_map.json import_maps/test.ts",
- output: "036_import_map_fetch.out",
+ output: "cache/036_import_map_fetch.out",
});
itest!(_037_fetch_multiple {
- args: "cache --reload --check=all fetch/test.ts fetch/other.ts",
+ args: "cache --reload --check=all run/fetch/test.ts run/fetch/other.ts",
http_server: true,
- output: "037_fetch_multiple.out",
+ output: "cache/037_fetch_multiple.out",
});
itest!(_095_cache_with_bare_import {
- args: "cache 095_cache_with_bare_import.ts",
- output: "095_cache_with_bare_import.ts.out",
+ args: "cache cache/095_cache_with_bare_import.ts",
+ output: "cache/095_cache_with_bare_import.ts.out",
exit_code: 1,
});
itest!(cache_extensionless {
args: "cache --reload --check=all http://localhost:4545/subdir/no_js_ext",
- output: "cache_extensionless.out",
+ output: "cache/cache_extensionless.out",
http_server: true,
});
itest!(cache_random_extension {
args:
"cache --reload --check=all http://localhost:4545/subdir/no_js_ext@1.0.0",
- output: "cache_random_extension.out",
+ output: "cache/cache_random_extension.out",
http_server: true,
});
itest!(performance_stats {
- args: "cache --reload --check=all --log-level debug 002_hello.ts",
- output: "performance_stats.out",
+ args: "cache --reload --check=all --log-level debug run/002_hello.ts",
+ output: "cache/performance_stats.out",
});
itest!(redirect_cache {
http_server: true,
args:
"cache --reload --check=all http://localhost:4548/subdir/redirects/a.ts",
- output: "redirect_cache.out",
+ output: "cache/redirect_cache.out",
});
itest!(ignore_require {
- args: "cache --reload --no-check ignore_require.js",
+ args: "cache --reload --no-check cache/ignore_require.js",
output_str: Some(""),
exit_code: 0,
});
@@ -71,7 +71,7 @@ fn relative_home_dir() {
.arg("cache")
.arg("--reload")
.arg("--no-check")
- .arg("002_hello.ts")
+ .arg("run/002_hello.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
diff --git a/cli/tests/integration/cert_tests.rs b/cli/tests/integration/cert_tests.rs
new file mode 100644
index 000000000..fd19c1cc1
--- /dev/null
+++ b/cli/tests/integration/cert_tests.rs
@@ -0,0 +1,316 @@
+// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
+
+use crate::itest;
+use deno_runtime::deno_net::ops_tls::TlsStream;
+use deno_runtime::deno_tls::rustls;
+use deno_runtime::deno_tls::rustls_pemfile;
+use std::io::BufReader;
+use std::io::Cursor;
+use std::io::Read;
+use std::process::Command;
+use std::sync::Arc;
+use test_util as util;
+use test_util::TempDir;
+use tokio::task::LocalSet;
+
+itest_flaky!(cafile_url_imports {
+ args: "run --quiet --reload --cert tls/RootCA.pem cert/cafile_url_imports.ts",
+ output: "cert/cafile_url_imports.ts.out",
+ http_server: true,
+});
+
+itest_flaky!(cafile_ts_fetch {
+ args:
+ "run --quiet --reload --allow-net --cert tls/RootCA.pem cert/cafile_ts_fetch.ts",
+ output: "cert/cafile_ts_fetch.ts.out",
+ http_server: true,
+});
+
+itest_flaky!(cafile_eval {
+ args: "eval --cert tls/RootCA.pem fetch('https://localhost:5545/cert/cafile_ts_fetch.ts.out').then(r=>r.text()).then(t=>console.log(t.trimEnd()))",
+ output: "cert/cafile_ts_fetch.ts.out",
+ http_server: true,
+});
+
+itest_flaky!(cafile_info {
+ args:
+ "info --quiet --cert tls/RootCA.pem https://localhost:5545/cert/cafile_info.ts",
+ output: "cert/cafile_info.ts.out",
+ http_server: true,
+});
+
+itest_flaky!(cafile_url_imports_unsafe_ssl {
+ args: "run --quiet --reload --unsafely-ignore-certificate-errors=localhost cert/cafile_url_imports.ts",
+ output: "cert/cafile_url_imports_unsafe_ssl.ts.out",
+ http_server: true,
+});
+
+itest_flaky!(cafile_ts_fetch_unsafe_ssl {
+ args:
+ "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors cert/cafile_ts_fetch.ts",
+ output: "cert/cafile_ts_fetch_unsafe_ssl.ts.out",
+ http_server: true,
+});
+
+itest!(deno_land_unsafe_ssl {
+ args:
+ "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors=deno.land cert/deno_land_unsafe_ssl.ts",
+ output: "cert/deno_land_unsafe_ssl.ts.out",
+});
+
+itest!(ip_address_unsafe_ssl {
+ args:
+ "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors=1.1.1.1 cert/ip_address_unsafe_ssl.ts",
+ output: "cert/ip_address_unsafe_ssl.ts.out",
+});
+
+itest!(localhost_unsafe_ssl {
+ args:
+ "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors=deno.land cert/cafile_url_imports.ts",
+ output: "cert/localhost_unsafe_ssl.ts.out",
+ http_server: true,
+ exit_code: 1,
+});
+
+#[flaky_test::flaky_test]
+fn cafile_env_fetch() {
+ use deno_core::url::Url;
+ let _g = util::http_server();
+ let deno_dir = TempDir::new();
+ let module_url =
+ Url::parse("https://localhost:5545/cert/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::testdata_path())
+ .arg("cache")
+ .arg(module_url.to_string())
+ .output()
+ .expect("Failed to spawn script");
+ assert!(output.status.success());
+}
+
+#[flaky_test::flaky_test]
+fn cafile_fetch() {
+ use deno_core::url::Url;
+ let _g = util::http_server();
+ let deno_dir = TempDir::new();
+ let module_url =
+ Url::parse("http://localhost:4545/cert/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::testdata_path())
+ .arg("cache")
+ .arg("--cert")
+ .arg(cafile)
+ .arg(module_url.to_string())
+ .output()
+ .expect("Failed to spawn script");
+ assert!(output.status.success());
+ let out = std::str::from_utf8(&output.stdout).unwrap();
+ assert_eq!(out, "");
+}
+
+#[flaky_test::flaky_test]
+fn cafile_install_remote_module() {
+ let _g = util::http_server();
+ let temp_dir = TempDir::new();
+ let bin_dir = temp_dir.path().join("bin");
+ std::fs::create_dir(&bin_dir).unwrap();
+ let deno_dir = TempDir::new();
+ 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::testdata_path())
+ .arg("install")
+ .arg("--cert")
+ .arg(cafile)
+ .arg("--root")
+ .arg(temp_dir.path())
+ .arg("-n")
+ .arg("echo_test")
+ .arg("https://localhost:5545/echo.ts")
+ .output()
+ .expect("Failed to spawn script");
+ println!("{}", std::str::from_utf8(&install_output.stdout).unwrap());
+ eprintln!("{}", std::str::from_utf8(&install_output.stderr).unwrap());
+ assert!(install_output.status.success());
+
+ let mut echo_test_path = bin_dir.join("echo_test");
+ if cfg!(windows) {
+ echo_test_path = echo_test_path.with_extension("cmd");
+ }
+ assert!(echo_test_path.exists());
+
+ let output = Command::new(echo_test_path)
+ .current_dir(temp_dir.path())
+ .arg("foo")
+ .env("PATH", util::target_dir())
+ .output()
+ .expect("failed to spawn script");
+ let stdout = std::str::from_utf8(&output.stdout).unwrap().trim();
+ assert!(stdout.ends_with("foo"));
+}
+
+#[flaky_test::flaky_test]
+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/subdir/mod1.ts";
+ let cafile = util::testdata_path().join("tls/RootCA.pem");
+ let t = TempDir::new();
+ let bundle = t.path().join("mod1.bundle.js");
+ let mut deno = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("bundle")
+ .arg("--cert")
+ .arg(cafile)
+ .arg(mod1)
+ .arg(&bundle)
+ .spawn()
+ .expect("failed to spawn script");
+ let status = deno.wait().expect("failed to wait for the child process");
+ assert!(status.success());
+ assert!(bundle.is_file());
+
+ // Now we try to use that bundle from another module.
+ let test = t.path().join("test.js");
+ std::fs::write(
+ &test,
+ "
+ import { printHello3 } from \"./mod1.bundle.js\";
+ printHello3(); ",
+ )
+ .expect("error writing file");
+
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--check")
+ .arg(&test)
+ .output()
+ .expect("failed to spawn script");
+ // check the output of the test.ts program.
+ assert!(std::str::from_utf8(&output.stdout)
+ .unwrap()
+ .trim()
+ .ends_with("Hello"));
+ assert_eq!(output.stderr, b"");
+}
+
+#[tokio::test]
+async fn listen_tls_alpn() {
+ // TLS streams require the presence of an ambient local task set to gracefully
+ // close dropped connections in the background.
+ LocalSet::new()
+ .run_until(async {
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--unstable")
+ .arg("--quiet")
+ .arg("--allow-net")
+ .arg("--allow-read")
+ .arg("./cert/listen_tls_alpn.ts")
+ .arg("4504")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut msg = [0; 5];
+ let read = stdout.read(&mut msg).unwrap();
+ assert_eq!(read, 5);
+ assert_eq!(&msg, b"READY");
+
+ let mut reader = &mut BufReader::new(Cursor::new(include_bytes!(
+ "../testdata/tls/RootCA.crt"
+ )));
+ let certs = rustls_pemfile::certs(&mut reader).unwrap();
+ let mut root_store = rustls::RootCertStore::empty();
+ root_store.add_parsable_certificates(&certs);
+ let mut cfg = rustls::ClientConfig::builder()
+ .with_safe_defaults()
+ .with_root_certificates(root_store)
+ .with_no_client_auth();
+ cfg.alpn_protocols.push(b"foobar".to_vec());
+ let cfg = Arc::new(cfg);
+
+ let hostname = rustls::ServerName::try_from("localhost").unwrap();
+
+ let tcp_stream = tokio::net::TcpStream::connect("localhost:4504")
+ .await
+ .unwrap();
+ let mut tls_stream =
+ TlsStream::new_client_side(tcp_stream, cfg, hostname);
+
+ tls_stream.handshake().await.unwrap();
+
+ let (_, rustls_connection) = tls_stream.get_ref();
+ let alpn = rustls_connection.alpn_protocol().unwrap();
+ assert_eq!(alpn, b"foobar");
+
+ let status = child.wait().unwrap();
+ assert!(status.success());
+ })
+ .await;
+}
+
+#[tokio::test]
+async fn listen_tls_alpn_fail() {
+ // TLS streams require the presence of an ambient local task set to gracefully
+ // close dropped connections in the background.
+ LocalSet::new()
+ .run_until(async {
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--unstable")
+ .arg("--quiet")
+ .arg("--allow-net")
+ .arg("--allow-read")
+ .arg("./cert/listen_tls_alpn_fail.ts")
+ .arg("4505")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut msg = [0; 5];
+ let read = stdout.read(&mut msg).unwrap();
+ assert_eq!(read, 5);
+ assert_eq!(&msg, b"READY");
+
+ let mut reader = &mut BufReader::new(Cursor::new(include_bytes!(
+ "../testdata/tls/RootCA.crt"
+ )));
+ let certs = rustls_pemfile::certs(&mut reader).unwrap();
+ let mut root_store = rustls::RootCertStore::empty();
+ root_store.add_parsable_certificates(&certs);
+ let mut cfg = rustls::ClientConfig::builder()
+ .with_safe_defaults()
+ .with_root_certificates(root_store)
+ .with_no_client_auth();
+ cfg.alpn_protocols.push(b"boofar".to_vec());
+ let cfg = Arc::new(cfg);
+
+ let hostname = rustls::ServerName::try_from("localhost").unwrap();
+
+ let tcp_stream = tokio::net::TcpStream::connect("localhost:4505")
+ .await
+ .unwrap();
+ let mut tls_stream =
+ TlsStream::new_client_side(tcp_stream, cfg, hostname);
+
+ tls_stream.handshake().await.unwrap_err();
+
+ let (_, rustls_connection) = tls_stream.get_ref();
+ assert!(rustls_connection.alpn_protocol().is_none());
+
+ let status = child.wait().unwrap();
+ assert!(status.success());
+ })
+ .await;
+}
diff --git a/cli/tests/integration/check_tests.rs b/cli/tests/integration/check_tests.rs
index 5ceaffe51..ab96670ef 100644
--- a/cli/tests/integration/check_tests.rs
+++ b/cli/tests/integration/check_tests.rs
@@ -1,50 +1,52 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
+use std::process::Command;
use std::process::Stdio;
use crate::itest;
use test_util as util;
+use util::TempDir;
itest!(_095_check_with_bare_import {
- args: "check 095_cache_with_bare_import.ts",
- output: "095_cache_with_bare_import.ts.out",
+ args: "check cache/095_cache_with_bare_import.ts",
+ output: "cache/095_cache_with_bare_import.ts.out",
exit_code: 1,
});
itest!(check_extensionless {
args: "check --reload http://localhost:4545/subdir/no_js_ext",
- output: "cache_extensionless.out",
+ output: "cache/cache_extensionless.out",
http_server: true,
});
itest!(check_random_extension {
args: "check --reload http://localhost:4545/subdir/no_js_ext@1.0.0",
- output: "cache_random_extension.out",
+ output: "cache/cache_random_extension.out",
http_server: true,
});
itest!(check_all {
- args: "check --quiet --remote check_all.ts",
- output: "check_all.out",
+ args: "check --quiet --remote check/check_all.ts",
+ output: "check/check_all.out",
http_server: true,
exit_code: 1,
});
itest!(check_all_local {
- args: "check --quiet check_all.ts",
+ args: "check --quiet check/check_all.ts",
output_str: Some(""),
http_server: true,
});
itest!(module_detection_force {
- args: "check --quiet module_detection_force.ts",
+ args: "check --quiet check/module_detection_force/main.ts",
output_str: Some(""),
});
// Regression test for https://github.com/denoland/deno/issues/14937.
itest!(declaration_header_file_with_no_exports {
- args: "check --quiet declaration_header_file_with_no_exports.ts",
+ args: "check --quiet check/declaration_header_file_with_no_exports.ts",
output_str: Some(""),
});
@@ -106,3 +108,91 @@ fn reload_flag() {
stderr.contains("Check")
}
}
+
+#[test]
+fn typecheck_declarations_ns() {
+ let output = util::deno_cmd()
+ .arg("test")
+ .arg("--doc")
+ .arg(util::root_path().join("cli/dts/lib.deno.ns.d.ts"))
+ .output()
+ .unwrap();
+ println!("stdout: {}", String::from_utf8(output.stdout).unwrap());
+ println!("stderr: {}", String::from_utf8(output.stderr).unwrap());
+ assert!(output.status.success());
+}
+
+#[test]
+fn typecheck_declarations_unstable() {
+ let output = util::deno_cmd()
+ .arg("test")
+ .arg("--doc")
+ .arg("--unstable")
+ .arg(util::root_path().join("cli/dts/lib.deno.unstable.d.ts"))
+ .output()
+ .unwrap();
+ println!("stdout: {}", String::from_utf8(output.stdout).unwrap());
+ println!("stderr: {}", String::from_utf8(output.stderr).unwrap());
+ assert!(output.status.success());
+}
+
+#[test]
+fn typecheck_core() {
+ let deno_dir = TempDir::new();
+ let test_file = deno_dir.path().join("test_deno_core_types.ts");
+ std::fs::write(
+ &test_file,
+ format!(
+ "import \"{}\";",
+ deno_core::resolve_path(
+ util::root_path()
+ .join("core/lib.deno_core.d.ts")
+ .to_str()
+ .unwrap()
+ )
+ .unwrap()
+ ),
+ )
+ .unwrap();
+ let output = util::deno_cmd_with_deno_dir(&deno_dir)
+ .arg("run")
+ .arg(test_file.to_str().unwrap())
+ .output()
+ .unwrap();
+ println!("stdout: {}", String::from_utf8(output.stdout).unwrap());
+ println!("stderr: {}", String::from_utf8(output.stderr).unwrap());
+ assert!(output.status.success());
+}
+
+#[test]
+fn ts_no_recheck_on_redirect() {
+ let deno_dir = util::new_deno_dir();
+ let e = util::deno_exe_path();
+
+ let redirect_ts = util::testdata_path().join("run/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::testdata_path())
+ .arg("run")
+ .arg("--check")
+ .arg(redirect_ts.clone())
+ .spawn()
+ .expect("failed to span script");
+ let status_initial =
+ initial.wait().expect("failed to wait for child process");
+ assert!(status_initial.success());
+
+ let mut cmd = Command::new(e);
+ cmd.env("DENO_DIR", deno_dir.path());
+ let output = cmd
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--check")
+ .arg(redirect_ts)
+ .output()
+ .expect("failed to spawn script");
+
+ assert!(std::str::from_utf8(&output.stderr).unwrap().is_empty());
+}
diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs
index 5c9a7f074..dea17e598 100644
--- a/cli/tests/integration/compile_tests.rs
+++ b/cli/tests/integration/compile_tests.rs
@@ -53,7 +53,7 @@ fn standalone_args() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./028_args.ts")
+ .arg("./compile/args.ts")
.arg("a")
.arg("b")
.stdout(std::process::Stdio::piped())
@@ -90,7 +90,7 @@ fn standalone_error() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./standalone_error.ts")
+ .arg("./compile/standalone_error.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -135,7 +135,7 @@ fn standalone_error_module_with_imports() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./standalone_error_module_with_imports_1.ts")
+ .arg("./compile/standalone_error_module_with_imports_1.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -177,7 +177,7 @@ fn standalone_load_datauri() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./standalone_import_datauri.ts")
+ .arg("./compile/standalone_import_datauri.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -210,7 +210,7 @@ fn standalone_follow_redirects() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./standalone_follow_redirects.ts")
+ .arg("./compile/standalone_follow_redirects.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -244,7 +244,7 @@ fn compile_with_file_exists_error() {
.arg("--unstable")
.arg("--output")
.arg(&output_path)
- .arg("./028_args.ts")
+ .arg("./compile/args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -278,7 +278,7 @@ fn compile_with_directory_exists_error() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./028_args.ts")
+ .arg("./compile/args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -312,7 +312,7 @@ fn compile_with_conflict_file_exists_error() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./028_args.ts")
+ .arg("./compile/args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -349,7 +349,7 @@ fn compile_and_overwrite_file() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./028_args.ts")
+ .arg("./compile/args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -364,7 +364,7 @@ fn compile_and_overwrite_file() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./028_args.ts")
+ .arg("./compile/args.ts")
.stderr(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -390,7 +390,7 @@ fn standalone_runtime_flags() {
.arg("1")
.arg("--output")
.arg(&exe)
- .arg("./standalone_runtime_flags.ts")
+ .arg("./compile/standalone_runtime_flags.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -426,10 +426,10 @@ fn standalone_import_map() {
.arg("--unstable")
.arg("--allow-read")
.arg("--import-map")
- .arg("standalone_import_map.json")
+ .arg("compile/standalone_import_map.json")
.arg("--output")
.arg(&exe)
- .arg("./standalone_import_map.ts")
+ .arg("./compile/standalone_import_map.ts")
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap()
@@ -461,7 +461,7 @@ fn skip_rebundle() {
.arg("--unstable")
.arg("--output")
.arg(&exe)
- .arg("./001_hello.js")
+ .arg("./run/001_hello.js")
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.spawn()
@@ -470,7 +470,7 @@ fn skip_rebundle() {
.unwrap();
assert!(output.status.success());
- //no "Bundle testdata_path/001_hello.js" in output
+ //no "Bundle testdata_path/run/001_hello.js" in output
assert!(!String::from_utf8(output.stderr).unwrap().contains("Bundle"));
let output = Command::new(exe)
diff --git a/cli/tests/integration/doc_tests.rs b/cli/tests/integration/doc_tests.rs
index f225eeb2c..4309d9754 100644
--- a/cli/tests/integration/doc_tests.rs
+++ b/cli/tests/integration/doc_tests.rs
@@ -8,7 +8,7 @@ use crate::itest;
itest!(deno_doc_builtin {
args: "doc",
- output: "deno_doc_builtin.out",
+ output: "doc/deno_doc_builtin.out",
});
#[test]
@@ -19,7 +19,7 @@ fn deno_doc() {
let output = util::deno_cmd_with_deno_dir(&dir)
.current_dir(util::testdata_path())
.arg("doc")
- .arg("deno_doc.ts")
+ .arg("doc/deno_doc.ts")
.env("NO_COLOR", "1")
.stdout(std::process::Stdio::piped())
.spawn()
@@ -56,8 +56,9 @@ itest!(deno_doc_types_header {
});
itest!(_060_deno_doc_displays_all_overloads_in_details_view {
- args: "doc 060_deno_doc_displays_all_overloads_in_details_view.ts NS.test",
- output: "060_deno_doc_displays_all_overloads_in_details_view.ts.out",
+ args:
+ "doc doc/060_deno_doc_displays_all_overloads_in_details_view.ts NS.test",
+ output: "doc/060_deno_doc_displays_all_overloads_in_details_view.ts.out",
});
itest!(deno_doc_types_header_direct {
diff --git a/cli/tests/integration/eval_tests.rs b/cli/tests/integration/eval_tests.rs
index 892ca7ffd..2d560812e 100644
--- a/cli/tests/integration/eval_tests.rs
+++ b/cli/tests/integration/eval_tests.rs
@@ -44,27 +44,27 @@ fn eval_randomness() {
assert!(numbers.len() > 1);
}
-itest!(_029_eval {
+itest!(eval_basic {
args: "eval console.log(\"hello\")",
- output: "029_eval.out",
+ output_str: Some("hello\n"),
});
// Ugly parentheses due to whitespace delimiting problem.
-itest!(_030_eval_ts {
+itest!(eval_ts {
args: "eval --quiet --ext=ts console.log((123)as(number))", // 'as' is a TS keyword only
- output: "030_eval_ts.out",
+ output_str: Some("123\n"),
});
-itest!(_041_dyn_import_eval {
+itest!(dyn_import_eval {
args: "eval import('./subdir/mod4.js').then(console.log)",
- output: "041_dyn_import_eval.out",
+ output: "eval/dyn_import_eval.out",
});
// Cannot write the expression to evaluate as "console.log(typeof gc)"
// because itest! splits args on whitespace.
itest!(v8_flags_eval {
args: "eval --v8-flags=--expose-gc console.log(typeof(gc))",
- output: "v8_flags.js.out",
+ output: "run/v8_flags.js.out",
});
itest!(check_local_by_default {
diff --git a/cli/tests/integration/flags_tests.rs b/cli/tests/integration/flags_tests.rs
new file mode 100644
index 000000000..5e3814e22
--- /dev/null
+++ b/cli/tests/integration/flags_tests.rs
@@ -0,0 +1,45 @@
+// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
+
+use crate::itest;
+use test_util as util;
+
+#[test]
+fn help_flag() {
+ let status = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("--help")
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+ assert!(status.success());
+}
+
+#[test]
+fn version_short_flag() {
+ let status = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("-V")
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+ assert!(status.success());
+}
+
+#[test]
+fn version_long_flag() {
+ let status = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("--version")
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+ assert!(status.success());
+}
+
+itest!(types {
+ args: "types",
+ output: "types/types.out",
+});
diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs
index 048e9aa21..53b45de19 100644
--- a/cli/tests/integration/fmt_tests.rs
+++ b/cli/tests/integration/fmt_tests.rs
@@ -7,29 +7,29 @@ use test_util::TempDir;
#[test]
fn fmt_test() {
let t = TempDir::new();
- let fixed_js = util::testdata_path().join("badly_formatted_fixed.js");
+ let testdata_fmt_dir = util::testdata_path().join("fmt");
+ let fixed_js = testdata_fmt_dir.join("badly_formatted_fixed.js");
let badly_formatted_original_js =
- util::testdata_path().join("badly_formatted.mjs");
+ testdata_fmt_dir.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).unwrap();
- let fixed_md = util::testdata_path().join("badly_formatted_fixed.md");
- let badly_formatted_original_md =
- util::testdata_path().join("badly_formatted.md");
+ let fixed_md = testdata_fmt_dir.join("badly_formatted_fixed.md");
+ let badly_formatted_original_md = testdata_fmt_dir.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).unwrap();
- let fixed_json = util::testdata_path().join("badly_formatted_fixed.json");
+ let fixed_json = testdata_fmt_dir.join("badly_formatted_fixed.json");
let badly_formatted_original_json =
- util::testdata_path().join("badly_formatted.json");
+ testdata_fmt_dir.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).unwrap();
// First, check formatting by ignoring the badly formatted file.
let status = util::deno_cmd()
- .current_dir(util::testdata_path())
+ .current_dir(&testdata_fmt_dir)
.arg("fmt")
.arg(format!(
"--ignore={},{},{}",
@@ -48,7 +48,7 @@ fn fmt_test() {
// Check without ignore.
let status = util::deno_cmd()
- .current_dir(util::testdata_path())
+ .current_dir(&testdata_fmt_dir)
.arg("fmt")
.arg("--check")
.arg(badly_formatted_js_str)
@@ -62,7 +62,7 @@ fn fmt_test() {
// Format the source file.
let status = util::deno_cmd()
- .current_dir(util::testdata_path())
+ .current_dir(&testdata_fmt_dir)
.arg("fmt")
.arg(badly_formatted_js_str)
.arg(badly_formatted_md_str)
diff --git a/cli/tests/integration/info_tests.rs b/cli/tests/integration/info_tests.rs
index aa678cb6d..0cb875078 100644
--- a/cli/tests/integration/info_tests.rs
+++ b/cli/tests/integration/info_tests.rs
@@ -8,7 +8,7 @@ use test_util::TempDir;
#[test]
fn info_with_compiled_source() {
let _g = util::http_server();
- let module_path = "http://127.0.0.1:4545/048_media_types_jsx.ts";
+ let module_path = "http://127.0.0.1:4545/run/048_media_types_jsx.ts";
let t = TempDir::new();
let mut deno = util::deno_cmd()
@@ -37,79 +37,79 @@ fn info_with_compiled_source() {
assert_eq!(output.stderr, b"");
}
-itest!(_022_info_flag_script {
- args: "info http://127.0.0.1:4545/019_media_types.ts",
- output: "022_info_flag_script.out",
+itest!(multiple_imports {
+ args: "info http://127.0.0.1:4545/run/019_media_types.ts",
+ output: "info/multiple_imports.out",
http_server: true,
});
-itest!(_031_info_ts_error {
- args: "info 031_info_ts_error.ts",
- output: "031_info_ts_error.out",
+itest!(info_ts_error {
+ args: "info info/031_info_ts_error.ts",
+ output: "info/031_info_ts_error.out",
});
-itest!(_041_info_flag {
+itest!(info_flag {
args: "info",
- output: "041_info_flag.out",
+ output: "info/041_info_flag.out",
});
-itest!(_042_info_flag_location {
+itest!(info_flag_location {
args: "info --location https://deno.land",
- output: "041_info_flag_location.out",
+ output: "info/041_info_flag_location.out",
});
itest!(info_json {
args: "info --json --unstable",
- output: "info_json.out",
+ output: "info/info_json.out",
});
itest!(info_json_location {
args: "info --json --unstable --location https://deno.land",
- output: "info_json_location.out",
+ output: "info/info_json_location.out",
});
-itest!(_049_info_flag_script_jsx {
- args: "info http://127.0.0.1:4545/048_media_types_jsx.ts",
- output: "049_info_flag_script_jsx.out",
+itest!(info_flag_script_jsx {
+ args: "info http://127.0.0.1:4545/run/048_media_types_jsx.ts",
+ output: "info/049_info_flag_script_jsx.out",
http_server: true,
});
-itest!(_055_info_file_json {
- args: "info --quiet --json --unstable 005_more_imports.ts",
- output: "055_info_file_json.out",
+itest!(json_file {
+ args: "info --quiet --json --unstable info/json_output/main.ts",
+ output: "info/json_output/main.out",
exit_code: 0,
});
-itest!(_065_import_map_info {
+itest!(import_map_info {
args:
"info --quiet --import-map=import_maps/import_map.json import_maps/test.ts",
- output: "065_import_map_info.out",
+ output: "info/065_import_map_info.out",
});
-itest!(_076_info_json_deps_order {
- args: "info --unstable --json 076_info_json_deps_order.ts",
- output: "076_info_json_deps_order.out",
+itest!(info_json_deps_order {
+ args: "info --unstable --json info/076_info_json_deps_order.ts",
+ output: "info/076_info_json_deps_order.out",
});
itest!(info_missing_module {
- args: "info error_009_missing_js_module.js",
- output: "info_missing_module.out",
+ args: "info info/error_009_missing_js_module.js",
+ output: "info/info_missing_module.out",
});
itest!(info_recursive_modules {
- args: "info --quiet info_recursive_imports_test.ts",
- output: "info_recursive_imports_test.out",
+ args: "info --quiet info/info_recursive_imports_test.ts",
+ output: "info/info_recursive_imports_test.out",
exit_code: 0,
});
itest!(info_type_import {
- args: "info info_type_import.ts",
- output: "info_type_import.out",
+ args: "info info/info_type_import.ts",
+ output: "info/info_type_import.out",
});
itest!(_054_info_local_imports {
- args: "info --quiet 005_more_imports.ts",
- output: "054_info_local_imports.out",
+ args: "info --quiet run/005_more_imports.ts",
+ output: "info/054_info_local_imports.out",
exit_code: 0,
});
@@ -120,13 +120,13 @@ itest!(data_null_error {
output: "info/data_null_error/data_null_error.out",
});
-itest!(deno_info_types_header_direct {
- args: "info --reload type_directives_01.ts",
+itest!(types_header_direct {
+ args: "info --reload run/type_directives_01.ts",
output: "info/types_header.out",
http_server: true,
});
-itest!(deno_info_with_config_override {
+itest!(with_config_override {
args: "info info/with_config/test.ts --config info/with_config/deno-override.json --import-map info/with_config/import_map.json",
output: "info/with_config/with_config.out",
});
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 7e75e852b..d49a8a814 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -4107,8 +4107,8 @@ fn lsp_diagnostics_warn_redirect() {
severity: Some(lsp::DiagnosticSeverity::INFORMATION),
code: Some(lsp::NumberOrString::String("redirect".to_string())),
source: Some("deno".to_string()),
- message: "The import of \"http://127.0.0.1:4545/x_deno_warning.js\" was redirected to \"http://127.0.0.1:4545/x_deno_warning_redirect.js\".".to_string(),
- data: Some(json!({"specifier": "http://127.0.0.1:4545/x_deno_warning.js", "redirect": "http://127.0.0.1:4545/x_deno_warning_redirect.js"})),
+ message: "The import of \"http://127.0.0.1:4545/x_deno_warning.js\" was redirected to \"http://127.0.0.1:4545/lsp/x_deno_warning_redirect.js\".".to_string(),
+ data: Some(json!({"specifier": "http://127.0.0.1:4545/x_deno_warning.js", "redirect": "http://127.0.0.1:4545/lsp/x_deno_warning_redirect.js"})),
..Default::default()
}
],
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index 143bda819..373d04e70 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -1,22 +1,6 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-use crate::itest;
-use deno_core::url;
-use deno_runtime::deno_fetch::reqwest;
-use deno_runtime::deno_net::ops_tls::TlsStream;
-use deno_runtime::deno_tls::rustls;
-use deno_runtime::deno_tls::rustls_pemfile;
-use std::fs;
-use std::io::BufReader;
-use std::io::Cursor;
-use std::io::{Read, Write};
-use std::process::Command;
-use std::sync::Arc;
use test_util as util;
-use test_util::TempDir;
-use tokio::task::LocalSet;
-use trust_dns_client::serialize::txt::Lexer;
-use trust_dns_client::serialize::txt::Parser;
#[macro_export]
macro_rules! itest(
@@ -58,6 +42,8 @@ mod bench;
mod bundle;
#[path = "cache_tests.rs"]
mod cache;
+#[path = "cert_tests.rs"]
+mod cert;
#[path = "check_tests.rs"]
mod check;
#[path = "compile_tests.rs"]
@@ -68,6 +54,8 @@ mod coverage;
mod doc;
#[path = "eval_tests.rs"]
mod eval;
+#[path = "flags_tests.rs"]
+mod flags;
#[path = "fmt_tests.rs"]
mod fmt;
#[path = "info_tests.rs"]
@@ -102,917 +90,6 @@ mod watcher;
mod worker;
#[test]
-fn help_flag() {
- let status = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("--help")
- .spawn()
- .unwrap()
- .wait()
- .unwrap();
- assert!(status.success());
-}
-
-#[test]
-fn version_short_flag() {
- let status = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("-V")
- .spawn()
- .unwrap()
- .wait()
- .unwrap();
- assert!(status.success());
-}
-
-#[test]
-fn version_long_flag() {
- let status = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("--version")
- .spawn()
- .unwrap()
- .wait()
- .unwrap();
- assert!(status.success());
-}
-
-itest!(types {
- args: "types",
- output: "types.out",
-});
-
-#[test]
-fn cache_test() {
- let _g = util::http_server();
- let deno_dir = TempDir::new();
- let module_url =
- 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::testdata_path())
- .arg("cache")
- .arg("--check=all")
- .arg("-L")
- .arg("debug")
- .arg(module_url.to_string())
- .output()
- .expect("Failed to spawn script");
- assert!(output.status.success());
-
- let prg = util::deno_exe_path();
- let output = Command::new(&prg)
- .env("DENO_DIR", deno_dir.path())
- .env("HTTP_PROXY", "http://nil")
- .env("NO_COLOR", "1")
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(module_url.to_string())
- .output()
- .expect("Failed to spawn script");
-
- let str_output = std::str::from_utf8(&output.stdout).unwrap();
-
- 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
- .read_to_string(&mut module_output)
- .unwrap();
-
- assert_eq!(module_output, str_output);
-}
-
-#[test]
-fn cache_invalidation_test() {
- let deno_dir = TempDir::new();
- let fixture_path = deno_dir.path().join("fixture.ts");
- {
- let mut file = std::fs::File::create(fixture_path.clone())
- .expect("could not create fixture");
- file
- .write_all(b"console.log(\"42\");")
- .expect("could not write fixture");
- }
- let output = Command::new(util::deno_exe_path())
- .env("DENO_DIR", deno_dir.path())
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(fixture_path.to_str().unwrap())
- .output()
- .expect("Failed to spawn script");
- assert!(output.status.success());
- let actual = std::str::from_utf8(&output.stdout).unwrap();
- assert_eq!(actual, "42\n");
- {
- let mut file = std::fs::File::create(fixture_path.clone())
- .expect("could not create fixture");
- file
- .write_all(b"console.log(\"43\");")
- .expect("could not write fixture");
- }
- let output = Command::new(util::deno_exe_path())
- .env("DENO_DIR", deno_dir.path())
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(fixture_path.to_str().unwrap())
- .output()
- .expect("Failed to spawn script");
- assert!(output.status.success());
- let actual = std::str::from_utf8(&output.stdout).unwrap();
- assert_eq!(actual, "43\n");
-}
-
-#[test]
-fn cache_invalidation_test_no_check() {
- let deno_dir = TempDir::new();
- let fixture_path = deno_dir.path().join("fixture.ts");
- {
- let mut file = std::fs::File::create(fixture_path.clone())
- .expect("could not create fixture");
- file
- .write_all(b"console.log(\"42\");")
- .expect("could not write fixture");
- }
- let output = Command::new(util::deno_exe_path())
- .env("DENO_DIR", deno_dir.path())
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--no-check")
- .arg(fixture_path.to_str().unwrap())
- .output()
- .expect("Failed to spawn script");
- assert!(output.status.success());
- let actual = std::str::from_utf8(&output.stdout).unwrap();
- assert_eq!(actual, "42\n");
- {
- let mut file = std::fs::File::create(fixture_path.clone())
- .expect("could not create fixture");
- file
- .write_all(b"console.log(\"43\");")
- .expect("could not write fixture");
- }
- let output = Command::new(util::deno_exe_path())
- .env("DENO_DIR", deno_dir.path())
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--no-check")
- .arg(fixture_path.to_str().unwrap())
- .output()
- .expect("Failed to spawn script");
- assert!(output.status.success());
- let actual = std::str::from_utf8(&output.stdout).unwrap();
- assert_eq!(actual, "43\n");
-}
-
-#[test]
-fn ts_dependency_recompilation() {
- let t = TempDir::new();
- let ats = t.path().join("a.ts");
-
- std::fs::write(
- &ats,
- "
- import { foo } from \"./b.ts\";
-
- function print(str: string): void {
- console.log(str);
- }
-
- print(foo);",
- )
- .unwrap();
-
- let bts = t.path().join("b.ts");
- std::fs::write(
- &bts,
- "
- export const foo = \"foo\";",
- )
- .unwrap();
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .env("NO_COLOR", "1")
- .arg("run")
- .arg("--check")
- .arg(&ats)
- .output()
- .expect("failed to spawn script");
-
- let stdout_output = std::str::from_utf8(&output.stdout).unwrap().trim();
- let stderr_output = std::str::from_utf8(&output.stderr).unwrap().trim();
-
- assert!(stdout_output.ends_with("foo"));
- assert!(stderr_output.starts_with("Check"));
-
- // Overwrite contents of b.ts and run again
- std::fs::write(
- &bts,
- "
- export const foo = 5;",
- )
- .expect("error writing file");
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .env("NO_COLOR", "1")
- .arg("run")
- .arg("--check")
- .arg(&ats)
- .output()
- .expect("failed to spawn script");
-
- let stdout_output = std::str::from_utf8(&output.stdout).unwrap().trim();
- let stderr_output = std::str::from_utf8(&output.stderr).unwrap().trim();
-
- // error: TS2345 [ERROR]: Argument of type '5' is not assignable to parameter of type 'string'.
- assert!(stderr_output.contains("TS2345"));
- assert!(!output.status.success());
- assert!(stdout_output.is_empty());
-}
-
-#[test]
-fn ts_no_recheck_on_redirect() {
- let deno_dir = util::new_deno_dir();
- let e = util::deno_exe_path();
-
- 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::testdata_path())
- .arg("run")
- .arg("--check")
- .arg(redirect_ts.clone())
- .spawn()
- .expect("failed to span script");
- let status_initial =
- initial.wait().expect("failed to wait for child process");
- assert!(status_initial.success());
-
- let mut cmd = Command::new(e);
- cmd.env("DENO_DIR", deno_dir.path());
- let output = cmd
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--check")
- .arg(redirect_ts)
- .output()
- .expect("failed to spawn script");
-
- assert!(std::str::from_utf8(&output.stderr).unwrap().is_empty());
-}
-
-#[test]
-fn timeout_clear() {
- // https://github.com/denoland/deno/issues/7599
-
- use std::time::Duration;
- use std::time::Instant;
-
- let source_code = r#"
-const handle = setTimeout(() => {
- console.log("timeout finish");
-}, 10000);
-clearTimeout(handle);
-console.log("finish");
-"#;
-
- let mut p = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("-")
- .stdin(std::process::Stdio::piped())
- .spawn()
- .unwrap();
- let stdin = p.stdin.as_mut().unwrap();
- stdin.write_all(source_code.as_bytes()).unwrap();
- let start = Instant::now();
- let status = p.wait().unwrap();
- let end = Instant::now();
- assert!(status.success());
- // check that program did not run for 10 seconds
- // for timeout to clear
- assert!(end - start < Duration::new(10, 0));
-}
-
-#[test]
-fn broken_stdout() {
- let (reader, writer) = os_pipe::pipe().unwrap();
- // drop the reader to create a broken pipe
- drop(reader);
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("eval")
- .arg("console.log(3.14)")
- .stdout(writer)
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
-
- assert!(!output.status.success());
- let stderr = std::str::from_utf8(output.stderr.as_ref()).unwrap().trim();
- assert!(stderr.contains("Uncaught BrokenPipe"));
- assert!(!stderr.contains("panic"));
-}
-
-itest!(error_cause {
- args: "run error_cause.ts",
- output: "error_cause.ts.out",
- exit_code: 1,
-});
-
-itest!(error_cause_recursive {
- args: "run error_cause_recursive.ts",
- output: "error_cause_recursive.ts.out",
- exit_code: 1,
-});
-
-itest_flaky!(cafile_url_imports {
- args: "run --quiet --reload --cert tls/RootCA.pem cafile_url_imports.ts",
- output: "cafile_url_imports.ts.out",
- http_server: true,
-});
-
-itest_flaky!(cafile_ts_fetch {
- args:
- "run --quiet --reload --allow-net --cert tls/RootCA.pem cafile_ts_fetch.ts",
- output: "cafile_ts_fetch.ts.out",
- http_server: true,
-});
-
-itest_flaky!(cafile_eval {
- 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_flaky!(cafile_info {
- args:
- "info --quiet --cert tls/RootCA.pem https://localhost:5545/cafile_info.ts",
- output: "cafile_info.ts.out",
- http_server: true,
-});
-
-itest_flaky!(cafile_url_imports_unsafe_ssl {
- args: "run --quiet --reload --unsafely-ignore-certificate-errors=localhost cafile_url_imports.ts",
- output: "cafile_url_imports_unsafe_ssl.ts.out",
- http_server: true,
-});
-
-itest_flaky!(cafile_ts_fetch_unsafe_ssl {
- args:
- "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors cafile_ts_fetch.ts",
- output: "cafile_ts_fetch_unsafe_ssl.ts.out",
- http_server: true,
-});
-
-itest!(deno_land_unsafe_ssl {
- args:
- "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors=deno.land deno_land_unsafe_ssl.ts",
- output: "deno_land_unsafe_ssl.ts.out",
-});
-
-itest!(ip_address_unsafe_ssl {
- args:
- "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors=1.1.1.1 ip_address_unsafe_ssl.ts",
- output: "ip_address_unsafe_ssl.ts.out",
-});
-
-itest!(localhost_unsafe_ssl {
- args:
- "run --quiet --reload --allow-net --unsafely-ignore-certificate-errors=deno.land cafile_url_imports.ts",
- output: "localhost_unsafe_ssl.ts.out",
- http_server: true,
- exit_code: 1,
-});
-
-#[flaky_test::flaky_test]
-fn cafile_env_fetch() {
- use deno_core::url::Url;
- let _g = util::http_server();
- let deno_dir = TempDir::new();
- let module_url =
- 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::testdata_path())
- .arg("cache")
- .arg(module_url.to_string())
- .output()
- .expect("Failed to spawn script");
- assert!(output.status.success());
-}
-
-#[flaky_test::flaky_test]
-fn cafile_fetch() {
- use deno_core::url::Url;
- let _g = util::http_server();
- let deno_dir = TempDir::new();
- let module_url =
- 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::testdata_path())
- .arg("cache")
- .arg("--cert")
- .arg(cafile)
- .arg(module_url.to_string())
- .output()
- .expect("Failed to spawn script");
- assert!(output.status.success());
- let out = std::str::from_utf8(&output.stdout).unwrap();
- assert_eq!(out, "");
-}
-
-#[flaky_test::flaky_test]
-fn cafile_install_remote_module() {
- let _g = util::http_server();
- let temp_dir = TempDir::new();
- let bin_dir = temp_dir.path().join("bin");
- std::fs::create_dir(&bin_dir).unwrap();
- let deno_dir = TempDir::new();
- 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::testdata_path())
- .arg("install")
- .arg("--cert")
- .arg(cafile)
- .arg("--root")
- .arg(temp_dir.path())
- .arg("-n")
- .arg("echo_test")
- .arg("https://localhost:5545/echo.ts")
- .output()
- .expect("Failed to spawn script");
- println!("{}", std::str::from_utf8(&install_output.stdout).unwrap());
- eprintln!("{}", std::str::from_utf8(&install_output.stderr).unwrap());
- assert!(install_output.status.success());
-
- let mut echo_test_path = bin_dir.join("echo_test");
- if cfg!(windows) {
- echo_test_path = echo_test_path.with_extension("cmd");
- }
- assert!(echo_test_path.exists());
-
- let output = Command::new(echo_test_path)
- .current_dir(temp_dir.path())
- .arg("foo")
- .env("PATH", util::target_dir())
- .output()
- .expect("failed to spawn script");
- let stdout = std::str::from_utf8(&output.stdout).unwrap().trim();
- assert!(stdout.ends_with("foo"));
-}
-
-#[flaky_test::flaky_test]
-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/subdir/mod1.ts";
- let cafile = util::testdata_path().join("tls/RootCA.pem");
- let t = TempDir::new();
- let bundle = t.path().join("mod1.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg("--cert")
- .arg(cafile)
- .arg(mod1)
- .arg(&bundle)
- .spawn()
- .expect("failed to spawn script");
- let status = deno.wait().expect("failed to wait for the child process");
- assert!(status.success());
- assert!(bundle.is_file());
-
- // Now we try to use that bundle from another module.
- let test = t.path().join("test.js");
- std::fs::write(
- &test,
- "
- import { printHello3 } from \"./mod1.bundle.js\";
- printHello3(); ",
- )
- .expect("error writing file");
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--check")
- .arg(&test)
- .output()
- .expect("failed to spawn script");
- // check the output of the test.ts program.
- assert!(std::str::from_utf8(&output.stdout)
- .unwrap()
- .trim()
- .ends_with("Hello"));
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn websocket() {
- let _g = util::http_server();
-
- 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")
- .arg("--allow-net")
- .arg("--cert")
- .arg(root_ca)
- .arg(script)
- .spawn()
- .unwrap()
- .wait()
- .unwrap();
-
- assert!(status.success());
-}
-
-#[test]
-fn websocketstream() {
- let _g = util::http_server();
-
- 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")
- .arg("--allow-net")
- .arg("--cert")
- .arg(root_ca)
- .arg(script)
- .spawn()
- .unwrap()
- .wait()
- .unwrap();
-
- assert!(status.success());
-}
-
-#[test]
-fn websocketstream_ping() {
- use deno_runtime::deno_websocket::tokio_tungstenite::tungstenite;
- let _g = util::http_server();
-
- let script = util::testdata_path().join("websocketstream_ping_test.ts");
- let root_ca = util::testdata_path().join("tls/RootCA.pem");
- let mut child = util::deno_cmd()
- .arg("test")
- .arg("--unstable")
- .arg("--allow-net")
- .arg("--cert")
- .arg(root_ca)
- .arg(script)
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap();
-
- let server = std::net::TcpListener::bind("127.0.0.1:4513").unwrap();
- let (stream, _) = server.accept().unwrap();
- let mut socket = tungstenite::accept(stream).unwrap();
- socket
- .write_message(tungstenite::Message::Text(String::from("A")))
- .unwrap();
- socket
- .write_message(tungstenite::Message::Ping(vec![]))
- .unwrap();
- socket
- .write_message(tungstenite::Message::Text(String::from("B")))
- .unwrap();
- let message = socket.read_message().unwrap();
- assert_eq!(message, tungstenite::Message::Pong(vec![]));
- socket
- .write_message(tungstenite::Message::Text(String::from("C")))
- .unwrap();
- socket.close(None).unwrap();
-
- assert!(child.wait().unwrap().success());
-}
-
-#[test]
-fn websocket_server_multi_field_connection_header() {
- let script = util::testdata_path()
- .join("websocket_server_multi_field_connection_header_test.ts");
- let root_ca = util::testdata_path().join("tls/RootCA.pem");
- let mut child = util::deno_cmd()
- .arg("run")
- .arg("--unstable")
- .arg("--allow-net")
- .arg("--cert")
- .arg(root_ca)
- .arg(script)
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap();
-
- let stdout = child.stdout.as_mut().unwrap();
- let mut buffer = [0; 5];
- let read = stdout.read(&mut buffer).unwrap();
- assert_eq!(read, 5);
- let msg = std::str::from_utf8(&buffer).unwrap();
- assert_eq!(msg, "READY");
-
- let req = http::request::Builder::new()
- .header(http::header::CONNECTION, "keep-alive, Upgrade")
- .uri("ws://localhost:4319")
- .body(())
- .unwrap();
- let (mut socket, _) =
- deno_runtime::deno_websocket::tokio_tungstenite::tungstenite::connect(req)
- .unwrap();
- let message = socket.read_message().unwrap();
- assert_eq!(message, deno_runtime::deno_websocket::tokio_tungstenite::tungstenite::Message::Close(None));
- socket.close(None).unwrap();
- assert!(child.wait().unwrap().success());
-}
-
-// TODO(bartlomieju): this should use `deno run`, not `deno test`; but the
-// test hangs then. https://github.com/denoland/deno/issues/14283
-#[test]
-#[ignore]
-fn websocket_server_idletimeout() {
- let script = util::testdata_path().join("websocket_server_idletimeout.ts");
- let root_ca = util::testdata_path().join("tls/RootCA.pem");
- let mut child = util::deno_cmd()
- .arg("test")
- .arg("--unstable")
- .arg("--allow-net")
- .arg("--cert")
- .arg(root_ca)
- .arg(script)
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap();
-
- let stdout = child.stdout.as_mut().unwrap();
- let mut buffer = [0; 5];
- let read = stdout.read(&mut buffer).unwrap();
- assert_eq!(read, 5);
- let msg = std::str::from_utf8(&buffer).unwrap();
- assert_eq!(msg, "READY");
-
- let req = http::request::Builder::new()
- .uri("ws://localhost:4509")
- .body(())
- .unwrap();
- let (_ws, _request) =
- deno_runtime::deno_websocket::tokio_tungstenite::tungstenite::connect(req)
- .unwrap();
-
- assert!(child.wait().unwrap().success());
-}
-
-#[cfg(not(windows))]
-#[test]
-fn set_raw_should_not_panic_on_no_tty() {
- let output = util::deno_cmd()
- .arg("eval")
- .arg("--unstable")
- .arg("Deno.setRaw(Deno.stdin.rid, true)")
- // stdin set to piped so it certainly does not refer to TTY
- .stdin(std::process::Stdio::piped())
- // stderr is piped so we can capture output.
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
- assert!(!output.status.success());
- let stderr = std::str::from_utf8(&output.stderr).unwrap().trim();
- assert!(stderr.contains("BadResource"));
-}
-
-#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
-async fn test_resolve_dns() {
- use std::net::SocketAddr;
- use std::str::FromStr;
- use std::sync::Arc;
- use std::time::Duration;
- use tokio::net::TcpListener;
- use tokio::net::UdpSocket;
- use tokio::sync::oneshot;
- use trust_dns_server::authority::Catalog;
- use trust_dns_server::authority::ZoneType;
- use trust_dns_server::proto::rr::Name;
- use trust_dns_server::store::in_memory::InMemoryAuthority;
- use trust_dns_server::ServerFuture;
-
- const DNS_PORT: u16 = 4553;
-
- // Setup DNS server for testing
- async fn run_dns_server(tx: oneshot::Sender<()>) {
- let zone_file =
- fs::read_to_string(util::testdata_path().join("resolve_dns.zone.in"))
- .unwrap();
- let lexer = Lexer::new(&zone_file);
- let records = Parser::new().parse(
- lexer,
- Some(Name::from_str("example.com").unwrap()),
- None,
- );
- if records.is_err() {
- panic!("failed to parse: {:?}", records.err())
- }
- let (origin, records) = records.unwrap();
- let authority = Box::new(Arc::new(
- InMemoryAuthority::new(origin, records, ZoneType::Primary, false)
- .unwrap(),
- ));
- let mut catalog: Catalog = Catalog::new();
- catalog.upsert(Name::root().into(), authority);
-
- let mut server_fut = ServerFuture::new(catalog);
- let socket_addr = SocketAddr::from(([127, 0, 0, 1], DNS_PORT));
- let tcp_listener = TcpListener::bind(socket_addr).await.unwrap();
- let udp_socket = UdpSocket::bind(socket_addr).await.unwrap();
- server_fut.register_socket(udp_socket);
- server_fut.register_listener(tcp_listener, Duration::from_secs(2));
-
- // Notifies that the DNS server is ready
- tx.send(()).unwrap();
-
- server_fut.block_until_done().await.unwrap();
- }
-
- let (ready_tx, ready_rx) = oneshot::channel();
- let dns_server_fut = run_dns_server(ready_tx);
- let handle = tokio::spawn(dns_server_fut);
-
- // Waits for the DNS server to be ready
- ready_rx.await.unwrap();
-
- // Pass: `--allow-net`
- {
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .env("NO_COLOR", "1")
- .arg("run")
- .arg("--check")
- .arg("--allow-net")
- .arg("resolve_dns.ts")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
- let err = String::from_utf8_lossy(&output.stderr);
- let out = String::from_utf8_lossy(&output.stdout);
- println!("{}", err);
- assert!(output.status.success());
- assert!(err.starts_with("Check file"));
-
- let expected =
- std::fs::read_to_string(util::testdata_path().join("resolve_dns.ts.out"))
- .unwrap();
- assert_eq!(expected, out);
- }
-
- // Pass: `--allow-net=127.0.0.1:4553`
- {
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .env("NO_COLOR", "1")
- .arg("run")
- .arg("--check")
- .arg("--allow-net=127.0.0.1:4553")
- .arg("resolve_dns.ts")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
- let err = String::from_utf8_lossy(&output.stderr);
- let out = String::from_utf8_lossy(&output.stdout);
- assert!(output.status.success());
- assert!(err.starts_with("Check file"));
-
- let expected =
- std::fs::read_to_string(util::testdata_path().join("resolve_dns.ts.out"))
- .unwrap();
- assert_eq!(expected, out);
- }
-
- // Permission error: `--allow-net=deno.land`
- {
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .env("NO_COLOR", "1")
- .arg("run")
- .arg("--check")
- .arg("--allow-net=deno.land")
- .arg("resolve_dns.ts")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
- let err = String::from_utf8_lossy(&output.stderr);
- let out = String::from_utf8_lossy(&output.stdout);
- assert!(!output.status.success());
- assert!(err.starts_with("Check file"));
- assert!(err.contains(r#"error: Uncaught PermissionDenied: Requires net access to "127.0.0.1:4553""#));
- assert!(out.is_empty());
- }
-
- // Permission error: no permission specified
- {
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .env("NO_COLOR", "1")
- .arg("run")
- .arg("--check")
- .arg("resolve_dns.ts")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
- let err = String::from_utf8_lossy(&output.stderr);
- let out = String::from_utf8_lossy(&output.stdout);
- assert!(!output.status.success());
- assert!(err.starts_with("Check file"));
- assert!(err.contains(r#"error: Uncaught PermissionDenied: Requires net access to "127.0.0.1:4553""#));
- assert!(out.is_empty());
- }
-
- handle.abort();
-}
-
-#[test]
-fn typecheck_declarations_ns() {
- let output = util::deno_cmd()
- .arg("test")
- .arg("--doc")
- .arg(util::root_path().join("cli/dts/lib.deno.ns.d.ts"))
- .output()
- .unwrap();
- println!("stdout: {}", String::from_utf8(output.stdout).unwrap());
- println!("stderr: {}", String::from_utf8(output.stderr).unwrap());
- assert!(output.status.success());
-}
-
-#[test]
-fn typecheck_declarations_unstable() {
- let output = util::deno_cmd()
- .arg("test")
- .arg("--doc")
- .arg("--unstable")
- .arg(util::root_path().join("cli/dts/lib.deno.unstable.d.ts"))
- .output()
- .unwrap();
- println!("stdout: {}", String::from_utf8(output.stdout).unwrap());
- println!("stderr: {}", String::from_utf8(output.stderr).unwrap());
- assert!(output.status.success());
-}
-
-#[test]
-fn typecheck_core() {
- let deno_dir = TempDir::new();
- let test_file = deno_dir.path().join("test_deno_core_types.ts");
- std::fs::write(
- &test_file,
- format!(
- "import \"{}\";",
- deno_core::resolve_path(
- util::root_path()
- .join("core/lib.deno_core.d.ts")
- .to_str()
- .unwrap()
- )
- .unwrap()
- ),
- )
- .unwrap();
- let output = util::deno_cmd_with_deno_dir(&deno_dir)
- .arg("run")
- .arg(test_file.to_str().unwrap())
- .output()
- .unwrap();
- println!("stdout: {}", String::from_utf8(output.stdout).unwrap());
- println!("stderr: {}", String::from_utf8(output.stderr).unwrap());
- assert!(output.status.success());
-}
-
-#[test]
fn js_unit_tests_lint() {
let status = util::deno_cmd()
.arg("lint")
@@ -1047,211 +124,3 @@ fn js_unit_tests() {
assert_eq!(Some(0), status.code());
assert!(status.success());
}
-
-#[test]
-fn basic_auth_tokens() {
- let _g = util::http_server();
-
- let output = util::deno_cmd()
- .current_dir(util::root_path())
- .arg("run")
- .arg("http://127.0.0.1:4554/001_hello.js")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
-
- assert!(!output.status.success());
-
- let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
- assert!(stdout_str.is_empty());
-
- let stderr_str = std::str::from_utf8(&output.stderr).unwrap().trim();
- eprintln!("{}", stderr_str);
-
- assert!(stderr_str
- .contains("Module not found \"http://127.0.0.1:4554/001_hello.js\"."));
-
- let output = util::deno_cmd()
- .current_dir(util::root_path())
- .arg("run")
- .arg("http://127.0.0.1:4554/001_hello.js")
- .env("DENO_AUTH_TOKENS", "testuser123:testpassabc@127.0.0.1:4554")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
-
- let stderr_str = std::str::from_utf8(&output.stderr).unwrap().trim();
- eprintln!("{}", stderr_str);
-
- assert!(output.status.success());
-
- let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
- assert_eq!(util::strip_ansi_codes(stdout_str), "Hello World");
-}
-
-#[tokio::test]
-async fn listen_tls_alpn() {
- // TLS streams require the presence of an ambient local task set to gracefully
- // close dropped connections in the background.
- LocalSet::new()
- .run_until(async {
- let mut child = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--unstable")
- .arg("--quiet")
- .arg("--allow-net")
- .arg("--allow-read")
- .arg("./listen_tls_alpn.ts")
- .arg("4504")
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap();
- let stdout = child.stdout.as_mut().unwrap();
- let mut msg = [0; 5];
- let read = stdout.read(&mut msg).unwrap();
- assert_eq!(read, 5);
- assert_eq!(&msg, b"READY");
-
- let mut reader = &mut BufReader::new(Cursor::new(include_bytes!(
- "../testdata/tls/RootCA.crt"
- )));
- let certs = rustls_pemfile::certs(&mut reader).unwrap();
- let mut root_store = rustls::RootCertStore::empty();
- root_store.add_parsable_certificates(&certs);
- let mut cfg = rustls::ClientConfig::builder()
- .with_safe_defaults()
- .with_root_certificates(root_store)
- .with_no_client_auth();
- cfg.alpn_protocols.push(b"foobar".to_vec());
- let cfg = Arc::new(cfg);
-
- let hostname = rustls::ServerName::try_from("localhost").unwrap();
-
- let tcp_stream = tokio::net::TcpStream::connect("localhost:4504")
- .await
- .unwrap();
- let mut tls_stream =
- TlsStream::new_client_side(tcp_stream, cfg, hostname);
-
- tls_stream.handshake().await.unwrap();
-
- let (_, rustls_connection) = tls_stream.get_ref();
- let alpn = rustls_connection.alpn_protocol().unwrap();
- assert_eq!(alpn, b"foobar");
-
- let status = child.wait().unwrap();
- assert!(status.success());
- })
- .await;
-}
-
-#[tokio::test]
-async fn listen_tls_alpn_fail() {
- // TLS streams require the presence of an ambient local task set to gracefully
- // close dropped connections in the background.
- LocalSet::new()
- .run_until(async {
- let mut child = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--unstable")
- .arg("--quiet")
- .arg("--allow-net")
- .arg("--allow-read")
- .arg("./listen_tls_alpn_fail.ts")
- .arg("4505")
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap();
- let stdout = child.stdout.as_mut().unwrap();
- let mut msg = [0; 5];
- let read = stdout.read(&mut msg).unwrap();
- assert_eq!(read, 5);
- assert_eq!(&msg, b"READY");
-
- let mut reader = &mut BufReader::new(Cursor::new(include_bytes!(
- "../testdata/tls/RootCA.crt"
- )));
- let certs = rustls_pemfile::certs(&mut reader).unwrap();
- let mut root_store = rustls::RootCertStore::empty();
- root_store.add_parsable_certificates(&certs);
- let mut cfg = rustls::ClientConfig::builder()
- .with_safe_defaults()
- .with_root_certificates(root_store)
- .with_no_client_auth();
- cfg.alpn_protocols.push(b"boofar".to_vec());
- let cfg = Arc::new(cfg);
-
- let hostname = rustls::ServerName::try_from("localhost").unwrap();
-
- let tcp_stream = tokio::net::TcpStream::connect("localhost:4505")
- .await
- .unwrap();
- let mut tls_stream =
- TlsStream::new_client_side(tcp_stream, cfg, hostname);
-
- tls_stream.handshake().await.unwrap_err();
-
- let (_, rustls_connection) = tls_stream.get_ref();
- assert!(rustls_connection.alpn_protocol().is_none());
-
- let status = child.wait().unwrap();
- assert!(status.success());
- })
- .await;
-}
-
-#[tokio::test]
-async fn http2_request_url() {
- // TLS streams require the presence of an ambient local task set to gracefully
- // close dropped connections in the background.
- LocalSet::new()
- .run_until(async {
- let mut child = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--unstable")
- .arg("--quiet")
- .arg("--allow-net")
- .arg("--allow-read")
- .arg("./http2_request_url.ts")
- .arg("4506")
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap();
- let stdout = child.stdout.as_mut().unwrap();
- let mut buffer = [0; 5];
- let read = stdout.read(&mut buffer).unwrap();
- assert_eq!(read, 5);
- let msg = std::str::from_utf8(&buffer).unwrap();
- assert_eq!(msg, "READY");
-
- let cert = reqwest::Certificate::from_pem(include_bytes!(
- "../testdata/tls/RootCA.crt"
- ))
- .unwrap();
-
- let client = reqwest::Client::builder()
- .add_root_certificate(cert)
- .http2_prior_knowledge()
- .build()
- .unwrap();
-
- let res = client.get("http://127.0.0.1:4506").send().await.unwrap();
- assert_eq!(200, res.status());
-
- let body = res.text().await.unwrap();
- assert_eq!(body, "http://127.0.0.1:4506/");
-
- child.kill().unwrap();
- child.wait().unwrap();
- })
- .await;
-}
diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs
index cdeb36c9c..44c7ec08f 100644
--- a/cli/tests/integration/repl_tests.rs
+++ b/cli/tests/integration/repl_tests.rs
@@ -160,9 +160,9 @@ fn pty_complete_expression() {
fn pty_complete_imports() {
util::with_pty(&["repl"], |mut console| {
// single quotes
- console.write_line("import './001_hel\t'");
+ console.write_line("import './run/001_hel\t'");
// double quotes
- console.write_line("import { output } from \"./045_out\t\"");
+ console.write_line("import { output } from \"./run/045_out\t\"");
console.write_line("output('testing output');");
console.write_line("close();");
@@ -179,7 +179,7 @@ fn pty_complete_imports() {
// ensure when the directory changes that the suggestions come from the cwd
util::with_pty(&["repl"], |mut console| {
console.write_line("Deno.chdir('./subdir');");
- console.write_line("import '../001_hel\t'");
+ console.write_line("import '../run/001_hel\t'");
console.write_line("close();");
let output = console.read_all_output();
@@ -750,7 +750,7 @@ fn eval_flag_runtime_error() {
fn eval_file_flag_valid_input() {
let (out, err) = util::run_and_collect_output_with_args(
true,
- vec!["repl", "--eval-file=./001_hello.js"],
+ vec!["repl", "--eval-file=./run/001_hello.js"],
None,
None,
false,
@@ -789,7 +789,7 @@ fn eval_file_flag_http_input() {
fn eval_file_flag_multiple_files() {
let (out, err) = util::run_and_collect_output_with_args(
true,
- vec!["repl", "--eval-file=http://127.0.0.1:4545/import_type.ts,./tsc/d.ts,http://127.0.0.1:4545/type_definitions/foo.js"],
+ vec!["repl", "--eval-file=http://127.0.0.1:4545/repl/import_type.ts,./tsc/d.ts,http://127.0.0.1:4545/type_definitions/foo.js"],
Some(vec!["b.method1=v4", "b.method1()+foo.toUpperCase()"]),
None,
true,
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index d4dfbb32b..55dac8573 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -1,10 +1,16 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use deno_core::url;
+use deno_runtime::deno_fetch::reqwest;
+use std::io::Read;
+use std::io::Write;
use std::process::Command;
use std::process::Stdio;
use test_util as util;
use test_util::TempDir;
+use tokio::task::LocalSet;
+use trust_dns_client::serialize::txt::Lexer;
+use trust_dns_client::serialize::txt::Parser;
use util::assert_contains;
itest!(stdout_write_all {
@@ -24,248 +30,251 @@ itest!(stdout_write_sync_async {
});
itest!(_001_hello {
- args: "run --reload 001_hello.js",
- output: "001_hello.js.out",
+ args: "run --reload run/001_hello.js",
+ output: "run/001_hello.js.out",
});
itest!(_002_hello {
- args: "run --quiet --reload 002_hello.ts",
- output: "002_hello.ts.out",
+ args: "run --quiet --reload run/002_hello.ts",
+ output: "run/002_hello.ts.out",
});
itest!(_003_relative_import {
- args: "run --quiet --reload 003_relative_import.ts",
- output: "003_relative_import.ts.out",
+ args: "run --quiet --reload run/003_relative_import.ts",
+ output: "run/003_relative_import.ts.out",
});
itest!(_004_set_timeout {
- args: "run --quiet --reload 004_set_timeout.ts",
- output: "004_set_timeout.ts.out",
+ args: "run --quiet --reload run/004_set_timeout.ts",
+ output: "run/004_set_timeout.ts.out",
});
itest!(_005_more_imports {
- args: "run --quiet --reload 005_more_imports.ts",
- output: "005_more_imports.ts.out",
+ args: "run --quiet --reload run/005_more_imports.ts",
+ output: "run/005_more_imports.ts.out",
});
itest!(_006_url_imports {
- args: "run --quiet --reload 006_url_imports.ts",
- output: "006_url_imports.ts.out",
+ args: "run --quiet --reload run/006_url_imports.ts",
+ output: "run/006_url_imports.ts.out",
http_server: true,
});
itest!(_012_async {
- args: "run --quiet --reload 012_async.ts",
- output: "012_async.ts.out",
+ args: "run --quiet --reload run/012_async.ts",
+ output: "run/012_async.ts.out",
});
itest!(_013_dynamic_import {
- args: "run --quiet --reload --allow-read 013_dynamic_import.ts",
- output: "013_dynamic_import.ts.out",
+ args: "run --quiet --reload --allow-read run/013_dynamic_import.ts",
+ output: "run/013_dynamic_import.ts.out",
});
itest!(_014_duplicate_import {
- args: "run --quiet --reload --allow-read 014_duplicate_import.ts ",
- output: "014_duplicate_import.ts.out",
+ args: "run --quiet --reload --allow-read run/014_duplicate_import.ts ",
+ output: "run/014_duplicate_import.ts.out",
});
itest!(_015_duplicate_parallel_import {
- args: "run --quiet --reload --allow-read 015_duplicate_parallel_import.js",
- output: "015_duplicate_parallel_import.js.out",
+ args:
+ "run --quiet --reload --allow-read run/015_duplicate_parallel_import.js",
+ output: "run/015_duplicate_parallel_import.js.out",
});
itest!(_016_double_await {
- args: "run --quiet --allow-read --reload 016_double_await.ts",
- output: "016_double_await.ts.out",
+ args: "run --quiet --allow-read --reload run/016_double_await.ts",
+ output: "run/016_double_await.ts.out",
});
itest!(_017_import_redirect {
- args: "run --quiet --reload 017_import_redirect.ts",
- output: "017_import_redirect.ts.out",
+ args: "run --quiet --reload run/017_import_redirect.ts",
+ output: "run/017_import_redirect.ts.out",
});
itest!(_017_import_redirect_nocheck {
- args: "run --quiet --reload --no-check 017_import_redirect.ts",
- output: "017_import_redirect.ts.out",
+ args: "run --quiet --reload --no-check run/017_import_redirect.ts",
+ output: "run/017_import_redirect.ts.out",
});
itest!(_017_import_redirect_info {
- args: "info --quiet --reload 017_import_redirect.ts",
- output: "017_import_redirect_info.out",
+ args: "info --quiet --reload run/017_import_redirect.ts",
+ output: "run/017_import_redirect_info.out",
});
itest!(_018_async_catch {
- args: "run --quiet --reload 018_async_catch.ts",
- output: "018_async_catch.ts.out",
+ args: "run --quiet --reload run/018_async_catch.ts",
+ output: "run/018_async_catch.ts.out",
});
itest!(_019_media_types {
- args: "run --reload 019_media_types.ts",
- output: "019_media_types.ts.out",
+ args: "run --reload run/019_media_types.ts",
+ output: "run/019_media_types.ts.out",
http_server: true,
});
itest!(_020_json_modules {
- args: "run --reload 020_json_modules.ts",
- output: "020_json_modules.ts.out",
+ args: "run --reload run/020_json_modules.ts",
+ output: "run/020_json_modules.ts.out",
exit_code: 1,
});
itest!(_021_mjs_modules {
- args: "run --quiet --reload 021_mjs_modules.ts",
- output: "021_mjs_modules.ts.out",
+ args: "run --quiet --reload run/021_mjs_modules.ts",
+ output: "run/021_mjs_modules.ts.out",
});
itest!(_023_no_ext {
- args: "run --reload --check 023_no_ext",
- output: "023_no_ext.out",
+ args: "run --reload --check run/023_no_ext",
+ output: "run/023_no_ext.out",
});
// TODO(lucacasonato): remove --unstable when permissions goes stable
itest!(_025_hrtime {
- args: "run --quiet --allow-hrtime --unstable --reload 025_hrtime.ts",
- output: "025_hrtime.ts.out",
+ args: "run --quiet --allow-hrtime --unstable --reload run/025_hrtime.ts",
+ output: "run/025_hrtime.ts.out",
});
itest!(_025_reload_js_type_error {
- args: "run --quiet --reload 025_reload_js_type_error.js",
- output: "025_reload_js_type_error.js.out",
+ args: "run --quiet --reload run/025_reload_js_type_error.js",
+ output: "run/025_reload_js_type_error.js.out",
});
itest!(_026_redirect_javascript {
- args: "run --quiet --reload 026_redirect_javascript.js",
- output: "026_redirect_javascript.js.out",
+ args: "run --quiet --reload run/026_redirect_javascript.js",
+ output: "run/026_redirect_javascript.js.out",
http_server: true,
});
itest!(_027_redirect_typescript {
- args: "run --quiet --reload 027_redirect_typescript.ts",
- output: "027_redirect_typescript.ts.out",
+ args: "run --quiet --reload run/027_redirect_typescript.ts",
+ output: "run/027_redirect_typescript.ts.out",
http_server: true,
});
itest!(_028_args {
- args: "run --quiet --reload 028_args.ts --arg1 val1 --arg2=val2 -- arg3 arg4",
- output: "028_args.ts.out",
+ args:
+ "run --quiet --reload run/028_args.ts --arg1 val1 --arg2=val2 -- arg3 arg4",
+ output: "run/028_args.ts.out",
});
itest!(_033_import_map {
args:
"run --quiet --reload --import-map=import_maps/import_map.json import_maps/test.ts",
- output: "033_import_map.out",
+ output: "run/033_import_map.out",
});
itest!(_033_import_map_remote {
args:
"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",
+ output: "run/033_import_map_remote.out",
http_server: true,
});
-itest!(_034_onload {
- args: "run --quiet --reload 034_onload/main.ts",
- output: "034_onload.out",
+itest!(onload {
+ args: "run --quiet --reload run/onload/main.ts",
+ output: "run/onload/main.out",
});
itest!(_035_cached_only_flag {
- args: "run --reload --check --cached-only http://127.0.0.1:4545/019_media_types.ts",
- output: "035_cached_only_flag.out",
+ args: "run --reload --check --cached-only http://127.0.0.1:4545/run/019_media_types.ts",
+ output: "run/035_cached_only_flag.out",
exit_code: 1,
http_server: true,
});
itest!(_038_checkjs {
// checking if JS file is run through TS compiler
- args: "run --reload --config checkjs.tsconfig.json --check 038_checkjs.js",
+ args:
+ "run --reload --config run/checkjs.tsconfig.json --check run/038_checkjs.js",
exit_code: 1,
- output: "038_checkjs.js.out",
+ output: "run/038_checkjs.js.out",
});
itest!(_042_dyn_import_evalcontext {
- args: "run --quiet --allow-read --reload 042_dyn_import_evalcontext.ts",
- output: "042_dyn_import_evalcontext.ts.out",
+ args: "run --quiet --allow-read --reload run/042_dyn_import_evalcontext.ts",
+ output: "run/042_dyn_import_evalcontext.ts.out",
});
itest!(_044_bad_resource {
- args: "run --quiet --reload --allow-read 044_bad_resource.ts",
- output: "044_bad_resource.ts.out",
+ args: "run --quiet --reload --allow-read run/044_bad_resource.ts",
+ output: "run/044_bad_resource.ts.out",
exit_code: 1,
});
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
itest!(_045_proxy {
- args: "run -L debug --unstable --allow-net --allow-env --allow-run --allow-read --reload --quiet 045_proxy_test.ts",
- output: "045_proxy_test.ts.out",
+ args: "run -L debug --unstable --allow-net --allow-env --allow-run --allow-read --reload --quiet run/045_proxy_test.ts",
+ output: "run/045_proxy_test.ts.out",
http_server: true,
});
itest!(_046_tsx {
- args: "run --quiet --reload 046_jsx_test.tsx",
- output: "046_jsx_test.tsx.out",
+ args: "run --quiet --reload run/046_jsx_test.tsx",
+ output: "run/046_jsx_test.tsx.out",
});
itest!(_047_jsx {
- args: "run --quiet --reload 047_jsx_test.jsx",
- output: "047_jsx_test.jsx.out",
+ args: "run --quiet --reload run/047_jsx_test.jsx",
+ output: "run/047_jsx_test.jsx.out",
});
itest!(_048_media_types_jsx {
- args: "run --reload 048_media_types_jsx.ts",
- output: "048_media_types_jsx.ts.out",
+ args: "run --reload run/048_media_types_jsx.ts",
+ output: "run/048_media_types_jsx.ts.out",
http_server: true,
});
itest!(_052_no_remote_flag {
args:
- "run --reload --check --no-remote http://127.0.0.1:4545/019_media_types.ts",
- output: "052_no_remote_flag.out",
+ "run --reload --check --no-remote http://127.0.0.1:4545/run/019_media_types.ts",
+ output: "run/052_no_remote_flag.out",
exit_code: 1,
http_server: true,
});
itest!(_056_make_temp_file_write_perm {
args:
- "run --quiet --allow-read --allow-write=./subdir/ 056_make_temp_file_write_perm.ts",
- output: "056_make_temp_file_write_perm.out",
+ "run --quiet --allow-read --allow-write=./subdir/ run/056_make_temp_file_write_perm.ts",
+ output: "run/056_make_temp_file_write_perm.out",
});
itest!(_058_tasks_microtasks_close {
- args: "run --quiet 058_tasks_microtasks_close.ts",
- output: "058_tasks_microtasks_close.ts.out",
+ args: "run --quiet run/058_tasks_microtasks_close.ts",
+ output: "run/058_tasks_microtasks_close.ts.out",
});
itest!(_059_fs_relative_path_perm {
- args: "run 059_fs_relative_path_perm.ts",
- output: "059_fs_relative_path_perm.ts.out",
+ args: "run run/059_fs_relative_path_perm.ts",
+ output: "run/059_fs_relative_path_perm.ts.out",
exit_code: 1,
});
itest!(_070_location {
- args: "run --location https://foo/bar?baz#bat 070_location.ts",
- output: "070_location.ts.out",
+ args: "run --location https://foo/bar?baz#bat run/070_location.ts",
+ output: "run/070_location.ts.out",
});
itest!(_071_location_unset {
- args: "run 071_location_unset.ts",
- output: "071_location_unset.ts.out",
+ args: "run run/071_location_unset.ts",
+ output: "run/071_location_unset.ts.out",
});
itest!(_072_location_relative_fetch {
- args: "run --location http://127.0.0.1:4545/ --allow-net 072_location_relative_fetch.ts",
- output: "072_location_relative_fetch.ts.out",
+ args: "run --location http://127.0.0.1:4545/ --allow-net run/072_location_relative_fetch.ts",
+ output: "run/072_location_relative_fetch.ts.out",
http_server: true,
});
-// tests the serialization of webstorage (both localStorage and sessionStorage)
-itest!(webstorage_serialization {
- args: "run webstorage/serialization.ts",
- output: "webstorage/serialization.ts.out",
-});
-
// tests the beforeunload event
itest!(beforeunload_event {
- args: "run before_unload.js",
- output: "before_unload.js.out",
+ args: "run run/before_unload.js",
+ output: "run/before_unload.js.out",
+});
+
+// tests the serialization of webstorage (both localStorage and sessionStorage)
+itest!(webstorage_serialization {
+ args: "run run/webstorage/serialization.ts",
+ output: "run/webstorage/serialization.ts.out",
});
// tests to ensure that when `--location` is set, all code shares the same
@@ -280,7 +289,7 @@ fn webstorage_location_shares_origin() {
.arg("run")
.arg("--location")
.arg("https://example.com/a.ts")
- .arg("webstorage/fixture.ts")
+ .arg("run/webstorage/fixture.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -295,7 +304,7 @@ fn webstorage_location_shares_origin() {
.arg("run")
.arg("--location")
.arg("https://example.com/b.ts")
- .arg("webstorage/logger.ts")
+ .arg("run/webstorage/logger.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -316,8 +325,8 @@ fn webstorage_config_file() {
.current_dir(util::testdata_path())
.arg("run")
.arg("--config")
- .arg("webstorage/config_a.jsonc")
- .arg("webstorage/fixture.ts")
+ .arg("run/webstorage/config_a.jsonc")
+ .arg("run/webstorage/fixture.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -331,8 +340,8 @@ fn webstorage_config_file() {
.current_dir(util::testdata_path())
.arg("run")
.arg("--config")
- .arg("webstorage/config_b.jsonc")
- .arg("webstorage/logger.ts")
+ .arg("run/webstorage/config_b.jsonc")
+ .arg("run/webstorage/logger.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -346,8 +355,8 @@ fn webstorage_config_file() {
.current_dir(util::testdata_path())
.arg("run")
.arg("--config")
- .arg("webstorage/config_a.jsonc")
- .arg("webstorage/logger.ts")
+ .arg("run/webstorage/config_a.jsonc")
+ .arg("run/webstorage/logger.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -370,8 +379,8 @@ fn webstorage_location_precedes_config() {
.arg("--location")
.arg("https://example.com/a.ts")
.arg("--config")
- .arg("webstorage/config_a.jsonc")
- .arg("webstorage/fixture.ts")
+ .arg("run/webstorage/config_a.jsonc")
+ .arg("run/webstorage/fixture.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -387,8 +396,8 @@ fn webstorage_location_precedes_config() {
.arg("--location")
.arg("https://example.com/b.ts")
.arg("--config")
- .arg("webstorage/config_b.jsonc")
- .arg("webstorage/logger.ts")
+ .arg("run/webstorage/config_b.jsonc")
+ .arg("run/webstorage/logger.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -408,7 +417,7 @@ fn webstorage_main_module() {
let output = deno_cmd
.current_dir(util::testdata_path())
.arg("run")
- .arg("webstorage/fixture.ts")
+ .arg("run/webstorage/fixture.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -421,7 +430,7 @@ fn webstorage_main_module() {
let output = deno_cmd
.current_dir(util::testdata_path())
.arg("run")
- .arg("webstorage/logger.ts")
+ .arg("run/webstorage/logger.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -434,7 +443,7 @@ fn webstorage_main_module() {
let output = deno_cmd
.current_dir(util::testdata_path())
.arg("run")
- .arg("webstorage/fixture.ts")
+ .arg("run/webstorage/fixture.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -445,36 +454,37 @@ fn webstorage_main_module() {
}
itest!(_075_import_local_query_hash {
- args: "run 075_import_local_query_hash.ts",
- output: "075_import_local_query_hash.ts.out",
+ args: "run run/075_import_local_query_hash.ts",
+ output: "run/075_import_local_query_hash.ts.out",
});
itest!(_077_fetch_empty {
- args: "run -A 077_fetch_empty.ts",
- output: "077_fetch_empty.ts.out",
+ args: "run -A run/077_fetch_empty.ts",
+ output: "run/077_fetch_empty.ts.out",
exit_code: 1,
});
itest!(_078_unload_on_exit {
- args: "run 078_unload_on_exit.ts",
- output: "078_unload_on_exit.ts.out",
+ args: "run run/078_unload_on_exit.ts",
+ output: "run/078_unload_on_exit.ts.out",
exit_code: 1,
});
itest!(_079_location_authentication {
- args: "run --location https://foo:bar@baz/qux 079_location_authentication.ts",
- output: "079_location_authentication.ts.out",
+ args:
+ "run --location https://foo:bar@baz/qux run/079_location_authentication.ts",
+ output: "run/079_location_authentication.ts.out",
});
itest!(_081_location_relative_fetch_redirect {
- args: "run --location http://127.0.0.1:4546/ --allow-net 081_location_relative_fetch_redirect.ts",
- output: "081_location_relative_fetch_redirect.ts.out",
+ args: "run --location http://127.0.0.1:4546/ --allow-net run/081_location_relative_fetch_redirect.ts",
+ output: "run/081_location_relative_fetch_redirect.ts.out",
http_server: true,
});
itest!(_082_prepare_stack_trace_throw {
- args: "run 082_prepare_stack_trace_throw.js",
- output: "082_prepare_stack_trace_throw.js.out",
+ args: "run run/082_prepare_stack_trace_throw.js",
+ output: "run/082_prepare_stack_trace_throw.js.out",
exit_code: 1,
});
@@ -482,9 +492,10 @@ itest!(_082_prepare_stack_trace_throw {
fn _083_legacy_external_source_map() {
let _g = util::http_server();
let deno_dir = TempDir::new();
- let module_url =
- url::Url::parse("http://localhost:4545/083_legacy_external_source_map.ts")
- .unwrap();
+ let module_url = url::Url::parse(
+ "http://localhost:4545/run/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()).unwrap();
@@ -505,35 +516,35 @@ fn _083_legacy_external_source_map() {
assert_eq!(out, "");
}
-itest!(_085_dynamic_import_async_error {
- args: "run --allow-read 085_dynamic_import_async_error.ts",
- output: "085_dynamic_import_async_error.ts.out",
+itest!(dynamic_import_async_error {
+ args: "run --allow-read run/dynamic_import_async_error/main.ts",
+ output: "run/dynamic_import_async_error/main.out",
});
-itest!(_086_dynamic_import_already_rejected {
- args: "run --allow-read 086_dynamic_import_already_rejected.ts",
- output: "086_dynamic_import_already_rejected.ts.out",
+itest!(dynamic_import_already_rejected {
+ args: "run --allow-read run/dynamic_import_already_rejected/main.ts",
+ output: "run/dynamic_import_already_rejected/main.out",
});
-itest!(_087_no_check_imports_not_used_as_values {
- args: "run --config preserve_imports.tsconfig.json --no-check 087_no_check_imports_not_used_as_values.ts",
- output: "087_no_check_imports_not_used_as_values.ts.out",
+itest!(no_check_imports_not_used_as_values {
+ args: "run --config run/no_check_imports_not_used_as_values/preserve_imports.tsconfig.json --no-check run/no_check_imports_not_used_as_values/main.ts",
+ output: "run/no_check_imports_not_used_as_values/main.out",
});
itest!(_088_dynamic_import_already_evaluating {
- args: "run --allow-read 088_dynamic_import_already_evaluating.ts",
- output: "088_dynamic_import_already_evaluating.ts.out",
+ args: "run --allow-read run/088_dynamic_import_already_evaluating.ts",
+ output: "run/088_dynamic_import_already_evaluating.ts.out",
});
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
itest!(_089_run_allow_list {
- args: "run --unstable --allow-run=curl 089_run_allow_list.ts",
- output: "089_run_allow_list.ts.out",
+ args: "run --unstable --allow-run=curl run/089_run_allow_list.ts",
+ output: "run/089_run_allow_list.ts.out",
});
#[test]
fn _090_run_permissions_request() {
- let args = "run --quiet 090_run_permissions_request.ts";
+ let args = "run --quiet run/090_run_permissions_request.ts";
use util::PtyData::*;
util::test_pty2(args, vec![
Output("⚠️ ️Deno requests run access to \"ls\". Run again with --allow-run to bypass this prompt.\r\n Allow? [y/n (y = yes allow, n = no deny)]"),
@@ -547,159 +558,161 @@ fn _090_run_permissions_request() {
}
itest!(_091_use_define_for_class_fields {
- args: "run --check 091_use_define_for_class_fields.ts",
- output: "091_use_define_for_class_fields.ts.out",
+ args: "run --check run/091_use_define_for_class_fields.ts",
+ output: "run/091_use_define_for_class_fields.ts.out",
exit_code: 1,
});
itest!(_092_import_map_unmapped_bare_specifier {
- args: "run --import-map import_maps/import_map.json 092_import_map_unmapped_bare_specifier.ts",
- output: "092_import_map_unmapped_bare_specifier.ts.out",
+ args: "run --import-map import_maps/import_map.json run/092_import_map_unmapped_bare_specifier.ts",
+ output: "run/092_import_map_unmapped_bare_specifier.ts.out",
exit_code: 1,
});
itest!(js_import_detect {
- args: "run --quiet --reload js_import_detect.ts",
- output: "js_import_detect.ts.out",
+ args: "run --quiet --reload run/js_import_detect.ts",
+ output: "run/js_import_detect.ts.out",
exit_code: 0,
});
itest!(blob_gc_finalization {
- args: "run blob_gc_finalization.js",
- output: "blob_gc_finalization.js.out",
+ args: "run run/blob_gc_finalization.js",
+ output: "run/blob_gc_finalization.js.out",
exit_code: 0,
});
itest!(fetch_response_finalization {
- args: "run --v8-flags=--expose-gc --allow-net fetch_response_finalization.js",
- output: "fetch_response_finalization.js.out",
+ args:
+ "run --v8-flags=--expose-gc --allow-net run/fetch_response_finalization.js",
+ output: "run/fetch_response_finalization.js.out",
http_server: true,
exit_code: 0,
});
itest!(import_type {
- args: "run --reload import_type.ts",
- output: "import_type.ts.out",
+ args: "run --reload run/import_type.ts",
+ output: "run/import_type.ts.out",
});
itest!(import_type_no_check {
- args: "run --reload --no-check import_type.ts",
- output: "import_type.ts.out",
+ args: "run --reload --no-check run/import_type.ts",
+ output: "run/import_type.ts.out",
});
itest!(private_field_presence {
- args: "run --reload private_field_presence.ts",
- output: "private_field_presence.ts.out",
+ args: "run --reload run/private_field_presence.ts",
+ output: "run/private_field_presence.ts.out",
});
itest!(private_field_presence_no_check {
- args: "run --reload --no-check private_field_presence.ts",
- output: "private_field_presence.ts.out",
+ args: "run --reload --no-check run/private_field_presence.ts",
+ output: "run/private_field_presence.ts.out",
});
itest!(lock_write_requires_lock {
args: "run --lock-write some_file.ts",
- output: "lock_write_requires_lock.out",
+ output: "run/lock_write_requires_lock.out",
exit_code: 1,
});
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
itest!(lock_write_fetch {
args:
- "run --quiet --allow-read --allow-write --allow-env --allow-run --unstable lock_write_fetch.ts",
- output: "lock_write_fetch.ts.out",
+ "run --quiet --allow-read --allow-write --allow-env --allow-run --unstable run/lock_write_fetch/main.ts",
+ output: "run/lock_write_fetch/main.out",
http_server: true,
exit_code: 0,
});
itest!(lock_check_ok {
args:
- "run --lock=lock_check_ok.json http://127.0.0.1:4545/003_relative_import.ts",
- output: "003_relative_import.ts.out",
+ "run --lock=run/lock_check_ok.json http://127.0.0.1:4545/run/003_relative_import.ts",
+ output: "run/003_relative_import.ts.out",
http_server: true,
});
itest!(lock_check_ok2 {
- args: "run --lock=lock_check_ok2.json 019_media_types.ts",
- output: "019_media_types.ts.out",
+ args: "run --lock=run/lock_check_ok2.json run/019_media_types.ts",
+ output: "run/019_media_types.ts.out",
http_server: true,
});
itest!(lock_dynamic_imports {
- 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",
+ args: "run --lock=run/lock_dynamic_imports.json --allow-read --allow-net http://127.0.0.1:4545/run/013_dynamic_import.ts",
+ output: "run/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/003_relative_import.ts",
- output: "lock_check_err.out",
+ args: "run --lock=run/lock_check_err.json http://127.0.0.1:4545/run/003_relative_import.ts",
+ output: "run/lock_check_err.out",
exit_code: 10,
http_server: true,
});
itest!(lock_check_err2 {
- args: "run --lock=lock_check_err2.json 019_media_types.ts",
- output: "lock_check_err2.out",
+ args: "run --lock=run/lock_check_err2.json run/019_media_types.ts",
+ output: "run/lock_check_err2.out",
exit_code: 10,
http_server: true,
});
itest!(mts_dmts_mjs {
args: "run subdir/import.mts",
- output: "mts_dmts_mjs.out",
+ output: "run/mts_dmts_mjs.out",
});
itest!(mts_dmts_mjs_no_check {
args: "run --no-check subdir/import.mts",
- output: "mts_dmts_mjs.out",
+ output: "run/mts_dmts_mjs.out",
});
itest!(async_error {
exit_code: 1,
- args: "run --reload async_error.ts",
- output: "async_error.ts.out",
+ args: "run --reload run/async_error.ts",
+ output: "run/async_error.ts.out",
});
itest!(config {
- args: "run --reload --config config.tsconfig.json --check config.ts",
- output: "config.ts.out",
+ args:
+ "run --reload --config run/config/tsconfig.json --check run/config/main.ts",
+ output: "run/config/main.out",
});
itest!(config_types {
args:
- "run --reload --quiet --config config_types.tsconfig.json config_types.ts",
- output: "config_types.ts.out",
+ "run --reload --quiet --config run/config_types/tsconfig.json run/config_types/main.ts",
+ output: "run/config_types/main.out",
});
itest!(config_types_remote {
http_server: true,
- args: "run --reload --quiet --config config_types_remote.tsconfig.json config_types.ts",
- output: "config_types.ts.out",
+ args: "run --reload --quiet --config run/config_types/remote.tsconfig.json run/config_types/main.ts",
+ output: "run/config_types/main.out",
});
itest!(empty_typescript {
- args: "run --reload --check subdir/empty.ts",
- output_str: Some("Check file:[WILDCARD]/subdir/empty.ts\n"),
+ args: "run --reload --check run/empty.ts",
+ output_str: Some("Check file:[WILDCARD]/run/empty.ts\n"),
});
itest!(error_001 {
- args: "run --reload error_001.ts",
+ args: "run --reload run/error_001.ts",
exit_code: 1,
- output: "error_001.ts.out",
+ output: "run/error_001.ts.out",
});
itest!(error_002 {
- args: "run --reload error_002.ts",
+ args: "run --reload run/error_002.ts",
exit_code: 1,
- output: "error_002.ts.out",
+ output: "run/error_002.ts.out",
});
itest!(error_003_typescript {
- args: "run --reload --check error_003_typescript.ts",
+ args: "run --reload --check run/error_003_typescript.ts",
exit_code: 1,
- output: "error_003_typescript.ts.out",
+ output: "run/error_003_typescript.ts.out",
});
// Supposing that we've already attempted to run error_003_typescript.ts
@@ -707,820 +720,816 @@ itest!(error_003_typescript {
// should result in the same output.
// https://github.com/denoland/deno/issues/2436
itest!(error_003_typescript2 {
- args: "run --check error_003_typescript.ts",
+ args: "run --check run/error_003_typescript.ts",
exit_code: 1,
- output: "error_003_typescript.ts.out",
+ output: "run/error_003_typescript.ts.out",
});
itest!(error_004_missing_module {
- args: "run --reload error_004_missing_module.ts",
+ args: "run --reload run/error_004_missing_module.ts",
exit_code: 1,
- output: "error_004_missing_module.ts.out",
+ output: "run/error_004_missing_module.ts.out",
});
itest!(error_005_missing_dynamic_import {
- args: "run --reload --allow-read --quiet error_005_missing_dynamic_import.ts",
+ args:
+ "run --reload --allow-read --quiet run/error_005_missing_dynamic_import.ts",
exit_code: 1,
- output: "error_005_missing_dynamic_import.ts.out",
+ output: "run/error_005_missing_dynamic_import.ts.out",
});
itest!(error_006_import_ext_failure {
- args: "run --reload error_006_import_ext_failure.ts",
+ args: "run --reload run/error_006_import_ext_failure.ts",
exit_code: 1,
- output: "error_006_import_ext_failure.ts.out",
+ output: "run/error_006_import_ext_failure.ts.out",
});
itest!(error_007_any {
- args: "run --reload error_007_any.ts",
+ args: "run --reload run/error_007_any.ts",
exit_code: 1,
- output: "error_007_any.ts.out",
+ output: "run/error_007_any.ts.out",
});
itest!(error_008_checkjs {
- args: "run --reload error_008_checkjs.js",
+ args: "run --reload run/error_008_checkjs.js",
exit_code: 1,
- output: "error_008_checkjs.js.out",
+ output: "run/error_008_checkjs.js.out",
});
itest!(error_009_extensions_error {
- args: "run error_009_extensions_error.js",
- output: "error_009_extensions_error.js.out",
+ args: "run run/error_009_extensions_error.js",
+ output: "run/error_009_extensions_error.js.out",
exit_code: 1,
});
itest!(error_011_bad_module_specifier {
- args: "run --reload error_011_bad_module_specifier.ts",
+ args: "run --reload run/error_011_bad_module_specifier.ts",
exit_code: 1,
- output: "error_011_bad_module_specifier.ts.out",
+ output: "run/error_011_bad_module_specifier.ts.out",
});
itest!(error_012_bad_dynamic_import_specifier {
- args: "run --reload --check error_012_bad_dynamic_import_specifier.ts",
+ args: "run --reload --check run/error_012_bad_dynamic_import_specifier.ts",
exit_code: 1,
- output: "error_012_bad_dynamic_import_specifier.ts.out",
+ output: "run/error_012_bad_dynamic_import_specifier.ts.out",
});
itest!(error_013_missing_script {
args: "run --reload missing_file_name",
exit_code: 1,
- output: "error_013_missing_script.out",
+ output: "run/error_013_missing_script.out",
});
itest!(error_014_catch_dynamic_import_error {
- args: "run --reload --allow-read error_014_catch_dynamic_import_error.js",
- output: "error_014_catch_dynamic_import_error.js.out",
+ args:
+ "run --reload --allow-read run/error_014_catch_dynamic_import_error.js",
+ output: "run/error_014_catch_dynamic_import_error.js.out",
});
itest!(error_015_dynamic_import_permissions {
- args: "run --reload --quiet error_015_dynamic_import_permissions.js",
- output: "error_015_dynamic_import_permissions.out",
+ args: "run --reload --quiet run/error_015_dynamic_import_permissions.js",
+ output: "run/error_015_dynamic_import_permissions.out",
exit_code: 1,
http_server: true,
});
// We have an allow-net flag but not allow-read, it should still result in error.
itest!(error_016_dynamic_import_permissions2 {
- args: "run --reload --allow-net error_016_dynamic_import_permissions2.js",
- output: "error_016_dynamic_import_permissions2.out",
+ args: "run --reload --allow-net run/error_016_dynamic_import_permissions2.js",
+ output: "run/error_016_dynamic_import_permissions2.out",
exit_code: 1,
http_server: true,
});
itest!(error_017_hide_long_source_ts {
- args: "run --reload --check error_017_hide_long_source_ts.ts",
- output: "error_017_hide_long_source_ts.ts.out",
+ args: "run --reload --check run/error_017_hide_long_source_ts.ts",
+ output: "run/error_017_hide_long_source_ts.ts.out",
exit_code: 1,
});
itest!(error_018_hide_long_source_js {
- args: "run error_018_hide_long_source_js.js",
- output: "error_018_hide_long_source_js.js.out",
+ args: "run run/error_018_hide_long_source_js.js",
+ output: "run/error_018_hide_long_source_js.js.out",
exit_code: 1,
});
itest!(error_019_stack_function {
- args: "run error_019_stack_function.ts",
- output: "error_019_stack_function.ts.out",
+ args: "run run/error_019_stack_function.ts",
+ output: "run/error_019_stack_function.ts.out",
exit_code: 1,
});
itest!(error_020_stack_constructor {
- args: "run error_020_stack_constructor.ts",
- output: "error_020_stack_constructor.ts.out",
+ args: "run run/error_020_stack_constructor.ts",
+ output: "run/error_020_stack_constructor.ts.out",
exit_code: 1,
});
itest!(error_021_stack_method {
- args: "run error_021_stack_method.ts",
- output: "error_021_stack_method.ts.out",
+ args: "run run/error_021_stack_method.ts",
+ output: "run/error_021_stack_method.ts.out",
exit_code: 1,
});
itest!(error_022_stack_custom_error {
- args: "run error_022_stack_custom_error.ts",
- output: "error_022_stack_custom_error.ts.out",
+ args: "run run/error_022_stack_custom_error.ts",
+ output: "run/error_022_stack_custom_error.ts.out",
exit_code: 1,
});
itest!(error_023_stack_async {
- args: "run error_023_stack_async.ts",
- output: "error_023_stack_async.ts.out",
+ args: "run run/error_023_stack_async.ts",
+ output: "run/error_023_stack_async.ts.out",
exit_code: 1,
});
itest!(error_024_stack_promise_all {
- args: "run error_024_stack_promise_all.ts",
- output: "error_024_stack_promise_all.ts.out",
+ args: "run run/error_024_stack_promise_all.ts",
+ output: "run/error_024_stack_promise_all.ts.out",
exit_code: 1,
});
itest!(error_025_tab_indent {
- args: "run error_025_tab_indent",
- output: "error_025_tab_indent.out",
+ args: "run run/error_025_tab_indent",
+ output: "run/error_025_tab_indent.out",
exit_code: 1,
});
itest!(error_026_remote_import_error {
- args: "run error_026_remote_import_error.ts",
- output: "error_026_remote_import_error.ts.out",
+ args: "run run/error_026_remote_import_error.ts",
+ output: "run/error_026_remote_import_error.ts.out",
exit_code: 1,
http_server: true,
});
itest!(error_for_await {
- args: "run --reload --check error_for_await.ts",
- output: "error_for_await.ts.out",
+ args: "run --reload --check run/error_for_await.ts",
+ output: "run/error_for_await.ts.out",
exit_code: 1,
});
itest!(error_missing_module_named_import {
- args: "run --reload error_missing_module_named_import.ts",
- output: "error_missing_module_named_import.ts.out",
+ args: "run --reload run/error_missing_module_named_import.ts",
+ output: "run/error_missing_module_named_import.ts.out",
exit_code: 1,
});
itest!(error_no_check {
- args: "run --reload --no-check error_no_check.ts",
- output: "error_no_check.ts.out",
+ args: "run --reload --no-check run/error_no_check.ts",
+ output: "run/error_no_check.ts.out",
exit_code: 1,
});
itest!(error_syntax {
- args: "run --reload error_syntax.js",
+ args: "run --reload run/error_syntax.js",
exit_code: 1,
- output: "error_syntax.js.out",
+ output: "run/error_syntax.js.out",
});
itest!(error_syntax_empty_trailing_line {
- args: "run --reload error_syntax_empty_trailing_line.mjs",
+ args: "run --reload run/error_syntax_empty_trailing_line.mjs",
exit_code: 1,
- output: "error_syntax_empty_trailing_line.mjs.out",
+ output: "run/error_syntax_empty_trailing_line.mjs.out",
});
itest!(error_type_definitions {
- args: "run --reload --check error_type_definitions.ts",
+ args: "run --reload --check run/error_type_definitions.ts",
exit_code: 1,
- output: "error_type_definitions.ts.out",
+ output: "run/error_type_definitions.ts.out",
});
itest!(error_local_static_import_from_remote_ts {
- args: "run --reload http://localhost:4545/error_local_static_import_from_remote.ts",
+ args: "run --reload http://localhost:4545/run/error_local_static_import_from_remote.ts",
exit_code: 1,
http_server: true,
- output: "error_local_static_import_from_remote.ts.out",
+ output: "run/error_local_static_import_from_remote.ts.out",
});
itest!(error_local_static_import_from_remote_js {
- args: "run --reload http://localhost:4545/error_local_static_import_from_remote.js",
+ args: "run --reload http://localhost:4545/run/error_local_static_import_from_remote.js",
exit_code: 1,
http_server: true,
- output: "error_local_static_import_from_remote.js.out",
+ output: "run/error_local_static_import_from_remote.js.out",
});
itest!(exit_error42 {
exit_code: 42,
- args: "run --quiet --reload exit_error42.ts",
- output: "exit_error42.ts.out",
+ args: "run --quiet --reload run/exit_error42.ts",
+ output: "run/exit_error42.ts.out",
});
itest!(set_exit_code_0 {
- args: "run --no-check --unstable set_exit_code_0.ts",
- output: "empty.out",
+ args: "run --no-check --unstable run/set_exit_code_0.ts",
+ output_str: Some(""),
exit_code: 0,
});
itest!(set_exit_code_1 {
- args: "run --no-check --unstable set_exit_code_1.ts",
- output: "empty.out",
+ args: "run --no-check --unstable run/set_exit_code_1.ts",
+ output_str: Some(""),
exit_code: 42,
});
itest!(set_exit_code_2 {
- args: "run --no-check --unstable set_exit_code_2.ts",
- output: "empty.out",
+ args: "run --no-check --unstable run/set_exit_code_2.ts",
+ output_str: Some(""),
exit_code: 42,
});
itest!(op_exit_op_set_exit_code_in_worker {
- args: "run --no-check --unstable --allow-read op_exit_op_set_exit_code_in_worker.ts",
+ args: "run --no-check --unstable --allow-read run/op_exit_op_set_exit_code_in_worker.ts",
exit_code: 21,
- output: "empty.out",
+ output_str: Some(""),
});
itest!(deno_exit_tampering {
- args: "run --no-check --unstable deno_exit_tampering.ts",
- output: "empty.out",
+ args: "run --no-check --unstable run/deno_exit_tampering.ts",
+ output_str: Some(""),
exit_code: 42,
});
itest!(heapstats {
- args: "run --quiet --unstable --v8-flags=--expose-gc heapstats.js",
- output: "heapstats.js.out",
+ args: "run --quiet --unstable --v8-flags=--expose-gc run/heapstats.js",
+ output: "run/heapstats.js.out",
});
itest!(finalization_registry {
args:
- "run --quiet --unstable --v8-flags=--expose-gc finalization_registry.js",
- output: "finalization_registry.js.out",
+ "run --quiet --unstable --v8-flags=--expose-gc run/finalization_registry.js",
+ output: "run/finalization_registry.js.out",
});
itest!(https_import {
- args: "run --quiet --reload --cert tls/RootCA.pem https_import.ts",
- output: "https_import.ts.out",
+ args: "run --quiet --reload --cert tls/RootCA.pem run/https_import.ts",
+ output: "run/https_import.ts.out",
http_server: true,
});
itest!(if_main {
- args: "run --quiet --reload if_main.ts",
- output: "if_main.ts.out",
+ args: "run --quiet --reload run/if_main.ts",
+ output: "run/if_main.ts.out",
});
itest!(import_meta {
- args: "run --quiet --reload --import-map=import_meta.importmap.json import_meta.ts",
- output: "import_meta.ts.out",
+ args: "run --quiet --reload --import-map=run/import_meta/importmap.json run/import_meta/main.ts",
+ output: "run/import_meta/main.out",
});
itest!(main_module {
- args: "run --quiet --allow-read --reload main_module.ts",
- output: "main_module.ts.out",
+ args: "run --quiet --allow-read --reload run/main_module/main.ts",
+ output: "run/main_module/main.out",
});
itest!(no_check {
- args: "run --quiet --reload --no-check 006_url_imports.ts",
- output: "006_url_imports.ts.out",
+ args: "run --quiet --reload --no-check run/006_url_imports.ts",
+ output: "run/006_url_imports.ts.out",
http_server: true,
});
itest!(no_check_decorators {
- args: "run --quiet --reload --no-check no_check_decorators.ts",
- output: "no_check_decorators.ts.out",
+ args: "run --quiet --reload --no-check run/no_check_decorators.ts",
+ output: "run/no_check_decorators.ts.out",
});
itest!(check_remote {
- args: "run --quiet --reload --check=all no_check_remote.ts",
- output: "no_check_remote.ts.disabled.out",
+ args: "run --quiet --reload --check=all run/no_check_remote.ts",
+ output: "run/no_check_remote.ts.disabled.out",
exit_code: 1,
http_server: true,
});
itest!(no_check_remote {
- args: "run --quiet --reload --no-check=remote no_check_remote.ts",
- output: "no_check_remote.ts.enabled.out",
+ args: "run --quiet --reload --no-check=remote run/no_check_remote.ts",
+ output: "run/no_check_remote.ts.enabled.out",
http_server: true,
});
itest!(runtime_decorators {
- args: "run --quiet --reload --no-check runtime_decorators.ts",
- output: "runtime_decorators.ts.out",
+ args: "run --quiet --reload --no-check run/runtime_decorators.ts",
+ output: "run/runtime_decorators.ts.out",
});
itest!(seed_random {
- args: "run --seed=100 seed_random.js",
- output: "seed_random.js.out",
+ args: "run --seed=100 run/seed_random.js",
+ output: "run/seed_random.js.out",
});
itest!(type_definitions {
- args: "run --reload type_definitions.ts",
- output: "type_definitions.ts.out",
+ args: "run --reload run/type_definitions.ts",
+ output: "run/type_definitions.ts.out",
});
itest!(type_definitions_for_export {
- args: "run --reload --check type_definitions_for_export.ts",
- output: "type_definitions_for_export.ts.out",
+ args: "run --reload --check run/type_definitions_for_export.ts",
+ output: "run/type_definitions_for_export.ts.out",
exit_code: 1,
});
itest!(type_directives_01 {
- args: "run --reload --check=all -L debug type_directives_01.ts",
- output: "type_directives_01.ts.out",
+ args: "run --reload --check=all -L debug run/type_directives_01.ts",
+ output: "run/type_directives_01.ts.out",
http_server: true,
});
itest!(type_directives_02 {
- args: "run --reload --check=all -L debug type_directives_02.ts",
- output: "type_directives_02.ts.out",
+ args: "run --reload --check=all -L debug run/type_directives_02.ts",
+ output: "run/type_directives_02.ts.out",
});
itest!(type_directives_js_main {
- args: "run --reload -L debug type_directives_js_main.js",
- output: "type_directives_js_main.js.out",
+ args: "run --reload -L debug run/type_directives_js_main.js",
+ output: "run/type_directives_js_main.js.out",
exit_code: 0,
});
itest!(type_directives_redirect {
- args: "run --reload --check type_directives_redirect.ts",
- output: "type_directives_redirect.ts.out",
+ args: "run --reload --check run/type_directives_redirect.ts",
+ output: "run/type_directives_redirect.ts.out",
http_server: true,
});
itest!(type_headers_deno_types {
- args: "run --reload --check type_headers_deno_types.ts",
- output: "type_headers_deno_types.ts.out",
+ args: "run --reload --check run/type_headers_deno_types.ts",
+ output: "run/type_headers_deno_types.ts.out",
http_server: true,
});
itest!(ts_type_imports {
- args: "run --reload --check ts_type_imports.ts",
- output: "ts_type_imports.ts.out",
+ args: "run --reload --check run/ts_type_imports.ts",
+ output: "run/ts_type_imports.ts.out",
exit_code: 1,
});
itest!(ts_decorators {
- args: "run --reload --check ts_decorators.ts",
- output: "ts_decorators.ts.out",
+ args: "run --reload --check run/ts_decorators.ts",
+ output: "run/ts_decorators.ts.out",
});
itest!(ts_type_only_import {
- args: "run --reload --check ts_type_only_import.ts",
- output: "ts_type_only_import.ts.out",
+ args: "run --reload --check run/ts_type_only_import.ts",
+ output: "run/ts_type_only_import.ts.out",
});
itest!(swc_syntax_error {
- args: "run --reload --check swc_syntax_error.ts",
- output: "swc_syntax_error.ts.out",
+ args: "run --reload --check run/swc_syntax_error.ts",
+ output: "run/swc_syntax_error.ts.out",
exit_code: 1,
});
itest!(unbuffered_stderr {
- args: "run --reload unbuffered_stderr.ts",
- output: "unbuffered_stderr.ts.out",
+ args: "run --reload run/unbuffered_stderr.ts",
+ output: "run/unbuffered_stderr.ts.out",
});
itest!(unbuffered_stdout {
- args: "run --quiet --reload unbuffered_stdout.ts",
- output: "unbuffered_stdout.ts.out",
+ args: "run --quiet --reload run/unbuffered_stdout.ts",
+ output: "run/unbuffered_stdout.ts.out",
});
itest!(v8_flags_run {
- args: "run --v8-flags=--expose-gc v8_flags.js",
- output: "v8_flags.js.out",
+ args: "run --v8-flags=--expose-gc run/v8_flags.js",
+ output: "run/v8_flags.js.out",
});
itest!(v8_flags_unrecognized {
args: "repl --v8-flags=--foo,bar,--trace-gc,-baz",
- output: "v8_flags_unrecognized.out",
+ output: "run/v8_flags_unrecognized.out",
exit_code: 1,
});
itest!(v8_help {
args: "repl --v8-flags=--help",
- output: "v8_help.out",
+ output: "run/v8_help.out",
});
itest!(unsupported_dynamic_import_scheme {
args: "eval import('xxx:')",
- output: "unsupported_dynamic_import_scheme.out",
+ output: "run/unsupported_dynamic_import_scheme.out",
exit_code: 1,
});
itest!(wasm {
- args: "run --quiet wasm.ts",
- output: "wasm.ts.out",
+ args: "run --quiet run/wasm.ts",
+ output: "run/wasm.ts.out",
});
itest!(wasm_shared {
- args: "run --quiet wasm_shared.ts",
- output: "wasm_shared.out",
+ args: "run --quiet run/wasm_shared.ts",
+ output: "run/wasm_shared.out",
});
itest!(wasm_async {
- args: "run wasm_async.js",
- output: "wasm_async.out",
+ args: "run run/wasm_async.js",
+ output: "run/wasm_async.out",
});
itest!(wasm_unreachable {
- args: "run --allow-read wasm_unreachable.js",
- output: "wasm_unreachable.out",
+ args: "run --allow-read run/wasm_unreachable.js",
+ output: "run/wasm_unreachable.out",
exit_code: 1,
});
itest!(wasm_url {
- args: "run --quiet --allow-net=localhost:4545 wasm_url.js",
- output: "wasm_url.out",
+ args: "run --quiet --allow-net=localhost:4545 run/wasm_url.js",
+ output: "run/wasm_url.out",
exit_code: 1,
http_server: true,
});
itest!(weakref {
- args: "run --quiet --reload weakref.ts",
- output: "weakref.ts.out",
+ args: "run --quiet --reload run/weakref.ts",
+ output: "run/weakref.ts.out",
});
itest!(top_level_await_order {
- args: "run --allow-read top_level_await_order.js",
- output: "top_level_await_order.out",
+ args: "run --allow-read run/top_level_await/order.js",
+ output: "run/top_level_await/order.out",
});
itest!(top_level_await_loop {
- args: "run --allow-read top_level_await_loop.js",
- output: "top_level_await_loop.out",
+ args: "run --allow-read run/top_level_await/loop.js",
+ output: "run/top_level_await/loop.out",
});
itest!(top_level_await_circular {
- args: "run --allow-read top_level_await_circular.js",
- output: "top_level_await_circular.out",
+ args: "run --allow-read run/top_level_await/circular.js",
+ output: "run/top_level_await/circular.out",
exit_code: 1,
});
// Regression test for https://github.com/denoland/deno/issues/11238.
itest!(top_level_await_nested {
- args: "run --allow-read top_level_await_nested/main.js",
- output: "top_level_await_nested.out",
+ args: "run --allow-read run/top_level_await/nested/main.js",
+ output: "run/top_level_await/nested.out",
});
itest!(top_level_await_unresolved {
- args: "run top_level_await_unresolved.js",
- output: "top_level_await_unresolved.out",
+ args: "run run/top_level_await/unresolved.js",
+ output: "run/top_level_await/unresolved.out",
exit_code: 1,
});
itest!(top_level_await {
- args: "run --allow-read top_level_await.js",
- output: "top_level_await.out",
+ args: "run --allow-read run/top_level_await/top_level_await.js",
+ output: "run/top_level_await/top_level_await.out",
});
itest!(top_level_await_ts {
- args: "run --quiet --allow-read top_level_await.ts",
- output: "top_level_await.out",
+ args: "run --quiet --allow-read run/top_level_await/top_level_await.ts",
+ output: "run/top_level_await/top_level_await.out",
});
itest!(top_level_for_await {
- args: "run --quiet top_level_for_await.js",
- output: "top_level_for_await.out",
+ args: "run --quiet run/top_level_await/top_level_for_await.js",
+ output: "run/top_level_await/top_level_for_await.out",
});
itest!(top_level_for_await_ts {
- args: "run --quiet top_level_for_await.ts",
- output: "top_level_for_await.out",
+ args: "run --quiet run/top_level_await/top_level_for_await.ts",
+ output: "run/top_level_await/top_level_for_await.out",
});
itest!(unstable_disabled {
- args: "run --reload --check unstable.ts",
+ args: "run --reload --check run/unstable.ts",
exit_code: 1,
- output: "unstable_disabled.out",
+ output: "run/unstable_disabled.out",
});
itest!(unstable_enabled {
- args: "run --quiet --reload --unstable unstable.ts",
- output: "unstable_enabled.out",
+ args: "run --quiet --reload --unstable run/unstable.ts",
+ output: "run/unstable_enabled.out",
});
itest!(unstable_disabled_js {
- args: "run --reload unstable.js",
- output: "unstable_disabled_js.out",
+ args: "run --reload run/unstable.js",
+ output: "run/unstable_disabled_js.out",
});
itest!(unstable_enabled_js {
- args: "run --quiet --reload --unstable unstable.ts",
- output: "unstable_enabled_js.out",
+ args: "run --quiet --reload --unstable run/unstable.ts",
+ output: "run/unstable_enabled_js.out",
});
itest!(unstable_worker {
- args: "run --reload --unstable --quiet --allow-read unstable_worker.ts",
- output: "unstable_worker.ts.out",
+ args: "run --reload --unstable --quiet --allow-read run/unstable_worker.ts",
+ output: "run/unstable_worker.ts.out",
});
-itest!(_053_import_compression {
- args: "run --quiet --reload --allow-net 053_import_compression/main.ts",
- output: "053_import_compression.out",
+itest!(import_compression {
+ args: "run --quiet --reload --allow-net run/import_compression/main.ts",
+ output: "run/import_compression/main.out",
http_server: true,
});
itest!(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",
+ args: "run --quiet --reload --cert tls/RootCA.pem https://localhost:5545/run/disallow_http_from_https.js",
+ output: "run/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/disallow_http_from_https.ts",
- output: "disallow_http_from_https_ts.out",
+ args: "run --quiet --reload --cert tls/RootCA.pem https://localhost:5545/run/disallow_http_from_https.ts",
+ output: "run/disallow_http_from_https_ts.out",
http_server: true,
exit_code: 1,
});
itest!(dynamic_import_conditional {
- args: "run --quiet --reload dynamic_import_conditional.js",
- output: "dynamic_import_conditional.js.out",
+ args: "run --quiet --reload run/dynamic_import_conditional.js",
+ output: "run/dynamic_import_conditional.js.out",
});
itest!(tsx_imports {
- args: "run --reload --check tsx_imports.ts",
- output: "tsx_imports.ts.out",
+ args: "run --reload --check run/tsx_imports/tsx_imports.ts",
+ output: "run/tsx_imports/tsx_imports.ts.out",
});
itest!(fix_dynamic_import_errors {
- args: "run --reload fix_dynamic_import_errors.js",
- output: "fix_dynamic_import_errors.js.out",
+ args: "run --reload run/fix_dynamic_import_errors.js",
+ output: "run/fix_dynamic_import_errors.js.out",
});
itest!(fix_emittable_skipped {
- args: "run --reload fix_emittable_skipped.js",
- output: "fix_emittable_skipped.ts.out",
+ args: "run --reload run/fix_emittable_skipped.js",
+ output: "run/fix_emittable_skipped.ts.out",
});
itest!(fix_exotic_specifiers {
- args: "run --quiet --reload fix_exotic_specifiers.ts",
- output: "fix_exotic_specifiers.ts.out",
+ args: "run --quiet --reload run/fix_exotic_specifiers.ts",
+ output: "run/fix_exotic_specifiers.ts.out",
});
itest!(fix_js_import_js {
- args: "run --quiet --reload fix_js_import_js.ts",
- output: "fix_js_import_js.ts.out",
+ args: "run --quiet --reload run/fix_js_import_js.ts",
+ output: "run/fix_js_import_js.ts.out",
});
itest!(fix_js_imports {
- args: "run --quiet --reload fix_js_imports.ts",
- output: "fix_js_imports.ts.out",
+ args: "run --quiet --reload run/fix_js_imports.ts",
+ output: "run/fix_js_imports.ts.out",
});
itest!(fix_tsc_file_exists {
args: "run --quiet --reload tsc/test.js",
- output: "fix_tsc_file_exists.out",
+ output: "run/fix_tsc_file_exists.out",
});
itest!(fix_worker_dispatchevent {
- args: "run --quiet --reload fix_worker_dispatchevent.ts",
- output: "fix_worker_dispatchevent.ts.out",
+ args: "run --quiet --reload run/fix_worker_dispatchevent.ts",
+ output: "run/fix_worker_dispatchevent.ts.out",
});
itest!(es_private_fields {
- args: "run --quiet --reload es_private_fields.js",
- output: "es_private_fields.js.out",
+ args: "run --quiet --reload run/es_private_fields.js",
+ output: "run/es_private_fields.js.out",
});
itest!(cjs_imports {
- args: "run --quiet --reload cjs_imports.ts",
- output: "cjs_imports.ts.out",
+ args: "run --quiet --reload run/cjs_imports/main.ts",
+ output: "run/cjs_imports/main.out",
});
itest!(ts_import_from_js {
- args: "run --quiet --reload ts_import_from_js.js",
- output: "ts_import_from_js.js.out",
+ args: "run --quiet --reload run/ts_import_from_js/main.js",
+ output: "run/ts_import_from_js/main.out",
http_server: true,
});
itest!(jsx_import_from_ts {
- args: "run --quiet --reload jsx_import_from_ts.ts",
- output: "jsx_import_from_ts.ts.out",
+ args: "run --quiet --reload run/jsx_import_from_ts.ts",
+ output: "run/jsx_import_from_ts.ts.out",
});
itest!(jsx_import_source_pragma {
- args: "run --reload jsx_import_source_pragma.tsx",
- output: "jsx_import_source.out",
+ args: "run --reload run/jsx_import_source_pragma.tsx",
+ output: "run/jsx_import_source.out",
http_server: true,
});
itest!(jsx_import_source_pragma_with_config {
- args: "run --reload --config jsx/deno-jsx.jsonc jsx_import_source_pragma.tsx",
- output: "jsx_import_source.out",
+ args:
+ "run --reload --config jsx/deno-jsx.jsonc run/jsx_import_source_pragma.tsx",
+ output: "run/jsx_import_source.out",
http_server: true,
});
itest!(jsx_import_source_pragma_with_dev_config {
args:
- "run --reload --config jsx/deno-jsxdev.jsonc jsx_import_source_pragma.tsx",
- output: "jsx_import_source_dev.out",
+ "run --reload --config jsx/deno-jsxdev.jsonc run/jsx_import_source_pragma.tsx",
+ output: "run/jsx_import_source_dev.out",
http_server: true,
});
itest!(jsx_import_source_no_pragma {
args:
- "run --reload --config jsx/deno-jsx.jsonc jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source.out",
+ "run --reload --config jsx/deno-jsx.jsonc run/jsx_import_source_no_pragma.tsx",
+ output: "run/jsx_import_source.out",
http_server: true,
});
itest!(jsx_import_source_no_pragma_dev {
- args: "run --reload --config jsx/deno-jsxdev.jsonc jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source_dev.out",
+ args: "run --reload --config jsx/deno-jsxdev.jsonc run/jsx_import_source_no_pragma.tsx",
+ output: "run/jsx_import_source_dev.out",
http_server: true,
});
itest!(jsx_import_source_pragma_import_map {
- args: "run --reload --import-map jsx/import-map.json jsx_import_source_pragma_import_map.tsx",
- output: "jsx_import_source_import_map.out",
+ args: "run --reload --import-map jsx/import-map.json run/jsx_import_source_pragma_import_map.tsx",
+ output: "run/jsx_import_source_import_map.out",
http_server: true,
});
itest!(jsx_import_source_pragma_import_map_dev {
- args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc jsx_import_source_pragma_import_map.tsx",
- output: "jsx_import_source_import_map_dev.out",
+ args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc run/jsx_import_source_pragma_import_map.tsx",
+ output: "run/jsx_import_source_import_map_dev.out",
http_server: true,
});
itest!(jsx_import_source_import_map {
- args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsx-import-map.jsonc jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source_import_map.out",
+ args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsx-import-map.jsonc run/jsx_import_source_no_pragma.tsx",
+ output: "run/jsx_import_source_import_map.out",
http_server: true,
});
itest!(jsx_import_source_import_map_dev {
- args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source_import_map_dev.out",
+ args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc run/jsx_import_source_no_pragma.tsx",
+ output: "run/jsx_import_source_import_map_dev.out",
http_server: true,
});
itest!(jsx_import_source_import_map_scoped {
args: "run --reload --import-map jsx/import-map-scoped.json --config jsx/deno-jsx-import-map.jsonc subdir/jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source_import_map.out",
+ output: "run/jsx_import_source_import_map.out",
http_server: true,
});
itest!(jsx_import_source_import_map_scoped_dev {
args: "run --reload --import-map jsx/import-map-scoped.json --config jsx/deno-jsxdev-import-map.jsonc subdir/jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source_import_map_dev.out",
+ output: "run/jsx_import_source_import_map_dev.out",
http_server: true,
});
itest!(jsx_import_source_pragma_no_check {
- args: "run --reload --no-check jsx_import_source_pragma.tsx",
- output: "jsx_import_source.out",
+ args: "run --reload --no-check run/jsx_import_source_pragma.tsx",
+ output: "run/jsx_import_source.out",
http_server: true,
});
itest!(jsx_import_source_pragma_with_config_no_check {
- args: "run --reload --config jsx/deno-jsx.jsonc --no-check jsx_import_source_pragma.tsx",
- output: "jsx_import_source.out",
+ args: "run --reload --config jsx/deno-jsx.jsonc --no-check run/jsx_import_source_pragma.tsx",
+ output: "run/jsx_import_source.out",
http_server: true,
});
-// itest!(jsx_import_source_pragma_with_dev_config_no_check {
-// args:
-// "run --reload --config jsx/deno-jsxdev.jsonc --no-check jsx_import_source_pragma.tsx",
-// output: "jsx_import_source_dev.out",
-// http_server: true,
-// });
-
itest!(jsx_import_source_no_pragma_no_check {
args:
- "run --reload --config jsx/deno-jsx.jsonc --no-check jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source.out",
+ "run --reload --config jsx/deno-jsx.jsonc --no-check run/jsx_import_source_no_pragma.tsx",
+ output: "run/jsx_import_source.out",
http_server: true,
});
-// itest!(jsx_import_source_no_pragma_dev_no_check {
-// args: "run --reload --config jsx/deno-jsxdev.jsonc --no-check jsx_import_source_no_pragma.tsx",
-// output: "jsx_import_source_dev.out",
-// http_server: true,
-// });
-
itest!(jsx_import_source_pragma_import_map_no_check {
- args: "run --reload --import-map jsx/import-map.json --no-check jsx_import_source_pragma_import_map.tsx",
- output: "jsx_import_source_import_map.out",
+ args: "run --reload --import-map jsx/import-map.json --no-check run/jsx_import_source_pragma_import_map.tsx",
+ output: "run/jsx_import_source_import_map.out",
http_server: true,
});
-// itest!(jsx_import_source_pragma_import_map_dev_no_check {
-// args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc --no-check jsx_import_source_pragma_import_map.tsx",
-// output: "jsx_import_source_import_map_dev.out",
-// http_server: true,
-// });
-
itest!(jsx_import_source_import_map_no_check {
- args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsx-import-map.jsonc --no-check jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source_import_map.out",
+ args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsx-import-map.jsonc --no-check run/jsx_import_source_no_pragma.tsx",
+ output: "run/jsx_import_source_import_map.out",
http_server: true,
});
-// itest!(jsx_import_source_import_map_dev_no_check {
-// args: "run --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc --no-check jsx_import_source_no_pragma.tsx",
-// output: "jsx_import_source_import_map_dev.out",
-// http_server: true,
-// });
+itest!(jsx_import_source_error {
+ args: "run --config jsx/deno-jsx-error.jsonc --check run/jsx_import_source_no_pragma.tsx",
+ output: "run/jsx_import_source_error.out",
+ exit_code: 1,
+});
// TODO(#11128): Flaky. Re-enable later.
// itest!(single_compile_with_reload {
-// args: "run --reload --allow-read single_compile_with_reload.ts",
-// output: "single_compile_with_reload.ts.out",
+// args: "run --relcert/oad --allow-read run/single_compile_with_reload.ts",
+// output: "run/single_compile_with_reload.ts.out",
// });
itest!(proto_exploit {
- args: "run proto_exploit.js",
- output: "proto_exploit.js.out",
+ args: "run run/proto_exploit.js",
+ output: "run/proto_exploit.js.out",
});
itest!(reference_types {
- args: "run --reload --quiet reference_types.ts",
- output: "reference_types.ts.out",
+ args: "run --reload --quiet run/reference_types.ts",
+ output: "run/reference_types.ts.out",
});
itest!(references_types_remote {
http_server: true,
- args: "run --reload --quiet reference_types_remote.ts",
- output: "reference_types_remote.ts.out",
+ args: "run --reload --quiet run/reference_types_remote.ts",
+ output: "run/reference_types_remote.ts.out",
+});
+
+itest!(reference_types_error {
+ args:
+ "run --config run/checkjs.tsconfig.json --check run/reference_types_error.js",
+ output: "run/reference_types_error.js.out",
+ exit_code: 1,
+});
+
+itest!(reference_types_error_no_check {
+ args: "run --no-check run/reference_types_error.js",
+ output_str: Some(""),
});
itest!(import_data_url_error_stack {
- args: "run --quiet --reload import_data_url_error_stack.ts",
- output: "import_data_url_error_stack.ts.out",
+ args: "run --quiet --reload run/import_data_url_error_stack.ts",
+ output: "run/import_data_url_error_stack.ts.out",
exit_code: 1,
});
itest!(import_data_url_import_relative {
- args: "run --quiet --reload import_data_url_import_relative.ts",
- output: "import_data_url_import_relative.ts.out",
+ args: "run --quiet --reload run/import_data_url_import_relative.ts",
+ output: "run/import_data_url_import_relative.ts.out",
exit_code: 1,
});
itest!(import_data_url_import_map {
- args: "run --quiet --reload --import-map import_maps/import_map.json import_data_url.ts",
- output: "import_data_url.ts.out",
+ args: "run --quiet --reload --import-map import_maps/import_map.json run/import_data_url.ts",
+ output: "run/import_data_url.ts.out",
});
itest!(import_data_url_imports {
- args: "run --quiet --reload import_data_url_imports.ts",
- output: "import_data_url_imports.ts.out",
+ args: "run --quiet --reload run/import_data_url_imports.ts",
+ output: "run/import_data_url_imports.ts.out",
http_server: true,
});
itest!(import_data_url_jsx {
- args: "run --quiet --reload import_data_url_jsx.ts",
- output: "import_data_url_jsx.ts.out",
+ args: "run --quiet --reload run/import_data_url_jsx.ts",
+ output: "run/import_data_url_jsx.ts.out",
});
itest!(import_data_url {
- args: "run --quiet --reload import_data_url.ts",
- output: "import_data_url.ts.out",
+ args: "run --quiet --reload run/import_data_url.ts",
+ output: "run/import_data_url.ts.out",
});
itest!(import_dynamic_data_url {
- args: "run --quiet --reload import_dynamic_data_url.ts",
- output: "import_dynamic_data_url.ts.out",
+ args: "run --quiet --reload run/import_dynamic_data_url.ts",
+ output: "run/import_dynamic_data_url.ts.out",
});
itest!(import_blob_url_error_stack {
- args: "run --quiet --reload import_blob_url_error_stack.ts",
- output: "import_blob_url_error_stack.ts.out",
+ args: "run --quiet --reload run/import_blob_url_error_stack.ts",
+ output: "run/import_blob_url_error_stack.ts.out",
exit_code: 1,
});
itest!(import_blob_url_import_relative {
- args: "run --quiet --reload import_blob_url_import_relative.ts",
- output: "import_blob_url_import_relative.ts.out",
+ args: "run --quiet --reload run/import_blob_url_import_relative.ts",
+ output: "run/import_blob_url_import_relative.ts.out",
exit_code: 1,
});
itest!(import_blob_url_imports {
args:
- "run --quiet --reload --allow-net=localhost:4545 import_blob_url_imports.ts",
- output: "import_blob_url_imports.ts.out",
+ "run --quiet --reload --allow-net=localhost:4545 run/import_blob_url_imports.ts",
+ output: "run/import_blob_url_imports.ts.out",
http_server: true,
});
itest!(import_blob_url_jsx {
- args: "run --quiet --reload import_blob_url_jsx.ts",
- output: "import_blob_url_jsx.ts.out",
+ args: "run --quiet --reload run/import_blob_url_jsx.ts",
+ output: "run/import_blob_url_jsx.ts.out",
});
itest!(import_blob_url {
- args: "run --quiet --reload import_blob_url.ts",
- output: "import_blob_url.ts.out",
+ args: "run --quiet --reload run/import_blob_url.ts",
+ output: "run/import_blob_url.ts.out",
});
itest!(import_file_with_colon {
- args: "run --quiet --reload import_file_with_colon.ts",
- output: "import_file_with_colon.ts.out",
+ args: "run --quiet --reload run/import_file_with_colon.ts",
+ output: "run/import_file_with_colon.ts.out",
http_server: true,
});
itest!(import_extensionless {
- args: "run --quiet --reload import_extensionless.ts",
- output: "import_extensionless.ts.out",
+ args: "run --quiet --reload run/import_extensionless.ts",
+ output: "run/import_extensionless.ts.out",
http_server: true,
});
itest!(classic_workers_event_loop {
args:
- "run --enable-testing-features-do-not-use classic_workers_event_loop.js",
- output: "classic_workers_event_loop.js.out",
+ "run --enable-testing-features-do-not-use run/classic_workers_event_loop.js",
+ output: "run/classic_workers_event_loop.js.out",
});
// FIXME(bartlomieju): disabled, because this test is very flaky on CI
// itest!(local_sources_not_cached_in_memory {
-// args: "run --allow-read --allow-write no_mem_cache.js",
-// output: "no_mem_cache.js.out",
+// args: "run --allow-read --allow-write run/no_mem_cache.js",
+// output: "run/no_mem_cache.js.out",
// });
// This test checks that inline source map data is used. It uses a hand crafted
@@ -1529,8 +1538,8 @@ itest!(classic_workers_event_loop {
// Source line is not remapped because no inline source contents are included in
// the sourcemap and the file is not present in the dependency graph.
itest!(inline_js_source_map_2 {
- args: "run --quiet inline_js_source_map_2.js",
- output: "inline_js_source_map_2.js.out",
+ args: "run --quiet run/inline_js_source_map_2.js",
+ output: "run/inline_js_source_map_2.js.out",
exit_code: 1,
});
@@ -1540,8 +1549,8 @@ itest!(inline_js_source_map_2 {
// Source line remapped using th inline source contents that are included in the
// inline source map.
itest!(inline_js_source_map_2_with_inline_contents {
- args: "run --quiet inline_js_source_map_2_with_inline_contents.js",
- output: "inline_js_source_map_2_with_inline_contents.js.out",
+ args: "run --quiet run/inline_js_source_map_2_with_inline_contents.js",
+ output: "run/inline_js_source_map_2_with_inline_contents.js.out",
exit_code: 1,
});
@@ -1552,8 +1561,8 @@ itest!(inline_js_source_map_2_with_inline_contents {
// was not commented out. The source line is remapped using source contents that
// from the module graph.
itest!(inline_js_source_map_with_contents_from_graph {
- args: "run --quiet inline_js_source_map_with_contents_from_graph.js",
- output: "inline_js_source_map_with_contents_from_graph.js.out",
+ args: "run --quiet run/inline_js_source_map_with_contents_from_graph.js",
+ output: "run/inline_js_source_map_with_contents_from_graph.js.out",
exit_code: 1,
http_server: true,
});
@@ -1564,78 +1573,62 @@ itest!(inline_js_source_map_with_contents_from_graph {
// `program_state.maybe_import_map` to access the import map underneath.
itest!(error_import_map_unable_to_load {
args: "run --import-map=import_maps/does_not_exist.json import_maps/test.ts",
- output: "error_import_map_unable_to_load.out",
+ output: "run/error_import_map_unable_to_load.out",
exit_code: 1,
});
// Test that setting `self` in the main thread to some other value doesn't break
// the world.
itest!(replace_self {
- args: "run replace_self.js",
- output: "replace_self.js.out",
+ args: "run run/replace_self.js",
+ output: "run/replace_self.js.out",
});
itest!(worker_event_handler_test {
- args: "run --quiet --reload --allow-read worker_event_handler_test.js",
- output: "worker_event_handler_test.js.out",
+ args: "run --quiet --reload --allow-read run/worker_event_handler_test.js",
+ output: "run/worker_event_handler_test.js.out",
});
itest!(worker_close_race {
- args: "run --quiet --reload --allow-read worker_close_race.js",
- output: "worker_close_race.js.out",
+ args: "run --quiet --reload --allow-read run/worker_close_race.js",
+ output: "run/worker_close_race.js.out",
});
itest!(worker_drop_handle_race {
- args: "run --quiet --reload --allow-read worker_drop_handle_race.js",
- output: "worker_drop_handle_race.js.out",
+ args: "run --quiet --reload --allow-read run/worker_drop_handle_race.js",
+ output: "run/worker_drop_handle_race.js.out",
exit_code: 1,
});
itest!(worker_drop_handle_race_terminate {
- args: "run --unstable worker_drop_handle_race_terminate.js",
- output: "worker_drop_handle_race_terminate.js.out",
+ args: "run --unstable run/worker_drop_handle_race_terminate.js",
+ output: "run/worker_drop_handle_race_terminate.js.out",
});
itest!(worker_close_nested {
- args: "run --quiet --reload --allow-read worker_close_nested.js",
- output: "worker_close_nested.js.out",
+ args: "run --quiet --reload --allow-read run/worker_close_nested.js",
+ output: "run/worker_close_nested.js.out",
});
itest!(worker_message_before_close {
- args: "run --quiet --reload --allow-read worker_message_before_close.js",
- output: "worker_message_before_close.js.out",
+ args: "run --quiet --reload --allow-read run/worker_message_before_close.js",
+ output: "run/worker_message_before_close.js.out",
});
itest!(worker_close_in_wasm_reactions {
- args: "run --quiet --reload --allow-read worker_close_in_wasm_reactions.js",
- output: "worker_close_in_wasm_reactions.js.out",
-});
-
-itest!(reference_types_error {
- args: "run --config checkjs.tsconfig.json --check reference_types_error.js",
- output: "reference_types_error.js.out",
- exit_code: 1,
-});
-
-itest!(reference_types_error_no_check {
- args: "run --no-check reference_types_error.js",
- output_str: Some(""),
-});
-
-itest!(jsx_import_source_error {
- args: "run --config jsx/deno-jsx-error.jsonc --check jsx_import_source_no_pragma.tsx",
- output: "jsx_import_source_error.out",
- exit_code: 1,
+ args:
+ "run --quiet --reload --allow-read run/worker_close_in_wasm_reactions.js",
+ output: "run/worker_close_in_wasm_reactions.js.out",
});
itest!(shebang_tsc {
- args: "run --quiet shebang.ts",
- output: "shebang.ts.out",
+ args: "run --quiet --check run/shebang.ts",
+ output: "run/shebang.ts.out",
});
itest!(shebang_swc {
- args: "run --quiet --no-check shebang.ts",
- output: "shebang.ts.out",
+ args: "run --quiet run/shebang.ts",
+ output: "run/shebang.ts.out",
});
itest!(shebang_with_json_imports_tsc {
@@ -1655,7 +1648,7 @@ fn no_validate_asm() {
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
- .arg("no_validate_asm.js")
+ .arg("run/no_validate_asm.js")
.stderr(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
@@ -1673,7 +1666,7 @@ fn exec_path() {
.current_dir(util::testdata_path())
.arg("run")
.arg("--allow-read")
- .arg("exec_path.ts")
+ .arg("run/exec_path.ts")
.stdout(Stdio::piped())
.spawn()
.unwrap()
@@ -1701,7 +1694,7 @@ fn run_deno_script_constrained(
script_path: std::path::PathBuf,
constraints: WinProcConstraints,
) -> Result<(), i64> {
- let file_path = "DenoWinRunner.ps1";
+ let file_path = "assets/DenoWinRunner.ps1";
let constraints = match constraints {
WinProcConstraints::NoStdIn => "1",
WinProcConstraints::NoStdOut => "2",
@@ -1799,7 +1792,7 @@ fn rust_log() {
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
- .arg("001_hello.js")
+ .arg("run/001_hello.js")
.stderr(Stdio::piped())
.spawn()
.unwrap()
@@ -1812,7 +1805,7 @@ fn rust_log() {
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
- .arg("001_hello.js")
+ .arg("run/001_hello.js")
.env("RUST_LOG", "debug")
.stderr(Stdio::piped())
.spawn()
@@ -1833,7 +1826,7 @@ fn dont_cache_on_check_fail() {
.arg("run")
.arg("--check=all")
.arg("--reload")
- .arg("error_003_typescript.ts")
+ .arg("run/error_003_typescript.ts")
.stderr(Stdio::piped())
.spawn()
.unwrap()
@@ -1847,7 +1840,7 @@ fn dont_cache_on_check_fail() {
.current_dir(util::testdata_path())
.arg("run")
.arg("--check=all")
- .arg("error_003_typescript.ts")
+ .arg("run/error_003_typescript.ts")
.stderr(Stdio::piped())
.spawn()
.unwrap()
@@ -1869,7 +1862,7 @@ mod permissions {
.arg("run")
.arg("--unstable")
.arg(format!("--allow-{0}", permission))
- .arg("permission_test.ts")
+ .arg("run/permission_test.ts")
.arg(format!("{0}Required", permission))
.spawn()
.unwrap()
@@ -1885,7 +1878,10 @@ mod permissions {
for permission in &util::PERMISSION_VARIANTS {
let (_, err) = util::run_and_collect_output(
false,
- &format!("run --unstable permission_test.ts {0}Required", permission),
+ &format!(
+ "run --unstable run/permission_test.ts {0}Required",
+ permission
+ ),
None,
None,
false,
@@ -1909,9 +1905,9 @@ mod permissions {
.into_string()
.unwrap()
))
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.arg(permission)
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.spawn()
.unwrap()
.wait()
@@ -1927,7 +1923,7 @@ mod permissions {
let (_, err) = util::run_and_collect_output(
false,
&format!(
- "run --allow-{0}={1} complex_permissions_test.ts {0} {2}",
+ "run --allow-{0}={1} run/complex_permissions_test.ts {0} {2}",
permission,
util::testdata_path()
.into_os_string()
@@ -1962,9 +1958,9 @@ mod permissions {
.into_string()
.unwrap()
))
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.arg(permission)
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.spawn()
.unwrap()
.wait()
@@ -1989,7 +1985,7 @@ mod permissions {
let (_, err) = util::run_and_collect_output(
false,
&format!(
- "run --allow-{0}={1},{2} complex_permissions_test.ts {0} {3}",
+ "run --allow-{0}={1},{2} run/complex_permissions_test.ts {0} {3}",
permission,
test_dir,
js_dir,
@@ -2024,9 +2020,9 @@ mod permissions {
.current_dir(&util::testdata_path())
.arg("run")
.arg(format!("--allow-{0}={1},{2}", permission, test_dir, js_dir))
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.arg(permission)
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.spawn()
.unwrap()
.wait()
@@ -2043,9 +2039,9 @@ mod permissions {
.current_dir(&util::testdata_path())
.arg("run")
.arg(format!("--allow-{0}=.", permission))
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.arg(permission)
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.spawn()
.unwrap()
.wait()
@@ -2062,9 +2058,9 @@ mod permissions {
.current_dir(&util::testdata_path())
.arg("run")
.arg(format!("--allow-{0}=tls/../", permission))
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.arg(permission)
- .arg("complex_permissions_test.ts")
+ .arg("run/complex_permissions_test.ts")
.spawn()
.unwrap()
.wait()
@@ -2077,7 +2073,7 @@ mod permissions {
fn net_fetch_allow_localhost_4545() {
let (_, err) = util::run_and_collect_output(
true,
- "run --allow-net=localhost:4545 complex_permissions_test.ts netFetch http://localhost:4545/",
+ "run --allow-net=localhost:4545 run/complex_permissions_test.ts netFetch http://localhost:4545/",
None,
None,
true,
@@ -2089,7 +2085,7 @@ mod permissions {
fn net_fetch_allow_deno_land() {
let (_, err) = util::run_and_collect_output(
false,
- "run --allow-net=deno.land complex_permissions_test.ts netFetch http://localhost:4545/",
+ "run --allow-net=deno.land run/complex_permissions_test.ts netFetch http://localhost:4545/",
None,
None,
true,
@@ -2101,7 +2097,7 @@ mod permissions {
fn net_fetch_localhost_4545_fail() {
let (_, err) = util::run_and_collect_output(
false,
- "run --allow-net=localhost:4545 complex_permissions_test.ts netFetch http://localhost:4546/",
+ "run --allow-net=localhost:4545 run/complex_permissions_test.ts netFetch http://localhost:4546/",
None,
None,
true,
@@ -2113,7 +2109,7 @@ mod permissions {
fn net_fetch_localhost() {
let (_, err) = util::run_and_collect_output(
true,
- "run --allow-net=localhost complex_permissions_test.ts netFetch http://localhost:4545/ http://localhost:4546/ http://localhost:4547/",
+ "run --allow-net=localhost run/complex_permissions_test.ts netFetch http://localhost:4545/ http://localhost:4546/ http://localhost:4547/",
None,
None,
true,
@@ -2125,7 +2121,7 @@ mod permissions {
fn net_connect_allow_localhost_ip_4555() {
let (_, err) = util::run_and_collect_output(
true,
- "run --allow-net=127.0.0.1:4545 complex_permissions_test.ts netConnect 127.0.0.1:4545",
+ "run --allow-net=127.0.0.1:4545 run/complex_permissions_test.ts netConnect 127.0.0.1:4545",
None,
None,
true,
@@ -2137,7 +2133,7 @@ mod permissions {
fn net_connect_allow_deno_land() {
let (_, err) = util::run_and_collect_output(
false,
- "run --allow-net=deno.land complex_permissions_test.ts netConnect 127.0.0.1:4546",
+ "run --allow-net=deno.land run/complex_permissions_test.ts netConnect 127.0.0.1:4546",
None,
None,
true,
@@ -2149,7 +2145,7 @@ mod permissions {
fn net_connect_allow_localhost_ip_4545_fail() {
let (_, err) = util::run_and_collect_output(
false,
- "run --allow-net=127.0.0.1:4545 complex_permissions_test.ts netConnect 127.0.0.1:4546",
+ "run --allow-net=127.0.0.1:4545 run/complex_permissions_test.ts netConnect 127.0.0.1:4546",
None,
None,
true,
@@ -2161,7 +2157,7 @@ mod permissions {
fn net_connect_allow_localhost_ip() {
let (_, err) = util::run_and_collect_output(
true,
- "run --allow-net=127.0.0.1 complex_permissions_test.ts netConnect 127.0.0.1:4545 127.0.0.1:4546 127.0.0.1:4547",
+ "run --allow-net=127.0.0.1 run/complex_permissions_test.ts netConnect 127.0.0.1:4545 127.0.0.1:4546 127.0.0.1:4547",
None,
None,
true,
@@ -2173,7 +2169,7 @@ mod permissions {
fn net_listen_allow_localhost_4555() {
let (_, err) = util::run_and_collect_output(
true,
- "run --allow-net=localhost:4558 complex_permissions_test.ts netListen localhost:4558",
+ "run --allow-net=localhost:4558 run/complex_permissions_test.ts netListen localhost:4558",
None,
None,
false,
@@ -2185,7 +2181,7 @@ mod permissions {
fn net_listen_allow_deno_land() {
let (_, err) = util::run_and_collect_output(
false,
- "run --allow-net=deno.land complex_permissions_test.ts netListen localhost:4545",
+ "run --allow-net=deno.land run/complex_permissions_test.ts netListen localhost:4545",
None,
None,
false,
@@ -2197,7 +2193,7 @@ mod permissions {
fn net_listen_allow_localhost_4555_fail() {
let (_, err) = util::run_and_collect_output(
false,
- "run --allow-net=localhost:4555 complex_permissions_test.ts netListen localhost:4556",
+ "run --allow-net=localhost:4555 run/complex_permissions_test.ts netListen localhost:4556",
None,
None,
false,
@@ -2211,7 +2207,7 @@ mod permissions {
// target/debug/test_server
let (_, err) = util::run_and_collect_output(
true,
- "run --allow-net=localhost complex_permissions_test.ts netListen localhost:4600",
+ "run --allow-net=localhost run/complex_permissions_test.ts netListen localhost:4600",
None,
None,
false,
@@ -2221,7 +2217,7 @@ mod permissions {
#[test]
fn _061_permissions_request() {
- let args = "run --quiet 061_permissions_request.ts";
+ let args = "run --quiet run/061_permissions_request.ts";
use util::PtyData::*;
util::test_pty2(args, vec![
Output("⚠️ ️Deno requests read access to \"foo\". Run again with --allow-read to bypass this prompt.\r\n Allow? [y/n (y = yes allow, n = no deny)] "),
@@ -2236,7 +2232,7 @@ mod permissions {
#[test]
fn _062_permissions_request_global() {
- let args = "run --quiet 062_permissions_request_global.ts";
+ let args = "run --quiet run/062_permissions_request_global.ts";
use util::PtyData::*;
util::test_pty2(args, vec![
Output("⚠️ ️Deno requests read access. Run again with --allow-read to bypass this prompt.\r\n Allow? [y/n (y = yes allow, n = no deny)] "),
@@ -2248,18 +2244,18 @@ mod permissions {
}
itest!(_063_permissions_revoke {
- args: "run --allow-read=foo,bar 063_permissions_revoke.ts",
- output: "063_permissions_revoke.ts.out",
+ args: "run --allow-read=foo,bar run/063_permissions_revoke.ts",
+ output: "run/063_permissions_revoke.ts.out",
});
itest!(_064_permissions_revoke_global {
- args: "run --allow-read=foo,bar 064_permissions_revoke_global.ts",
- output: "064_permissions_revoke_global.ts.out",
+ args: "run --allow-read=foo,bar run/064_permissions_revoke_global.ts",
+ output: "run/064_permissions_revoke_global.ts.out",
});
#[test]
fn _066_prompt() {
- let args = "run --quiet --unstable 066_prompt.ts";
+ let args = "run --quiet --unstable run/066_prompt.ts";
use util::PtyData::*;
util::test_pty2(
args,
@@ -2337,25 +2333,25 @@ mod permissions {
}
itest!(tls_starttls {
- args: "run --quiet --reload --allow-net --allow-read --unstable --cert tls/RootCA.pem tls_starttls.js",
- output: "tls.out",
+ args: "run --quiet --reload --allow-net --allow-read --unstable --cert tls/RootCA.pem run/tls_starttls.js",
+ output: "run/tls.out",
});
itest!(tls_connecttls {
- args: "run --quiet --reload --allow-net --allow-read --cert tls/RootCA.pem tls_connecttls.js",
- output: "tls.out",
+ args: "run --quiet --reload --allow-net --allow-read --cert tls/RootCA.pem run/tls_connecttls.js",
+ output: "run/tls.out",
});
itest!(byte_order_mark {
- args: "run --no-check byte_order_mark.ts",
- output: "byte_order_mark.out",
+ args: "run --no-check run/byte_order_mark.ts",
+ output: "run/byte_order_mark.out",
});
#[test]
fn issue9750() {
use util::PtyData::*;
util::test_pty2(
- "run --prompt issue9750.js",
+ "run --prompt run/issue9750.js",
vec![
Output("Enter 'yy':\r\n"),
Input("yy\n"),
@@ -2370,20 +2366,20 @@ fn issue9750() {
// Regression test for https://github.com/denoland/deno/issues/11451.
itest!(dom_exception_formatting {
- args: "run dom_exception_formatting.ts",
- output: "dom_exception_formatting.ts.out",
+ args: "run run/dom_exception_formatting.ts",
+ output: "run/dom_exception_formatting.ts.out",
exit_code: 1,
});
itest!(long_data_url_formatting {
- args: "run long_data_url_formatting.ts",
- output: "long_data_url_formatting.ts.out",
+ args: "run run/long_data_url_formatting.ts",
+ output: "run/long_data_url_formatting.ts.out",
exit_code: 1,
});
itest!(eval_context_throw_dom_exception {
- args: "run eval_context_throw_dom_exception.js",
- output: "eval_context_throw_dom_exception.js.out",
+ args: "run run/eval_context_throw_dom_exception.js",
+ output: "run/eval_context_throw_dom_exception.js.out",
});
/// Regression test for https://github.com/denoland/deno/issues/12740.
@@ -2459,8 +2455,8 @@ fn issue12807() {
}
itest!(issue_13562 {
- args: "run issue13562.ts",
- output: "issue13562.ts.out",
+ args: "run run/issue13562.ts",
+ output: "run/issue13562.ts.out",
});
itest!(import_assertions_static_import {
@@ -2497,12 +2493,12 @@ itest!(import_assertions_type_check {
});
itest!(delete_window {
- args: "run delete_window.js",
+ args: "run run/delete_window.js",
output_str: Some("true\n"),
});
itest!(colors_without_global_this {
- args: "run colors_without_globalThis.js",
+ args: "run run/colors_without_globalThis.js",
output_str: Some("true\n"),
});
@@ -2524,166 +2520,166 @@ itest!(config_not_auto_discovered_for_remote_script {
});
itest!(wasm_streaming_panic_test {
- args: "run wasm_streaming_panic_test.js",
- output: "wasm_streaming_panic_test.js.out",
+ args: "run run/wasm_streaming_panic_test.js",
+ output: "run/wasm_streaming_panic_test.js.out",
exit_code: 1,
});
// Regression test for https://github.com/denoland/deno/issues/13897.
itest!(fetch_async_error_stack {
- args: "run --quiet -A fetch_async_error_stack.ts",
- output: "fetch_async_error_stack.ts.out",
+ args: "run --quiet -A run/fetch_async_error_stack.ts",
+ output: "run/fetch_async_error_stack.ts.out",
exit_code: 1,
});
itest!(unstable_ffi_1 {
- args: "run unstable_ffi_1.js",
- output: "unstable_ffi_1.js.out",
+ args: "run run/ffi/unstable_ffi_1.js",
+ output: "run/ffi/unstable_ffi_1.js.out",
exit_code: 70,
});
itest!(unstable_ffi_2 {
- args: "run unstable_ffi_2.js",
- output: "unstable_ffi_2.js.out",
+ args: "run run/ffi/unstable_ffi_2.js",
+ output: "run/ffi/unstable_ffi_2.js.out",
exit_code: 70,
});
itest!(unstable_ffi_3 {
- args: "run unstable_ffi_3.js",
- output: "unstable_ffi_3.js.out",
+ args: "run run/ffi/unstable_ffi_3.js",
+ output: "run/ffi/unstable_ffi_3.js.out",
exit_code: 70,
});
itest!(unstable_ffi_4 {
- args: "run unstable_ffi_4.js",
- output: "unstable_ffi_4.js.out",
+ args: "run run/ffi/unstable_ffi_4.js",
+ output: "run/ffi/unstable_ffi_4.js.out",
exit_code: 70,
});
itest!(unstable_ffi_5 {
- args: "run unstable_ffi_5.js",
- output: "unstable_ffi_5.js.out",
+ args: "run run/ffi/unstable_ffi_5.js",
+ output: "run/ffi/unstable_ffi_5.js.out",
exit_code: 70,
});
itest!(unstable_ffi_6 {
- args: "run unstable_ffi_6.js",
- output: "unstable_ffi_6.js.out",
+ args: "run run/ffi/unstable_ffi_6.js",
+ output: "run/ffi/unstable_ffi_6.js.out",
exit_code: 70,
});
itest!(unstable_ffi_7 {
- args: "run unstable_ffi_7.js",
- output: "unstable_ffi_7.js.out",
+ args: "run run/ffi/unstable_ffi_7.js",
+ output: "run/ffi/unstable_ffi_7.js.out",
exit_code: 70,
});
itest!(unstable_ffi_8 {
- args: "run unstable_ffi_8.js",
- output: "unstable_ffi_8.js.out",
+ args: "run run/ffi/unstable_ffi_8.js",
+ output: "run/ffi/unstable_ffi_8.js.out",
exit_code: 70,
});
itest!(unstable_ffi_9 {
- args: "run unstable_ffi_9.js",
- output: "unstable_ffi_9.js.out",
+ args: "run run/ffi/unstable_ffi_9.js",
+ output: "run/ffi/unstable_ffi_9.js.out",
exit_code: 70,
});
itest!(unstable_ffi_10 {
- args: "run unstable_ffi_10.js",
- output: "unstable_ffi_10.js.out",
+ args: "run run/ffi/unstable_ffi_10.js",
+ output: "run/ffi/unstable_ffi_10.js.out",
exit_code: 70,
});
itest!(unstable_ffi_11 {
- args: "run unstable_ffi_11.js",
- output: "unstable_ffi_11.js.out",
+ args: "run run/ffi/unstable_ffi_11.js",
+ output: "run/ffi/unstable_ffi_11.js.out",
exit_code: 70,
});
itest!(unstable_ffi_12 {
- args: "run unstable_ffi_12.js",
- output: "unstable_ffi_12.js.out",
+ args: "run run/ffi/unstable_ffi_12.js",
+ output: "run/ffi/unstable_ffi_12.js.out",
exit_code: 70,
});
itest!(unstable_ffi_13 {
- args: "run unstable_ffi_13.js",
- output: "unstable_ffi_13.js.out",
+ args: "run run/ffi/unstable_ffi_13.js",
+ output: "run/ffi/unstable_ffi_13.js.out",
exit_code: 70,
});
itest!(unstable_ffi_14 {
- args: "run unstable_ffi_14.js",
- output: "unstable_ffi_14.js.out",
+ args: "run run/ffi/unstable_ffi_14.js",
+ output: "run/ffi/unstable_ffi_14.js.out",
exit_code: 70,
});
itest!(unstable_ffi_15 {
- args: "run unstable_ffi_15.js",
- output: "unstable_ffi_15.js.out",
+ args: "run run/ffi/unstable_ffi_15.js",
+ output: "run/ffi/unstable_ffi_15.js.out",
exit_code: 70,
});
itest!(future_check2 {
- args: "run --check future_check.ts",
- output: "future_check2.out",
+ args: "run --check run/future_check.ts",
+ output: "run/future_check2.out",
});
itest!(event_listener_error {
- args: "run --quiet event_listener_error.ts",
- output: "event_listener_error.ts.out",
+ args: "run --quiet run/event_listener_error.ts",
+ output: "run/event_listener_error.ts.out",
exit_code: 1,
});
itest!(event_listener_error_handled {
- args: "run --quiet event_listener_error_handled.ts",
- output: "event_listener_error_handled.ts.out",
+ args: "run --quiet run/event_listener_error_handled.ts",
+ output: "run/event_listener_error_handled.ts.out",
});
// https://github.com/denoland/deno/pull/14159#issuecomment-1092285446
itest!(event_listener_error_immediate_exit {
- args: "run --quiet event_listener_error_immediate_exit.ts",
- output: "event_listener_error_immediate_exit.ts.out",
+ args: "run --quiet run/event_listener_error_immediate_exit.ts",
+ output: "run/event_listener_error_immediate_exit.ts.out",
exit_code: 1,
});
// https://github.com/denoland/deno/pull/14159#issuecomment-1092285446
itest!(event_listener_error_immediate_exit_worker {
args:
- "run --quiet --unstable -A event_listener_error_immediate_exit_worker.ts",
- output: "event_listener_error_immediate_exit_worker.ts.out",
+ "run --quiet --unstable -A run/event_listener_error_immediate_exit_worker.ts",
+ output: "run/event_listener_error_immediate_exit_worker.ts.out",
exit_code: 1,
});
itest!(set_timeout_error {
- args: "run --quiet set_timeout_error.ts",
- output: "set_timeout_error.ts.out",
+ args: "run --quiet run/set_timeout_error.ts",
+ output: "run/set_timeout_error.ts.out",
exit_code: 1,
});
itest!(set_timeout_error_handled {
- args: "run --quiet set_timeout_error_handled.ts",
- output: "set_timeout_error_handled.ts.out",
+ args: "run --quiet run/set_timeout_error_handled.ts",
+ output: "run/set_timeout_error_handled.ts.out",
});
itest!(aggregate_error {
- args: "run --quiet aggregate_error.ts",
- output: "aggregate_error.out",
+ args: "run --quiet run/aggregate_error.ts",
+ output: "run/aggregate_error.out",
exit_code: 1,
});
itest!(complex_error {
- args: "run --quiet complex_error.ts",
- output: "complex_error.ts.out",
+ args: "run --quiet run/complex_error.ts",
+ output: "run/complex_error.ts.out",
exit_code: 1,
});
// Regression test for https://github.com/denoland/deno/issues/12143.
itest!(js_root_with_ts_check {
- args: "run --quiet --check js_root_with_ts_check.js",
- output: "js_root_with_ts_check.js.out",
+ args: "run --quiet --check run/js_root_with_ts_check.js",
+ output: "run/js_root_with_ts_check.js.out",
exit_code: 1,
});
@@ -2719,13 +2715,13 @@ fn check_local_then_remote() {
// Regression test for https://github.com/denoland/deno/issues/15163
itest!(check_js_points_to_ts {
- args: "run --quiet --check --config checkjs.tsconfig.json run/check_js_points_to_ts/test.js",
+ args: "run --quiet --check --config run/checkjs.tsconfig.json run/check_js_points_to_ts/test.js",
output: "run/check_js_points_to_ts/test.js.out",
exit_code: 1,
});
itest!(no_prompt_flag {
- args: "run --quiet --unstable --no-prompt no_prompt.ts",
+ args: "run --quiet --unstable --no-prompt run/no_prompt.ts",
output_str: Some(""),
});
@@ -2735,7 +2731,7 @@ fn deno_no_prompt_environment_variable() {
.current_dir(util::testdata_path())
.arg("run")
.arg("--unstable")
- .arg("no_prompt.ts")
+ .arg("run/no_prompt.ts")
.env("DENO_NO_PROMPT", "1")
.spawn()
.unwrap()
@@ -2745,53 +2741,53 @@ fn deno_no_prompt_environment_variable() {
}
itest!(report_error {
- args: "run --quiet report_error.ts",
- output: "report_error.ts.out",
+ args: "run --quiet run/report_error.ts",
+ output: "run/report_error.ts.out",
exit_code: 1,
});
itest!(report_error_handled {
- args: "run --quiet report_error_handled.ts",
- output: "report_error_handled.ts.out",
+ args: "run --quiet run/report_error_handled.ts",
+ output: "run/report_error_handled.ts.out",
});
// Regression test for https://github.com/denoland/deno/issues/15513.
itest!(report_error_end_of_program {
- args: "run --quiet report_error_end_of_program.ts",
- output: "report_error_end_of_program.ts.out",
+ args: "run --quiet run/report_error_end_of_program.ts",
+ output: "run/report_error_end_of_program.ts.out",
exit_code: 1,
});
itest!(queue_microtask_error {
- args: "run --quiet queue_microtask_error.ts",
- output: "queue_microtask_error.ts.out",
+ args: "run --quiet run/queue_microtask_error.ts",
+ output: "run/queue_microtask_error.ts.out",
exit_code: 1,
});
itest!(queue_microtask_error_handled {
- args: "run --quiet queue_microtask_error_handled.ts",
- output: "queue_microtask_error_handled.ts.out",
+ args: "run --quiet run/queue_microtask_error_handled.ts",
+ output: "run/queue_microtask_error_handled.ts.out",
});
itest!(spawn_stdout_inherit {
- args: "run --quiet --unstable -A spawn_stdout_inherit.ts",
- output: "spawn_stdout_inherit.ts.out",
+ args: "run --quiet --unstable -A run/spawn_stdout_inherit.ts",
+ output: "run/spawn_stdout_inherit.ts.out",
});
itest!(error_name_non_string {
- args: "run --quiet error_name_non_string.js",
- output: "error_name_non_string.js.out",
+ args: "run --quiet run/error_name_non_string.js",
+ output: "run/error_name_non_string.js.out",
exit_code: 1,
});
itest!(custom_inspect_url {
- args: "run custom_inspect_url.js",
- output: "custom_inspect_url.js.out",
+ args: "run run/custom_inspect_url.js",
+ output: "run/custom_inspect_url.js.out",
});
itest!(config_json_import {
- args: "run --quiet -c jsx/deno-jsx.json config_json_import.ts",
- output: "config_json_import.ts.out",
+ args: "run --quiet -c jsx/deno-jsx.json run/config_json_import.ts",
+ output: "run/config_json_import.ts.out",
http_server: true,
});
@@ -2815,39 +2811,732 @@ fn running_declaration_files() {
}
itest!(test_and_bench_are_noops_in_run {
- args: "run test_and_bench_in_run.js",
+ args: "run run/test_and_bench_in_run.js",
output_str: Some(""),
});
itest!(followup_dyn_import_resolved {
- args: "run --unstable --allow-read followup_dyn_import_resolves/main.ts",
- output: "followup_dyn_import_resolves/main.ts.out",
+ args: "run --unstable --allow-read run/followup_dyn_import_resolves/main.ts",
+ output: "run/followup_dyn_import_resolves/main.ts.out",
});
itest!(unhandled_rejection {
- args: "run --check unhandled_rejection.ts",
- output: "unhandled_rejection.ts.out",
+ args: "run --check run/unhandled_rejection.ts",
+ output: "run/unhandled_rejection.ts.out",
});
itest!(unhandled_rejection_sync_error {
- args: "run --check unhandled_rejection_sync_error.ts",
- output: "unhandled_rejection_sync_error.ts.out",
+ args: "run --check run/unhandled_rejection_sync_error.ts",
+ output: "run/unhandled_rejection_sync_error.ts.out",
});
itest!(nested_error {
- args: "run nested_error.ts",
- output: "nested_error.ts.out",
+ args: "run run/nested_error.ts",
+ output: "run/nested_error.ts.out",
exit_code: 1,
});
itest!(node_env_var_allowlist_with_unstable_flag {
- args: "run --unstable --no-prompt node_env_var_allowlist.ts",
- output: "node_env_var_allowlist_with_unstable_flag.ts.out",
+ args: "run --unstable --no-prompt run/node_env_var_allowlist.ts",
+ output: "run/node_env_var_allowlist_with_unstable_flag.ts.out",
exit_code: 1,
});
itest!(node_env_var_allowlist_without_unstable_flag {
- args: "run --no-prompt node_env_var_allowlist.ts",
- output: "node_env_var_allowlist_without_unstable_flag.ts.out",
+ args: "run --no-prompt run/node_env_var_allowlist.ts",
+ output: "run/node_env_var_allowlist_without_unstable_flag.ts.out",
exit_code: 1,
});
+
+#[test]
+fn cache_test() {
+ let _g = util::http_server();
+ let deno_dir = TempDir::new();
+ let module_url =
+ url::Url::parse("http://localhost:4545/run/006_url_imports.ts").unwrap();
+ let output = Command::new(util::deno_exe_path())
+ .env("DENO_DIR", deno_dir.path())
+ .current_dir(util::testdata_path())
+ .arg("cache")
+ .arg("--check=all")
+ .arg("-L")
+ .arg("debug")
+ .arg(module_url.to_string())
+ .output()
+ .expect("Failed to spawn script");
+ assert!(output.status.success());
+
+ let prg = util::deno_exe_path();
+ let output = Command::new(&prg)
+ .env("DENO_DIR", deno_dir.path())
+ .env("HTTP_PROXY", "http://nil")
+ .env("NO_COLOR", "1")
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg(module_url.to_string())
+ .output()
+ .expect("Failed to spawn script");
+
+ let str_output = std::str::from_utf8(&output.stdout).unwrap();
+
+ let module_output_path =
+ util::testdata_path().join("run/006_url_imports.ts.out");
+ let mut module_output = String::new();
+ let mut module_output_file = std::fs::File::open(module_output_path).unwrap();
+ module_output_file
+ .read_to_string(&mut module_output)
+ .unwrap();
+
+ assert_eq!(module_output, str_output);
+}
+
+#[test]
+fn cache_invalidation_test() {
+ let deno_dir = TempDir::new();
+ let fixture_path = deno_dir.path().join("fixture.ts");
+ {
+ let mut file = std::fs::File::create(fixture_path.clone())
+ .expect("could not create fixture");
+ file
+ .write_all(b"console.log(\"42\");")
+ .expect("could not write fixture");
+ }
+ let output = Command::new(util::deno_exe_path())
+ .env("DENO_DIR", deno_dir.path())
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg(fixture_path.to_str().unwrap())
+ .output()
+ .expect("Failed to spawn script");
+ assert!(output.status.success());
+ let actual = std::str::from_utf8(&output.stdout).unwrap();
+ assert_eq!(actual, "42\n");
+ {
+ let mut file = std::fs::File::create(fixture_path.clone())
+ .expect("could not create fixture");
+ file
+ .write_all(b"console.log(\"43\");")
+ .expect("could not write fixture");
+ }
+ let output = Command::new(util::deno_exe_path())
+ .env("DENO_DIR", deno_dir.path())
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg(fixture_path.to_str().unwrap())
+ .output()
+ .expect("Failed to spawn script");
+ assert!(output.status.success());
+ let actual = std::str::from_utf8(&output.stdout).unwrap();
+ assert_eq!(actual, "43\n");
+}
+
+#[test]
+fn cache_invalidation_test_no_check() {
+ let deno_dir = TempDir::new();
+ let fixture_path = deno_dir.path().join("fixture.ts");
+ {
+ let mut file = std::fs::File::create(fixture_path.clone())
+ .expect("could not create fixture");
+ file
+ .write_all(b"console.log(\"42\");")
+ .expect("could not write fixture");
+ }
+ let output = Command::new(util::deno_exe_path())
+ .env("DENO_DIR", deno_dir.path())
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--no-check")
+ .arg(fixture_path.to_str().unwrap())
+ .output()
+ .expect("Failed to spawn script");
+ assert!(output.status.success());
+ let actual = std::str::from_utf8(&output.stdout).unwrap();
+ assert_eq!(actual, "42\n");
+ {
+ let mut file = std::fs::File::create(fixture_path.clone())
+ .expect("could not create fixture");
+ file
+ .write_all(b"console.log(\"43\");")
+ .expect("could not write fixture");
+ }
+ let output = Command::new(util::deno_exe_path())
+ .env("DENO_DIR", deno_dir.path())
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--no-check")
+ .arg(fixture_path.to_str().unwrap())
+ .output()
+ .expect("Failed to spawn script");
+ assert!(output.status.success());
+ let actual = std::str::from_utf8(&output.stdout).unwrap();
+ assert_eq!(actual, "43\n");
+}
+
+#[test]
+fn ts_dependency_recompilation() {
+ let t = TempDir::new();
+ let ats = t.path().join("a.ts");
+
+ std::fs::write(
+ &ats,
+ "
+ import { foo } from \"./b.ts\";
+
+ function print(str: string): void {
+ console.log(str);
+ }
+
+ print(foo);",
+ )
+ .unwrap();
+
+ let bts = t.path().join("b.ts");
+ std::fs::write(
+ &bts,
+ "
+ export const foo = \"foo\";",
+ )
+ .unwrap();
+
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg("--check")
+ .arg(&ats)
+ .output()
+ .expect("failed to spawn script");
+
+ let stdout_output = std::str::from_utf8(&output.stdout).unwrap().trim();
+ let stderr_output = std::str::from_utf8(&output.stderr).unwrap().trim();
+
+ assert!(stdout_output.ends_with("foo"));
+ assert!(stderr_output.starts_with("Check"));
+
+ // Overwrite contents of b.ts and run again
+ std::fs::write(
+ &bts,
+ "
+ export const foo = 5;",
+ )
+ .expect("error writing file");
+
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg("--check")
+ .arg(&ats)
+ .output()
+ .expect("failed to spawn script");
+
+ let stdout_output = std::str::from_utf8(&output.stdout).unwrap().trim();
+ let stderr_output = std::str::from_utf8(&output.stderr).unwrap().trim();
+
+ // error: TS2345 [ERROR]: Argument of type '5' is not assignable to parameter of type 'string'.
+ assert!(stderr_output.contains("TS2345"));
+ assert!(!output.status.success());
+ assert!(stdout_output.is_empty());
+}
+
+#[test]
+fn basic_auth_tokens() {
+ let _g = util::http_server();
+
+ let output = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("run")
+ .arg("http://127.0.0.1:4554/run/001_hello.js")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+
+ assert!(!output.status.success());
+
+ let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
+ assert!(stdout_str.is_empty());
+
+ let stderr_str = std::str::from_utf8(&output.stderr).unwrap().trim();
+ eprintln!("{}", stderr_str);
+
+ assert!(stderr_str
+ .contains("Module not found \"http://127.0.0.1:4554/run/001_hello.js\"."));
+
+ let output = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("run")
+ .arg("http://127.0.0.1:4554/run/001_hello.js")
+ .env("DENO_AUTH_TOKENS", "testuser123:testpassabc@127.0.0.1:4554")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+
+ let stderr_str = std::str::from_utf8(&output.stderr).unwrap().trim();
+ eprintln!("{}", stderr_str);
+
+ assert!(output.status.success());
+
+ let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
+ assert_eq!(util::strip_ansi_codes(stdout_str), "Hello World");
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
+async fn test_resolve_dns() {
+ use std::net::SocketAddr;
+ use std::str::FromStr;
+ use std::sync::Arc;
+ use std::time::Duration;
+ use tokio::net::TcpListener;
+ use tokio::net::UdpSocket;
+ use tokio::sync::oneshot;
+ use trust_dns_server::authority::Catalog;
+ use trust_dns_server::authority::ZoneType;
+ use trust_dns_server::proto::rr::Name;
+ use trust_dns_server::store::in_memory::InMemoryAuthority;
+ use trust_dns_server::ServerFuture;
+
+ const DNS_PORT: u16 = 4553;
+
+ // Setup DNS server for testing
+ async fn run_dns_server(tx: oneshot::Sender<()>) {
+ let zone_file = std::fs::read_to_string(
+ util::testdata_path().join("run/resolve_dns.zone.in"),
+ )
+ .unwrap();
+ let lexer = Lexer::new(&zone_file);
+ let records = Parser::new().parse(
+ lexer,
+ Some(Name::from_str("example.com").unwrap()),
+ None,
+ );
+ if records.is_err() {
+ panic!("failed to parse: {:?}", records.err())
+ }
+ let (origin, records) = records.unwrap();
+ let authority = Box::new(Arc::new(
+ InMemoryAuthority::new(origin, records, ZoneType::Primary, false)
+ .unwrap(),
+ ));
+ let mut catalog: Catalog = Catalog::new();
+ catalog.upsert(Name::root().into(), authority);
+
+ let mut server_fut = ServerFuture::new(catalog);
+ let socket_addr = SocketAddr::from(([127, 0, 0, 1], DNS_PORT));
+ let tcp_listener = TcpListener::bind(socket_addr).await.unwrap();
+ let udp_socket = UdpSocket::bind(socket_addr).await.unwrap();
+ server_fut.register_socket(udp_socket);
+ server_fut.register_listener(tcp_listener, Duration::from_secs(2));
+
+ // Notifies that the DNS server is ready
+ tx.send(()).unwrap();
+
+ server_fut.block_until_done().await.unwrap();
+ }
+
+ let (ready_tx, ready_rx) = oneshot::channel();
+ let dns_server_fut = run_dns_server(ready_tx);
+ let handle = tokio::spawn(dns_server_fut);
+
+ // Waits for the DNS server to be ready
+ ready_rx.await.unwrap();
+
+ // Pass: `--allow-net`
+ {
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg("--check")
+ .arg("--allow-net")
+ .arg("run/resolve_dns.ts")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ let err = String::from_utf8_lossy(&output.stderr);
+ let out = String::from_utf8_lossy(&output.stdout);
+ println!("{}", err);
+ assert!(output.status.success());
+ assert!(err.starts_with("Check file"));
+
+ let expected = std::fs::read_to_string(
+ util::testdata_path().join("run/resolve_dns.ts.out"),
+ )
+ .unwrap();
+ assert_eq!(expected, out);
+ }
+
+ // Pass: `--allow-net=127.0.0.1:4553`
+ {
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg("--check")
+ .arg("--allow-net=127.0.0.1:4553")
+ .arg("run/resolve_dns.ts")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ let err = String::from_utf8_lossy(&output.stderr);
+ let out = String::from_utf8_lossy(&output.stdout);
+ assert!(output.status.success());
+ assert!(err.starts_with("Check file"));
+
+ let expected = std::fs::read_to_string(
+ util::testdata_path().join("run/resolve_dns.ts.out"),
+ )
+ .unwrap();
+ assert_eq!(expected, out);
+ }
+
+ // Permission error: `--allow-net=deno.land`
+ {
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg("--check")
+ .arg("--allow-net=deno.land")
+ .arg("run/resolve_dns.ts")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ let err = String::from_utf8_lossy(&output.stderr);
+ let out = String::from_utf8_lossy(&output.stdout);
+ assert!(!output.status.success());
+ assert!(err.starts_with("Check file"));
+ assert!(err.contains(r#"error: Uncaught PermissionDenied: Requires net access to "127.0.0.1:4553""#));
+ assert!(out.is_empty());
+ }
+
+ // Permission error: no permission specified
+ {
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg("--check")
+ .arg("run/resolve_dns.ts")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ let err = String::from_utf8_lossy(&output.stderr);
+ let out = String::from_utf8_lossy(&output.stdout);
+ assert!(!output.status.success());
+ assert!(err.starts_with("Check file"));
+ assert!(err.contains(r#"error: Uncaught PermissionDenied: Requires net access to "127.0.0.1:4553""#));
+ assert!(out.is_empty());
+ }
+
+ handle.abort();
+}
+
+#[tokio::test]
+async fn http2_request_url() {
+ // TLS streams require the presence of an ambient local task set to gracefully
+ // close dropped connections in the background.
+ LocalSet::new()
+ .run_until(async {
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--unstable")
+ .arg("--quiet")
+ .arg("--allow-net")
+ .arg("--allow-read")
+ .arg("./run/http2_request_url.ts")
+ .arg("4506")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut buffer = [0; 5];
+ let read = stdout.read(&mut buffer).unwrap();
+ assert_eq!(read, 5);
+ let msg = std::str::from_utf8(&buffer).unwrap();
+ assert_eq!(msg, "READY");
+
+ let cert = reqwest::Certificate::from_pem(include_bytes!(
+ "../testdata/tls/RootCA.crt"
+ ))
+ .unwrap();
+
+ let client = reqwest::Client::builder()
+ .add_root_certificate(cert)
+ .http2_prior_knowledge()
+ .build()
+ .unwrap();
+
+ let res = client.get("http://127.0.0.1:4506").send().await.unwrap();
+ assert_eq!(200, res.status());
+
+ let body = res.text().await.unwrap();
+ assert_eq!(body, "http://127.0.0.1:4506/");
+
+ child.kill().unwrap();
+ child.wait().unwrap();
+ })
+ .await;
+}
+
+#[cfg(not(windows))]
+#[test]
+fn set_raw_should_not_panic_on_no_tty() {
+ let output = util::deno_cmd()
+ .arg("eval")
+ .arg("--unstable")
+ .arg("Deno.setRaw(Deno.stdin.rid, true)")
+ // stdin set to piped so it certainly does not refer to TTY
+ .stdin(std::process::Stdio::piped())
+ // stderr is piped so we can capture output.
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ assert!(!output.status.success());
+ let stderr = std::str::from_utf8(&output.stderr).unwrap().trim();
+ assert!(stderr.contains("BadResource"));
+}
+
+#[test]
+fn timeout_clear() {
+ // https://github.com/denoland/deno/issues/7599
+
+ use std::time::Duration;
+ use std::time::Instant;
+
+ let source_code = r#"
+const handle = setTimeout(() => {
+ console.log("timeout finish");
+}, 10000);
+clearTimeout(handle);
+console.log("finish");
+"#;
+
+ let mut p = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("-")
+ .stdin(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdin = p.stdin.as_mut().unwrap();
+ stdin.write_all(source_code.as_bytes()).unwrap();
+ let start = Instant::now();
+ let status = p.wait().unwrap();
+ let end = Instant::now();
+ assert!(status.success());
+ // check that program did not run for 10 seconds
+ // for timeout to clear
+ assert!(end - start < Duration::new(10, 0));
+}
+
+#[test]
+fn broken_stdout() {
+ let (reader, writer) = os_pipe::pipe().unwrap();
+ // drop the reader to create a broken pipe
+ drop(reader);
+
+ let output = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("eval")
+ .arg("console.log(3.14)")
+ .stdout(writer)
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+
+ assert!(!output.status.success());
+ let stderr = std::str::from_utf8(output.stderr.as_ref()).unwrap().trim();
+ assert!(stderr.contains("Uncaught BrokenPipe"));
+ assert!(!stderr.contains("panic"));
+}
+
+itest!(error_cause {
+ args: "run run/error_cause.ts",
+ output: "run/error_cause.ts.out",
+ exit_code: 1,
+});
+
+itest!(error_cause_recursive {
+ args: "run run/error_cause_recursive.ts",
+ output: "run/error_cause_recursive.ts.out",
+ exit_code: 1,
+});
+
+#[test]
+fn websocket() {
+ let _g = util::http_server();
+
+ let script = util::testdata_path().join("run/websocket_test.ts");
+ let root_ca = util::testdata_path().join("tls/RootCA.pem");
+ let status = util::deno_cmd()
+ .arg("test")
+ .arg("--unstable")
+ .arg("--allow-net")
+ .arg("--cert")
+ .arg(root_ca)
+ .arg(script)
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+
+ assert!(status.success());
+}
+
+#[test]
+fn websocketstream() {
+ let _g = util::http_server();
+
+ let script = util::testdata_path().join("run/websocketstream_test.ts");
+ let root_ca = util::testdata_path().join("tls/RootCA.pem");
+ let status = util::deno_cmd()
+ .arg("test")
+ .arg("--unstable")
+ .arg("--allow-net")
+ .arg("--cert")
+ .arg(root_ca)
+ .arg(script)
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+
+ assert!(status.success());
+}
+
+#[test]
+fn websocketstream_ping() {
+ use deno_runtime::deno_websocket::tokio_tungstenite::tungstenite;
+ let _g = util::http_server();
+
+ let script = util::testdata_path().join("run/websocketstream_ping_test.ts");
+ let root_ca = util::testdata_path().join("tls/RootCA.pem");
+ let mut child = util::deno_cmd()
+ .arg("test")
+ .arg("--unstable")
+ .arg("--allow-net")
+ .arg("--cert")
+ .arg(root_ca)
+ .arg(script)
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+
+ let server = std::net::TcpListener::bind("127.0.0.1:4513").unwrap();
+ let (stream, _) = server.accept().unwrap();
+ let mut socket = tungstenite::accept(stream).unwrap();
+ socket
+ .write_message(tungstenite::Message::Text(String::from("A")))
+ .unwrap();
+ socket
+ .write_message(tungstenite::Message::Ping(vec![]))
+ .unwrap();
+ socket
+ .write_message(tungstenite::Message::Text(String::from("B")))
+ .unwrap();
+ let message = socket.read_message().unwrap();
+ assert_eq!(message, tungstenite::Message::Pong(vec![]));
+ socket
+ .write_message(tungstenite::Message::Text(String::from("C")))
+ .unwrap();
+ socket.close(None).unwrap();
+
+ assert!(child.wait().unwrap().success());
+}
+
+#[test]
+fn websocket_server_multi_field_connection_header() {
+ let script = util::testdata_path()
+ .join("run/websocket_server_multi_field_connection_header_test.ts");
+ let root_ca = util::testdata_path().join("tls/RootCA.pem");
+ let mut child = util::deno_cmd()
+ .arg("run")
+ .arg("--unstable")
+ .arg("--allow-net")
+ .arg("--cert")
+ .arg(root_ca)
+ .arg(script)
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut buffer = [0; 5];
+ let read = stdout.read(&mut buffer).unwrap();
+ assert_eq!(read, 5);
+ let msg = std::str::from_utf8(&buffer).unwrap();
+ assert_eq!(msg, "READY");
+
+ let req = http::request::Builder::new()
+ .header(http::header::CONNECTION, "keep-alive, Upgrade")
+ .uri("ws://localhost:4319")
+ .body(())
+ .unwrap();
+ let (mut socket, _) =
+ deno_runtime::deno_websocket::tokio_tungstenite::tungstenite::connect(req)
+ .unwrap();
+ let message = socket.read_message().unwrap();
+ assert_eq!(message, deno_runtime::deno_websocket::tokio_tungstenite::tungstenite::Message::Close(None));
+ socket.close(None).unwrap();
+ assert!(child.wait().unwrap().success());
+}
+
+// TODO(bartlomieju): this should use `deno run`, not `deno test`; but the
+// test hangs then. https://github.com/denoland/deno/issues/14283
+#[test]
+#[ignore]
+fn websocket_server_idletimeout() {
+ let script =
+ util::testdata_path().join("run/websocket_server_idletimeout.ts");
+ let root_ca = util::testdata_path().join("tls/RootCA.pem");
+ let mut child = util::deno_cmd()
+ .arg("test")
+ .arg("--unstable")
+ .arg("--allow-net")
+ .arg("--cert")
+ .arg(root_ca)
+ .arg(script)
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut buffer = [0; 5];
+ let read = stdout.read(&mut buffer).unwrap();
+ assert_eq!(read, 5);
+ let msg = std::str::from_utf8(&buffer).unwrap();
+ assert_eq!(msg, "READY");
+
+ let req = http::request::Builder::new()
+ .uri("ws://localhost:4509")
+ .body(())
+ .unwrap();
+ let (_ws, _request) =
+ deno_runtime::deno_websocket::tokio_tungstenite::tungstenite::connect(req)
+ .unwrap();
+
+ assert!(child.wait().unwrap().success());
+}
diff --git a/cli/tests/integration/vendor_tests.rs b/cli/tests/integration/vendor_tests.rs
index 54809dacf..b3a3f441f 100644
--- a/cli/tests/integration/vendor_tests.rs
+++ b/cli/tests/integration/vendor_tests.rs
@@ -347,6 +347,7 @@ fn existing_import_map_mixed_with_remote() {
.arg("--output")
.arg("vendor2")
.stderr(Stdio::piped())
+ .stdout(Stdio::piped())
.spawn()
.unwrap();
let output = deno.wait_with_output().unwrap();
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs
index b69379427..efc1b186b 100644
--- a/cli/tests/integration/watcher_tests.rs
+++ b/cli/tests/integration/watcher_tests.rs
@@ -242,15 +242,15 @@ fn lint_all_files_on_each_change_test() {
#[test]
fn fmt_watch_test() {
+ let fmt_testdata_path = util::testdata_path().join("fmt");
let t = TempDir::new();
- let fixed = util::testdata_path().join("badly_formatted_fixed.js");
- let badly_formatted_original =
- util::testdata_path().join("badly_formatted.mjs");
+ let fixed = fmt_testdata_path.join("badly_formatted_fixed.js");
+ let badly_formatted_original = fmt_testdata_path.join("badly_formatted.mjs");
let badly_formatted = t.path().join("badly_formatted.js");
std::fs::copy(&badly_formatted_original, &badly_formatted).unwrap();
let mut child = util::deno_cmd()
- .current_dir(util::testdata_path())
+ .current_dir(&fmt_testdata_path)
.arg("fmt")
.arg(&badly_formatted)
.arg("--watch")
@@ -291,10 +291,10 @@ fn fmt_watch_test() {
#[test]
fn fmt_watch_without_args_test() {
+ let fmt_testdata_path = util::testdata_path().join("fmt");
let t = TempDir::new();
- let fixed = util::testdata_path().join("badly_formatted_fixed.js");
- let badly_formatted_original =
- util::testdata_path().join("badly_formatted.mjs");
+ let fixed = fmt_testdata_path.join("badly_formatted_fixed.js");
+ let badly_formatted_original = fmt_testdata_path.join("badly_formatted.mjs");
let badly_formatted = t.path().join("badly_formatted.js");
std::fs::copy(&badly_formatted_original, &badly_formatted).unwrap();
@@ -339,15 +339,15 @@ fn fmt_watch_without_args_test() {
#[test]
fn fmt_check_all_files_on_each_change_test() {
let t = TempDir::new();
- let badly_formatted_original =
- util::testdata_path().join("badly_formatted.mjs");
+ let fmt_testdata_path = util::testdata_path().join("fmt");
+ let badly_formatted_original = fmt_testdata_path.join("badly_formatted.mjs");
let badly_formatted_1 = t.path().join("badly_formatted_1.js");
let badly_formatted_2 = t.path().join("badly_formatted_2.js");
std::fs::copy(&badly_formatted_original, &badly_formatted_1).unwrap();
std::fs::copy(&badly_formatted_original, &badly_formatted_2).unwrap();
let mut child = util::deno_cmd()
- .current_dir(util::testdata_path())
+ .current_dir(&fmt_testdata_path)
.arg("fmt")
.arg(&t.path())
.arg("--watch")
diff --git a/cli/tests/integration/worker_tests.rs b/cli/tests/integration/worker_tests.rs
index 63d5ccbd3..b864c15da 100644
--- a/cli/tests/integration/worker_tests.rs
+++ b/cli/tests/integration/worker_tests.rs
@@ -41,20 +41,20 @@ itest!(nonexistent_worker {
});
itest!(_084_worker_custom_inspect {
- args: "run --allow-read 084_worker_custom_inspect.ts",
- output: "084_worker_custom_inspect.ts.out",
+ args: "run --allow-read workers/custom_inspect/main.ts",
+ output: "workers/custom_inspect/main.out",
});
itest!(error_worker_permissions_local {
- args: "run --reload error_worker_permissions_local.ts",
- output: "error_worker_permissions_local.ts.out",
+ args: "run --reload workers/error_worker_permissions_local.ts",
+ output: "workers/error_worker_permissions_local.ts.out",
exit_code: 1,
});
itest!(error_worker_permissions_remote {
- args: "run --reload error_worker_permissions_remote.ts",
+ args: "run --reload workers/error_worker_permissions_remote.ts",
http_server: true,
- output: "error_worker_permissions_remote.ts.out",
+ output: "workers/error_worker_permissions_remote.ts.out",
exit_code: 1,
});