summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/001_hello.js1
-rw-r--r--cli/tests/001_hello.js.out1
-rw-r--r--cli/tests/002_hello.ts1
-rw-r--r--cli/tests/002_hello.ts.out1
-rw-r--r--cli/tests/003_relative_import.ts3
-rw-r--r--cli/tests/003_relative_import.ts.out1
-rw-r--r--cli/tests/004_set_timeout.ts11
-rw-r--r--cli/tests/004_set_timeout.ts.out2
-rw-r--r--cli/tests/005_more_imports.ts11
-rw-r--r--cli/tests/005_more_imports.ts.out1
-rw-r--r--cli/tests/006_url_imports.ts3
-rw-r--r--cli/tests/006_url_imports.ts.out2
-rw-r--r--cli/tests/012_async.ts13
-rw-r--r--cli/tests/012_async.ts.out3
-rw-r--r--cli/tests/013_dynamic_import.ts15
-rw-r--r--cli/tests/013_dynamic_import.ts.out1
-rw-r--r--cli/tests/014_duplicate_import.ts9
-rw-r--r--cli/tests/014_duplicate_import.ts.out1
-rw-r--r--cli/tests/015_duplicate_parallel_import.js20
-rw-r--r--cli/tests/015_duplicate_parallel_import.js.out1
-rw-r--r--cli/tests/016_double_await.ts8
-rw-r--r--cli/tests/016_double_await.ts.out2
-rw-r--r--cli/tests/017_import_redirect.ts4
-rw-r--r--cli/tests/017_import_redirect.ts.out1
-rw-r--r--cli/tests/018_async_catch.ts14
-rw-r--r--cli/tests/018_async_catch.ts.out3
-rw-r--r--cli/tests/019_media_types.ts24
-rw-r--r--cli/tests/019_media_types.ts.out1
-rw-r--r--cli/tests/020_json_modules.ts2
-rw-r--r--cli/tests/020_json_modules.ts.out1
-rw-r--r--cli/tests/021_mjs_modules.ts2
-rw-r--r--cli/tests/021_mjs_modules.ts.out1
-rw-r--r--cli/tests/022_info_flag_script.out14
-rw-r--r--cli/tests/023_no_ext_with_headers1
-rw-r--r--cli/tests/023_no_ext_with_headers.headers.json1
-rw-r--r--cli/tests/023_no_ext_with_headers.out1
-rw-r--r--cli/tests/024_import_no_ext_with_headers.ts1
-rw-r--r--cli/tests/024_import_no_ext_with_headers.ts.out1
-rw-r--r--cli/tests/025_hrtime.ts3
-rw-r--r--cli/tests/025_hrtime.ts.out2
-rw-r--r--cli/tests/025_reload_js_type_error.js5
-rw-r--r--cli/tests/025_reload_js_type_error.js.out1
-rw-r--r--cli/tests/026_redirect_javascript.js2
-rw-r--r--cli/tests/026_redirect_javascript.js.out1
-rw-r--r--cli/tests/026_workers.ts14
-rw-r--r--cli/tests/026_workers.ts.out4
-rw-r--r--cli/tests/027_redirect_typescript.ts2
-rw-r--r--cli/tests/027_redirect_typescript.ts.out1
-rw-r--r--cli/tests/028_args.ts5
-rw-r--r--cli/tests/028_args.ts.out7
-rw-r--r--cli/tests/029_eval.out1
-rw-r--r--cli/tests/030_xeval.out3
-rw-r--r--cli/tests/031_xeval_replvar.out3
-rw-r--r--cli/tests/032_xeval_delim.out3
-rw-r--r--cli/tests/033_import_map.out7
-rw-r--r--cli/tests/034_onload.out11
-rw-r--r--cli/tests/034_onload/imported.ts11
-rw-r--r--cli/tests/034_onload/main.ts23
-rw-r--r--cli/tests/034_onload/nest_imported.ts10
-rw-r--r--cli/tests/035_no_fetch_flag.out1
-rw-r--r--cli/tests/036_import_map_fetch.out0
-rw-r--r--cli/tests/038_checkjs.js6
-rw-r--r--cli/tests/038_checkjs.js.out15
-rw-r--r--cli/tests/038_checkjs.tsconfig.json5
-rw-r--r--cli/tests/039_worker_deno_ns.ts25
-rw-r--r--cli/tests/039_worker_deno_ns.ts.out4
-rw-r--r--cli/tests/039_worker_deno_ns/has_ns.ts10
-rw-r--r--cli/tests/039_worker_deno_ns/maybe_ns.ts1
-rw-r--r--cli/tests/039_worker_deno_ns/no_ns.ts10
-rw-r--r--cli/tests/040_worker_blob.ts6
-rw-r--r--cli/tests/040_worker_blob.ts.out1
-rw-r--r--cli/tests/041_dyn_import_eval.out1
-rw-r--r--cli/tests/041_info_flag.out3
-rw-r--r--cli/tests/042_dyn_import_evalcontext.ts4
-rw-r--r--cli/tests/042_dyn_import_evalcontext.ts.out1
-rw-r--r--cli/tests/044_bad_resource.ts7
-rw-r--r--cli/tests/044_bad_resource.ts.out6
-rw-r--r--cli/tests/045_proxy_client.ts7
-rw-r--r--cli/tests/045_proxy_test.ts72
-rw-r--r--cli/tests/045_proxy_test.ts.out3
-rw-r--r--cli/tests/046_jsx_test.tsx9
-rw-r--r--cli/tests/046_jsx_test.tsx.out1
-rw-r--r--cli/tests/047_jsx_test.jsx9
-rw-r--r--cli/tests/047_jsx_test.jsx.out1
-rw-r--r--cli/tests/README.md7
-rw-r--r--cli/tests/async_error.ts8
-rw-r--r--cli/tests/async_error.ts.out11
-rw-r--r--cli/tests/badly_formatted.js4
-rw-r--r--cli/tests/badly_formatted_fixed.js1
-rw-r--r--cli/tests/cat.ts11
-rw-r--r--cli/tests/circular1.js2
-rw-r--r--cli/tests/circular1.js.out2
-rw-r--r--cli/tests/circular2.js2
-rw-r--r--cli/tests/config.ts5
-rw-r--r--cli/tests/config.ts.out10
-rw-r--r--cli/tests/config.tsconfig.json7
-rw-r--r--cli/tests/echo_server.ts12
-rw-r--r--cli/tests/error_001.ts9
-rw-r--r--cli/tests/error_001.ts.out9
-rw-r--r--cli/tests/error_002.ts7
-rw-r--r--cli/tests/error_002.ts.out9
-rw-r--r--cli/tests/error_003_typescript.ts20
-rw-r--r--cli/tests/error_003_typescript.ts.out16
-rw-r--r--cli/tests/error_004_missing_module.ts2
-rw-r--r--cli/tests/error_004_missing_module.ts.out5
-rw-r--r--cli/tests/error_005_missing_dynamic_import.ts4
-rw-r--r--cli/tests/error_005_missing_dynamic_import.ts.out5
-rw-r--r--cli/tests/error_006_import_ext_failure.ts1
-rw-r--r--cli/tests/error_006_import_ext_failure.ts.out5
-rw-r--r--cli/tests/error_007_any.ts1
-rw-r--r--cli/tests/error_007_any.ts.out1
-rw-r--r--cli/tests/error_008_checkjs.js6
-rw-r--r--cli/tests/error_008_checkjs.js.out7
-rw-r--r--cli/tests/error_009_missing_js_module.disabled4
-rw-r--r--cli/tests/error_009_missing_js_module.js1
-rw-r--r--cli/tests/error_009_missing_js_module.js.out1
-rw-r--r--cli/tests/error_010_nonexistent_arg.disabled4
-rw-r--r--cli/tests/error_010_nonexistent_arg.out1
-rw-r--r--cli/tests/error_011_bad_module_specifier.ts2
-rw-r--r--cli/tests/error_011_bad_module_specifier.ts.out5
-rw-r--r--cli/tests/error_012_bad_dynamic_import_specifier.ts4
-rw-r--r--cli/tests/error_012_bad_dynamic_import_specifier.ts.out5
-rw-r--r--cli/tests/error_013_missing_script.out1
-rw-r--r--cli/tests/error_014_catch_dynamic_import_error.js31
-rw-r--r--cli/tests/error_014_catch_dynamic_import_error.js.out12
-rw-r--r--cli/tests/error_015_dynamic_import_permissions.js3
-rw-r--r--cli/tests/error_015_dynamic_import_permissions.out1
-rw-r--r--cli/tests/error_016_dynamic_import_permissions2.js5
-rw-r--r--cli/tests/error_016_dynamic_import_permissions2.out2
-rw-r--r--cli/tests/error_stack.ts10
-rw-r--r--cli/tests/error_stack.ts.out6
-rw-r--r--cli/tests/error_syntax.js3
-rw-r--r--cli/tests/error_syntax.js.out6
-rw-r--r--cli/tests/error_type_definitions.ts5
-rw-r--r--cli/tests/error_type_definitions.ts.out5
-rw-r--r--cli/tests/error_worker_dynamic.ts3
-rw-r--r--cli/tests/error_worker_dynamic.ts.out3
-rw-r--r--cli/tests/esm_imports_a.js3
-rw-r--r--cli/tests/esm_imports_b.js3
-rw-r--r--cli/tests/exec_path.ts1
-rw-r--r--cli/tests/exit_error42.ts3
-rw-r--r--cli/tests/exit_error42.ts.out1
-rw-r--r--cli/tests/fetch_deps.ts14
-rw-r--r--cli/tests/hello.txt1
-rw-r--r--cli/tests/https_import.ts5
-rw-r--r--cli/tests/https_import.ts.out1
-rw-r--r--cli/tests/if_main.ts7
-rw-r--r--cli/tests/if_main.ts.out1
-rw-r--r--cli/tests/import_meta.ts3
-rw-r--r--cli/tests/import_meta.ts.out2
-rw-r--r--cli/tests/import_meta2.ts1
-rw-r--r--cli/tests/importmaps/import_map.json14
-rw-r--r--cli/tests/importmaps/lodash/lodash.ts1
-rw-r--r--cli/tests/importmaps/lodash/other_file.ts1
-rw-r--r--cli/tests/importmaps/moment/moment.ts1
-rw-r--r--cli/tests/importmaps/moment/other_file.ts1
-rw-r--r--cli/tests/importmaps/scope/scoped.ts2
-rw-r--r--cli/tests/importmaps/scoped_moment.ts1
-rw-r--r--cli/tests/importmaps/test.ts6
-rw-r--r--cli/tests/importmaps/vue.ts1
-rw-r--r--cli/tests/integration_tests.rs578
-rw-r--r--cli/tests/is_tty.ts1
-rw-r--r--cli/tests/no_color.js1
-rw-r--r--cli/tests/seed_random.js11
-rw-r--r--cli/tests/seed_random.js.out12
-rw-r--r--cli/tests/subdir/auto_print_hello.ts2
-rw-r--r--cli/tests/subdir/bench_worker.ts20
-rw-r--r--cli/tests/subdir/config.json6
-rw-r--r--cli/tests/subdir/evil_remote_import.js4
-rw-r--r--cli/tests/subdir/form_urlencoded.txt1
-rw-r--r--cli/tests/subdir/indirect_import_error.js1
-rw-r--r--cli/tests/subdir/indirect_throws.js1
-rw-r--r--cli/tests/subdir/mismatch_ext.ts1
-rw-r--r--cli/tests/subdir/mod1.ts17
-rw-r--r--cli/tests/subdir/mod2.ts1
-rw-r--r--cli/tests/subdir/mod3.js1
-rw-r--r--cli/tests/subdir/mod4.js1
-rw-r--r--cli/tests/subdir/mod5.mjs1
-rw-r--r--cli/tests/subdir/mt_application_ecmascript.j2.js1
-rw-r--r--cli/tests/subdir/mt_application_x_javascript.j4.js1
-rw-r--r--cli/tests/subdir/mt_application_x_typescript.t4.ts1
-rw-r--r--cli/tests/subdir/mt_javascript.js1
-rw-r--r--cli/tests/subdir/mt_text_ecmascript.j3.js1
-rw-r--r--cli/tests/subdir/mt_text_javascript.j1.js1
-rw-r--r--cli/tests/subdir/mt_text_typescript.t1.ts1
-rw-r--r--cli/tests/subdir/mt_video_mp2t.t3.ts1
-rw-r--r--cli/tests/subdir/mt_video_vdn.t2.ts1
-rw-r--r--cli/tests/subdir/no_ext1
-rw-r--r--cli/tests/subdir/print_hello.ts3
-rw-r--r--cli/tests/subdir/redirects/redirect1.js1
-rw-r--r--cli/tests/subdir/redirects/redirect1.ts1
-rw-r--r--cli/tests/subdir/redirects/redirect2.js1
-rw-r--r--cli/tests/subdir/redirects/redirect3.js2
-rw-r--r--cli/tests/subdir/redirects/redirect4.ts2
-rw-r--r--cli/tests/subdir/subdir2/mod2.ts9
-rw-r--r--cli/tests/subdir/test_worker.js7
-rw-r--r--cli/tests/subdir/test_worker.ts7
-rw-r--r--cli/tests/subdir/throws.js5
-rw-r--r--cli/tests/subdir/unknown_ext.deno1
-rw-r--r--cli/tests/top_level_await.js3
-rw-r--r--cli/tests/top_level_await.out3
-rw-r--r--cli/tests/top_level_await.ts3
-rw-r--r--cli/tests/tty_tests.rs18
-rw-r--r--cli/tests/type_definitions.ts10
-rw-r--r--cli/tests/type_definitions.ts.out3
-rw-r--r--cli/tests/type_definitions/bar.d.ts7
-rw-r--r--cli/tests/type_definitions/fizz.d.ts2
-rw-r--r--cli/tests/type_definitions/fizz.js1
-rw-r--r--cli/tests/type_definitions/foo.d.ts2
-rw-r--r--cli/tests/type_definitions/foo.js1
-rw-r--r--cli/tests/type_definitions/qat.ts1
-rw-r--r--cli/tests/types.out14
-rw-r--r--cli/tests/unbuffered_stderr.ts3
-rw-r--r--cli/tests/unbuffered_stderr.ts.out2
-rw-r--r--cli/tests/unbuffered_stdout.ts3
-rw-r--r--cli/tests/unbuffered_stdout.ts.out1
-rw-r--r--cli/tests/util/mod.rs218
-rw-r--r--cli/tests/v8_flags.js1
-rw-r--r--cli/tests/v8_flags.js.out1
-rw-r--r--cli/tests/v8_help.out3
-rw-r--r--cli/tests/version.out3
-rw-r--r--cli/tests/wasm.ts15
-rw-r--r--cli/tests/wasm.ts.out1
-rw-r--r--cli/tests/wasm_async.js27
-rw-r--r--cli/tests/wasm_async.out1
-rw-r--r--cli/tests/workers_round_robin_bench.ts79
-rw-r--r--cli/tests/workers_startup_bench.ts27
227 files changed, 2058 insertions, 0 deletions
diff --git a/cli/tests/001_hello.js b/cli/tests/001_hello.js
new file mode 100644
index 000000000..accefceba
--- /dev/null
+++ b/cli/tests/001_hello.js
@@ -0,0 +1 @@
+console.log("Hello World");
diff --git a/cli/tests/001_hello.js.out b/cli/tests/001_hello.js.out
new file mode 100644
index 000000000..557db03de
--- /dev/null
+++ b/cli/tests/001_hello.js.out
@@ -0,0 +1 @@
+Hello World
diff --git a/cli/tests/002_hello.ts b/cli/tests/002_hello.ts
new file mode 100644
index 000000000..accefceba
--- /dev/null
+++ b/cli/tests/002_hello.ts
@@ -0,0 +1 @@
+console.log("Hello World");
diff --git a/cli/tests/002_hello.ts.out b/cli/tests/002_hello.ts.out
new file mode 100644
index 000000000..557db03de
--- /dev/null
+++ b/cli/tests/002_hello.ts.out
@@ -0,0 +1 @@
+Hello World
diff --git a/cli/tests/003_relative_import.ts b/cli/tests/003_relative_import.ts
new file mode 100644
index 000000000..01d5d7faa
--- /dev/null
+++ b/cli/tests/003_relative_import.ts
@@ -0,0 +1,3 @@
+import { printHello } from "./subdir/print_hello.ts";
+
+printHello();
diff --git a/cli/tests/003_relative_import.ts.out b/cli/tests/003_relative_import.ts.out
new file mode 100644
index 000000000..e965047ad
--- /dev/null
+++ b/cli/tests/003_relative_import.ts.out
@@ -0,0 +1 @@
+Hello
diff --git a/cli/tests/004_set_timeout.ts b/cli/tests/004_set_timeout.ts
new file mode 100644
index 000000000..58f899ee3
--- /dev/null
+++ b/cli/tests/004_set_timeout.ts
@@ -0,0 +1,11 @@
+setTimeout((): void => {
+ console.log("World");
+}, 10);
+
+console.log("Hello");
+
+const id = setTimeout((): void => {
+ console.log("Not printed");
+}, 10000);
+
+clearTimeout(id);
diff --git a/cli/tests/004_set_timeout.ts.out b/cli/tests/004_set_timeout.ts.out
new file mode 100644
index 000000000..f9264f7fb
--- /dev/null
+++ b/cli/tests/004_set_timeout.ts.out
@@ -0,0 +1,2 @@
+Hello
+World
diff --git a/cli/tests/005_more_imports.ts b/cli/tests/005_more_imports.ts
new file mode 100644
index 000000000..52dd1df7b
--- /dev/null
+++ b/cli/tests/005_more_imports.ts
@@ -0,0 +1,11 @@
+import { returnsHi, returnsFoo2, printHello3 } from "./subdir/mod1.ts";
+
+printHello3();
+
+if (returnsHi() !== "Hi") {
+ throw Error("Unexpected");
+}
+
+if (returnsFoo2() !== "Foo") {
+ throw Error("Unexpected");
+}
diff --git a/cli/tests/005_more_imports.ts.out b/cli/tests/005_more_imports.ts.out
new file mode 100644
index 000000000..e965047ad
--- /dev/null
+++ b/cli/tests/005_more_imports.ts.out
@@ -0,0 +1 @@
+Hello
diff --git a/cli/tests/006_url_imports.ts b/cli/tests/006_url_imports.ts
new file mode 100644
index 000000000..109cb603e
--- /dev/null
+++ b/cli/tests/006_url_imports.ts
@@ -0,0 +1,3 @@
+import { printHello } from "http://localhost:4545/cli/tests/subdir/mod2.ts";
+printHello();
+console.log("success");
diff --git a/cli/tests/006_url_imports.ts.out b/cli/tests/006_url_imports.ts.out
new file mode 100644
index 000000000..989ce33e9
--- /dev/null
+++ b/cli/tests/006_url_imports.ts.out
@@ -0,0 +1,2 @@
+Hello
+success
diff --git a/cli/tests/012_async.ts b/cli/tests/012_async.ts
new file mode 100644
index 000000000..1f1822c04
--- /dev/null
+++ b/cli/tests/012_async.ts
@@ -0,0 +1,13 @@
+// Check that we can use the async keyword.
+async function main(): Promise<void> {
+ await new Promise(
+ (resolve): void => {
+ console.log("2");
+ setTimeout(resolve, 100);
+ }
+ );
+ console.log("3");
+}
+
+console.log("1");
+main();
diff --git a/cli/tests/012_async.ts.out b/cli/tests/012_async.ts.out
new file mode 100644
index 000000000..01e79c32a
--- /dev/null
+++ b/cli/tests/012_async.ts.out
@@ -0,0 +1,3 @@
+1
+2
+3
diff --git a/cli/tests/013_dynamic_import.ts b/cli/tests/013_dynamic_import.ts
new file mode 100644
index 000000000..6bbce3132
--- /dev/null
+++ b/cli/tests/013_dynamic_import.ts
@@ -0,0 +1,15 @@
+(async (): Promise<void> => {
+ const { returnsHi, returnsFoo2, printHello3 } = await import(
+ "./subdir/mod1.ts"
+ );
+
+ printHello3();
+
+ if (returnsHi() !== "Hi") {
+ throw Error("Unexpected");
+ }
+
+ if (returnsFoo2() !== "Foo") {
+ throw Error("Unexpected");
+ }
+})();
diff --git a/cli/tests/013_dynamic_import.ts.out b/cli/tests/013_dynamic_import.ts.out
new file mode 100644
index 000000000..e965047ad
--- /dev/null
+++ b/cli/tests/013_dynamic_import.ts.out
@@ -0,0 +1 @@
+Hello
diff --git a/cli/tests/014_duplicate_import.ts b/cli/tests/014_duplicate_import.ts
new file mode 100644
index 000000000..97864fea7
--- /dev/null
+++ b/cli/tests/014_duplicate_import.ts
@@ -0,0 +1,9 @@
+// with all the imports of the same module, the module should only be
+// instantiated once
+import "./subdir/auto_print_hello.ts";
+
+import "./subdir/auto_print_hello.ts";
+
+(async (): Promise<void> => {
+ await import("./subdir/auto_print_hello.ts");
+})();
diff --git a/cli/tests/014_duplicate_import.ts.out b/cli/tests/014_duplicate_import.ts.out
new file mode 100644
index 000000000..4effa19f4
--- /dev/null
+++ b/cli/tests/014_duplicate_import.ts.out
@@ -0,0 +1 @@
+hello!
diff --git a/cli/tests/015_duplicate_parallel_import.js b/cli/tests/015_duplicate_parallel_import.js
new file mode 100644
index 000000000..37033cfa2
--- /dev/null
+++ b/cli/tests/015_duplicate_parallel_import.js
@@ -0,0 +1,20 @@
+// Importing the same module in parallel, the module should only be
+// instantiated once.
+
+const promises = new Array(100)
+ .fill(null)
+ .map(() => import("./subdir/mod1.ts"));
+
+Promise.all(promises).then(imports => {
+ const mod = imports.reduce((first, cur) => {
+ if (typeof first !== "object") {
+ throw new Error("Expected an object.");
+ }
+ if (first !== cur) {
+ throw new Error("More than one instance of the same module.");
+ }
+ return first;
+ });
+
+ mod.printHello3();
+});
diff --git a/cli/tests/015_duplicate_parallel_import.js.out b/cli/tests/015_duplicate_parallel_import.js.out
new file mode 100644
index 000000000..e965047ad
--- /dev/null
+++ b/cli/tests/015_duplicate_parallel_import.js.out
@@ -0,0 +1 @@
+Hello
diff --git a/cli/tests/016_double_await.ts b/cli/tests/016_double_await.ts
new file mode 100644
index 000000000..9b4801567
--- /dev/null
+++ b/cli/tests/016_double_await.ts
@@ -0,0 +1,8 @@
+// This is to test if Deno would die at 2nd await
+// See https://github.com/denoland/deno/issues/919
+(async (): Promise<void> => {
+ const currDirInfo = await Deno.stat(".");
+ const parentDirInfo = await Deno.stat("..");
+ console.log(currDirInfo.isDirectory());
+ console.log(parentDirInfo.isFile());
+})();
diff --git a/cli/tests/016_double_await.ts.out b/cli/tests/016_double_await.ts.out
new file mode 100644
index 000000000..da29283aa
--- /dev/null
+++ b/cli/tests/016_double_await.ts.out
@@ -0,0 +1,2 @@
+true
+false
diff --git a/cli/tests/017_import_redirect.ts b/cli/tests/017_import_redirect.ts
new file mode 100644
index 000000000..1265dd4ed
--- /dev/null
+++ b/cli/tests/017_import_redirect.ts
@@ -0,0 +1,4 @@
+// http -> https redirect would happen:
+import { printHello } from "http://gist.githubusercontent.com/ry/f12b2aa3409e6b52645bc346a9e22929/raw/79318f239f51d764384a8bded8d7c6a833610dde/print_hello.ts";
+
+printHello();
diff --git a/cli/tests/017_import_redirect.ts.out b/cli/tests/017_import_redirect.ts.out
new file mode 100644
index 000000000..e965047ad
--- /dev/null
+++ b/cli/tests/017_import_redirect.ts.out
@@ -0,0 +1 @@
+Hello
diff --git a/cli/tests/018_async_catch.ts b/cli/tests/018_async_catch.ts
new file mode 100644
index 000000000..0d034d798
--- /dev/null
+++ b/cli/tests/018_async_catch.ts
@@ -0,0 +1,14 @@
+async function fn(): Promise<never> {
+ throw new Error("message");
+}
+async function call(): Promise<void> {
+ try {
+ console.log("before await fn()");
+ await fn();
+ console.log("after await fn()");
+ } catch (error) {
+ console.log("catch");
+ }
+ console.log("after try-catch");
+}
+call().catch((): void => console.log("outer catch"));
diff --git a/cli/tests/018_async_catch.ts.out b/cli/tests/018_async_catch.ts.out
new file mode 100644
index 000000000..4fc219973
--- /dev/null
+++ b/cli/tests/018_async_catch.ts.out
@@ -0,0 +1,3 @@
+before await fn()
+catch
+after try-catch
diff --git a/cli/tests/019_media_types.ts b/cli/tests/019_media_types.ts
new file mode 100644
index 000000000..cc99be83b
--- /dev/null
+++ b/cli/tests/019_media_types.ts
@@ -0,0 +1,24 @@
+// When run against the test HTTP server, it will serve different media types
+// based on the URL containing `.t#.` strings, which exercises the different
+// mapping of media types end to end.
+
+import { loaded as loadedTs1 } from "http://localhost:4545/cli/tests/subdir/mt_text_typescript.t1.ts";
+import { loaded as loadedTs2 } from "http://localhost:4545/cli/tests/subdir/mt_video_vdn.t2.ts";
+import { loaded as loadedTs3 } from "http://localhost:4545/cli/tests/subdir/mt_video_mp2t.t3.ts";
+import { loaded as loadedTs4 } from "http://localhost:4545/cli/tests/subdir/mt_application_x_typescript.t4.ts";
+import { loaded as loadedJs1 } from "http://localhost:4545/cli/tests/subdir/mt_text_javascript.j1.js";
+import { loaded as loadedJs2 } from "http://localhost:4545/cli/tests/subdir/mt_application_ecmascript.j2.js";
+import { loaded as loadedJs3 } from "http://localhost:4545/cli/tests/subdir/mt_text_ecmascript.j3.js";
+import { loaded as loadedJs4 } from "http://localhost:4545/cli/tests/subdir/mt_application_x_javascript.j4.js";
+
+console.log(
+ "success",
+ loadedTs1,
+ loadedTs2,
+ loadedTs3,
+ loadedTs4,
+ loadedJs1,
+ loadedJs2,
+ loadedJs3,
+ loadedJs4
+);
diff --git a/cli/tests/019_media_types.ts.out b/cli/tests/019_media_types.ts.out
new file mode 100644
index 000000000..7b5fdd44f
--- /dev/null
+++ b/cli/tests/019_media_types.ts.out
@@ -0,0 +1 @@
+success true true true true true true true true
diff --git a/cli/tests/020_json_modules.ts b/cli/tests/020_json_modules.ts
new file mode 100644
index 000000000..fdc85c440
--- /dev/null
+++ b/cli/tests/020_json_modules.ts
@@ -0,0 +1,2 @@
+import config from "./subdir/config.json";
+console.log(JSON.stringify(config));
diff --git a/cli/tests/020_json_modules.ts.out b/cli/tests/020_json_modules.ts.out
new file mode 100644
index 000000000..5d1623e6b
--- /dev/null
+++ b/cli/tests/020_json_modules.ts.out
@@ -0,0 +1 @@
+{"foo":{"bar":true,"baz":["qat",1]}}
diff --git a/cli/tests/021_mjs_modules.ts b/cli/tests/021_mjs_modules.ts
new file mode 100644
index 000000000..6052b9081
--- /dev/null
+++ b/cli/tests/021_mjs_modules.ts
@@ -0,0 +1,2 @@
+import { isMod5 } from "./subdir/mod5.mjs";
+console.log(isMod5);
diff --git a/cli/tests/021_mjs_modules.ts.out b/cli/tests/021_mjs_modules.ts.out
new file mode 100644
index 000000000..27ba77dda
--- /dev/null
+++ b/cli/tests/021_mjs_modules.ts.out
@@ -0,0 +1 @@
+true
diff --git a/cli/tests/022_info_flag_script.out b/cli/tests/022_info_flag_script.out
new file mode 100644
index 000000000..48eef7365
--- /dev/null
+++ b/cli/tests/022_info_flag_script.out
@@ -0,0 +1,14 @@
+local: [WILDCARD]019_media_types.ts
+type: TypeScript
+compiled: [WILDCARD].js
+map: [WILDCARD].js.map
+deps:
+http://127.0.0.1:4545/cli/tests/019_media_types.ts
+ ├── http://localhost:4545/cli/tests/subdir/mt_text_typescript.t1.ts
+ ├── http://localhost:4545/cli/tests/subdir/mt_video_vdn.t2.ts
+ ├── http://localhost:4545/cli/tests/subdir/mt_video_mp2t.t3.ts
+ ├── http://localhost:4545/cli/tests/subdir/mt_application_x_typescript.t4.ts
+ ├── http://localhost:4545/cli/tests/subdir/mt_text_javascript.j1.js
+ ├── http://localhost:4545/cli/tests/subdir/mt_application_ecmascript.j2.js
+ ├── http://localhost:4545/cli/tests/subdir/mt_text_ecmascript.j3.js
+ └── http://localhost:4545/cli/tests/subdir/mt_application_x_javascript.j4.js
diff --git a/cli/tests/023_no_ext_with_headers b/cli/tests/023_no_ext_with_headers
new file mode 100644
index 000000000..87951d835
--- /dev/null
+++ b/cli/tests/023_no_ext_with_headers
@@ -0,0 +1 @@
+console.log("HELLO");
diff --git a/cli/tests/023_no_ext_with_headers.headers.json b/cli/tests/023_no_ext_with_headers.headers.json
new file mode 100644
index 000000000..5b6f09aeb
--- /dev/null
+++ b/cli/tests/023_no_ext_with_headers.headers.json
@@ -0,0 +1 @@
+{ "mime_type": "application/javascript" }
diff --git a/cli/tests/023_no_ext_with_headers.out b/cli/tests/023_no_ext_with_headers.out
new file mode 100644
index 000000000..e427984d4
--- /dev/null
+++ b/cli/tests/023_no_ext_with_headers.out
@@ -0,0 +1 @@
+HELLO
diff --git a/cli/tests/024_import_no_ext_with_headers.ts b/cli/tests/024_import_no_ext_with_headers.ts
new file mode 100644
index 000000000..c8621d0e6
--- /dev/null
+++ b/cli/tests/024_import_no_ext_with_headers.ts
@@ -0,0 +1 @@
+import "./023_no_ext_with_headers";
diff --git a/cli/tests/024_import_no_ext_with_headers.ts.out b/cli/tests/024_import_no_ext_with_headers.ts.out
new file mode 100644
index 000000000..e427984d4
--- /dev/null
+++ b/cli/tests/024_import_no_ext_with_headers.ts.out
@@ -0,0 +1 @@
+HELLO
diff --git a/cli/tests/025_hrtime.ts b/cli/tests/025_hrtime.ts
new file mode 100644
index 000000000..417ca6982
--- /dev/null
+++ b/cli/tests/025_hrtime.ts
@@ -0,0 +1,3 @@
+console.log(performance.now() % 2 !== 0);
+Deno.revokePermission("hrtime");
+console.log(performance.now() % 2 === 0);
diff --git a/cli/tests/025_hrtime.ts.out b/cli/tests/025_hrtime.ts.out
new file mode 100644
index 000000000..bb101b641
--- /dev/null
+++ b/cli/tests/025_hrtime.ts.out
@@ -0,0 +1,2 @@
+true
+true
diff --git a/cli/tests/025_reload_js_type_error.js b/cli/tests/025_reload_js_type_error.js
new file mode 100644
index 000000000..8d6e4b415
--- /dev/null
+++ b/cli/tests/025_reload_js_type_error.js
@@ -0,0 +1,5 @@
+// There was a bug where if this was executed with --reload it would throw a
+// type error.
+window.test = null;
+test = console;
+test.log("hello");
diff --git a/cli/tests/025_reload_js_type_error.js.out b/cli/tests/025_reload_js_type_error.js.out
new file mode 100644
index 000000000..ce0136250
--- /dev/null
+++ b/cli/tests/025_reload_js_type_error.js.out
@@ -0,0 +1 @@
+hello
diff --git a/cli/tests/026_redirect_javascript.js b/cli/tests/026_redirect_javascript.js
new file mode 100644
index 000000000..226a6b622
--- /dev/null
+++ b/cli/tests/026_redirect_javascript.js
@@ -0,0 +1,2 @@
+import { value } from "http://localhost:4547/redirects/redirect3.js";
+console.log(value);
diff --git a/cli/tests/026_redirect_javascript.js.out b/cli/tests/026_redirect_javascript.js.out
new file mode 100644
index 000000000..290864299
--- /dev/null
+++ b/cli/tests/026_redirect_javascript.js.out
@@ -0,0 +1 @@
+3 imports 1
diff --git a/cli/tests/026_workers.ts b/cli/tests/026_workers.ts
new file mode 100644
index 000000000..f45fc4b77
--- /dev/null
+++ b/cli/tests/026_workers.ts
@@ -0,0 +1,14 @@
+const jsWorker = new Worker("./subdir/test_worker.js");
+const tsWorker = new Worker("./subdir/test_worker.ts");
+
+tsWorker.onmessage = (e): void => {
+ console.log("Received ts: " + e.data);
+};
+
+jsWorker.onmessage = (e): void => {
+ console.log("Received js: " + e.data);
+
+ tsWorker.postMessage("Hello World");
+};
+
+jsWorker.postMessage("Hello World");
diff --git a/cli/tests/026_workers.ts.out b/cli/tests/026_workers.ts.out
new file mode 100644
index 000000000..7538cc867
--- /dev/null
+++ b/cli/tests/026_workers.ts.out
@@ -0,0 +1,4 @@
+Hello World
+Received js: Hello World
+Hello World
+Received ts: Hello World
diff --git a/cli/tests/027_redirect_typescript.ts b/cli/tests/027_redirect_typescript.ts
new file mode 100644
index 000000000..584341975
--- /dev/null
+++ b/cli/tests/027_redirect_typescript.ts
@@ -0,0 +1,2 @@
+import { value } from "http://localhost:4547/redirects/redirect4.ts";
+console.log(value);
diff --git a/cli/tests/027_redirect_typescript.ts.out b/cli/tests/027_redirect_typescript.ts.out
new file mode 100644
index 000000000..480d4e8ca
--- /dev/null
+++ b/cli/tests/027_redirect_typescript.ts.out
@@ -0,0 +1 @@
+4 imports 1
diff --git a/cli/tests/028_args.ts b/cli/tests/028_args.ts
new file mode 100644
index 000000000..51c5cb14b
--- /dev/null
+++ b/cli/tests/028_args.ts
@@ -0,0 +1,5 @@
+Deno.args.forEach(
+ (arg): void => {
+ console.log(arg);
+ }
+);
diff --git a/cli/tests/028_args.ts.out b/cli/tests/028_args.ts.out
new file mode 100644
index 000000000..fa36f6e4c
--- /dev/null
+++ b/cli/tests/028_args.ts.out
@@ -0,0 +1,7 @@
+028_args.ts
+--arg1
+val1
+--arg2=val2
+--
+arg3
+arg4
diff --git a/cli/tests/029_eval.out b/cli/tests/029_eval.out
new file mode 100644
index 000000000..ce0136250
--- /dev/null
+++ b/cli/tests/029_eval.out
@@ -0,0 +1 @@
+hello
diff --git a/cli/tests/030_xeval.out b/cli/tests/030_xeval.out
new file mode 100644
index 000000000..b1e67221a
--- /dev/null
+++ b/cli/tests/030_xeval.out
@@ -0,0 +1,3 @@
+A
+B
+C
diff --git a/cli/tests/031_xeval_replvar.out b/cli/tests/031_xeval_replvar.out
new file mode 100644
index 000000000..b1e67221a
--- /dev/null
+++ b/cli/tests/031_xeval_replvar.out
@@ -0,0 +1,3 @@
+A
+B
+C
diff --git a/cli/tests/032_xeval_delim.out b/cli/tests/032_xeval_delim.out
new file mode 100644
index 000000000..b1e67221a
--- /dev/null
+++ b/cli/tests/032_xeval_delim.out
@@ -0,0 +1,3 @@
+A
+B
+C
diff --git a/cli/tests/033_import_map.out b/cli/tests/033_import_map.out
new file mode 100644
index 000000000..e9b9160e9
--- /dev/null
+++ b/cli/tests/033_import_map.out
@@ -0,0 +1,7 @@
+Hello from remapped moment!
+Hello from remapped moment dir!
+Hello from remapped lodash!
+Hello from remapped lodash dir!
+Hello from remapped Vue!
+Hello from scoped moment!
+Hello from scoped!
diff --git a/cli/tests/034_onload.out b/cli/tests/034_onload.out
new file mode 100644
index 000000000..c9556e991
--- /dev/null
+++ b/cli/tests/034_onload.out
@@ -0,0 +1,11 @@
+log from nest_imported script
+log from imported script
+log from main
+got load event in onload function
+got load event in event handler (nest_imported)
+got load event in event handler (imported)
+got load event in event handler (main)
+got unload event in onunload function
+got unload event in event handler (nest_imported)
+got unload event in event handler (imported)
+got unload event in event handler (main)
diff --git a/cli/tests/034_onload/imported.ts b/cli/tests/034_onload/imported.ts
new file mode 100644
index 000000000..f9a7009b8
--- /dev/null
+++ b/cli/tests/034_onload/imported.ts
@@ -0,0 +1,11 @@
+import { assert } from "../../../std/testing/asserts.ts";
+import "./nest_imported.ts";
+
+const handler = (e: Event): void => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in event handler (imported)`);
+};
+
+window.addEventListener("load", handler);
+window.addEventListener("unload", handler);
+console.log("log from imported script");
diff --git a/cli/tests/034_onload/main.ts b/cli/tests/034_onload/main.ts
new file mode 100644
index 000000000..db6ca669a
--- /dev/null
+++ b/cli/tests/034_onload/main.ts
@@ -0,0 +1,23 @@
+import { assert } from "../../../std/testing/asserts.ts";
+import "./imported.ts";
+
+const eventHandler = (e: Event): void => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in event handler (main)`);
+};
+
+window.addEventListener("load", eventHandler);
+
+window.addEventListener("unload", eventHandler);
+
+window.onload = (e: Event): void => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in onload function`);
+};
+
+window.onunload = (e: Event): void => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in onunload function`);
+};
+
+console.log("log from main");
diff --git a/cli/tests/034_onload/nest_imported.ts b/cli/tests/034_onload/nest_imported.ts
new file mode 100644
index 000000000..6b4a40749
--- /dev/null
+++ b/cli/tests/034_onload/nest_imported.ts
@@ -0,0 +1,10 @@
+import { assert } from "../../../std/testing/asserts.ts";
+
+const handler = (e: Event): void => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in event handler (nest_imported)`);
+};
+
+window.addEventListener("load", handler);
+window.addEventListener("unload", handler);
+console.log("log from nest_imported script");
diff --git a/cli/tests/035_no_fetch_flag.out b/cli/tests/035_no_fetch_flag.out
new file mode 100644
index 000000000..26f020aa5
--- /dev/null
+++ b/cli/tests/035_no_fetch_flag.out
@@ -0,0 +1 @@
+Cannot resolve module "http://127.0.0.1:4545/cli/tests/019_media_types.ts"
diff --git a/cli/tests/036_import_map_fetch.out b/cli/tests/036_import_map_fetch.out
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/cli/tests/036_import_map_fetch.out
diff --git a/cli/tests/038_checkjs.js b/cli/tests/038_checkjs.js
new file mode 100644
index 000000000..628d3e376
--- /dev/null
+++ b/cli/tests/038_checkjs.js
@@ -0,0 +1,6 @@
+// console.log intentionally misspelled to trigger a type error
+consol.log("hello world!");
+
+// the following error should be ignored and not output to the console
+// eslint-disable-next-line
+const foo = new Foo();
diff --git a/cli/tests/038_checkjs.js.out b/cli/tests/038_checkjs.js.out
new file mode 100644
index 000000000..deaf77211
--- /dev/null
+++ b/cli/tests/038_checkjs.js.out
@@ -0,0 +1,15 @@
+[WILDCARD]
+error TS2552: Cannot find name 'consol'. Did you mean 'console'?
+
+[WILDCARD]tests/038_checkjs.js:2:1
+
+2 consol.log("hello world!");
+[WILDCARD]
+error TS2552: Cannot find name 'Foo'. Did you mean 'foo'?
+
+[WILDCARD]tests/038_checkjs.js:6:17
+
+6 const foo = new Foo();
+[WILDCARD]
+Found 2 errors.
+[WILDCARD] \ No newline at end of file
diff --git a/cli/tests/038_checkjs.tsconfig.json b/cli/tests/038_checkjs.tsconfig.json
new file mode 100644
index 000000000..08ac60b6c
--- /dev/null
+++ b/cli/tests/038_checkjs.tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "compilerOptions": {
+ "checkJs": true
+ }
+}
diff --git a/cli/tests/039_worker_deno_ns.ts b/cli/tests/039_worker_deno_ns.ts
new file mode 100644
index 000000000..80ada4343
--- /dev/null
+++ b/cli/tests/039_worker_deno_ns.ts
@@ -0,0 +1,25 @@
+const w1 = new Worker("./039_worker_deno_ns/has_ns.ts");
+const w2 = new Worker("./039_worker_deno_ns/no_ns.ts", {
+ noDenoNamespace: true
+});
+let w1MsgCount = 0;
+let w2MsgCount = 0;
+w1.onmessage = (msg): void => {
+ console.log(msg.data);
+ w1MsgCount++;
+ if (w1MsgCount === 1) {
+ w1.postMessage("CONTINUE");
+ } else {
+ w2.postMessage("START");
+ }
+};
+w2.onmessage = (msg): void => {
+ console.log(msg.data);
+ w2MsgCount++;
+ if (w2MsgCount === 1) {
+ w2.postMessage("CONTINUE");
+ } else {
+ Deno.exit(0);
+ }
+};
+w1.postMessage("START");
diff --git a/cli/tests/039_worker_deno_ns.ts.out b/cli/tests/039_worker_deno_ns.ts.out
new file mode 100644
index 000000000..9b2f90099
--- /dev/null
+++ b/cli/tests/039_worker_deno_ns.ts.out
@@ -0,0 +1,4 @@
+has_ns.ts: is window.Deno available: true
+[SPAWNED BY has_ns.ts] maybe_ns.ts: is window.Deno available: true
+no_ns.ts: is window.Deno available: false
+[SPAWNED BY no_ns.ts] maybe_ns.ts: is window.Deno available: false
diff --git a/cli/tests/039_worker_deno_ns/has_ns.ts b/cli/tests/039_worker_deno_ns/has_ns.ts
new file mode 100644
index 000000000..8d2507122
--- /dev/null
+++ b/cli/tests/039_worker_deno_ns/has_ns.ts
@@ -0,0 +1,10 @@
+onmessage = (msg): void => {
+ if (msg.data === "START") {
+ postMessage("has_ns.ts: is window.Deno available: " + !!window.Deno);
+ } else {
+ const worker = new Worker("./maybe_ns.ts");
+ worker.onmessage = (msg): void => {
+ postMessage("[SPAWNED BY has_ns.ts] " + msg.data);
+ };
+ }
+};
diff --git a/cli/tests/039_worker_deno_ns/maybe_ns.ts b/cli/tests/039_worker_deno_ns/maybe_ns.ts
new file mode 100644
index 000000000..0bcbd1f97
--- /dev/null
+++ b/cli/tests/039_worker_deno_ns/maybe_ns.ts
@@ -0,0 +1 @@
+postMessage("maybe_ns.ts: is window.Deno available: " + !!window.Deno);
diff --git a/cli/tests/039_worker_deno_ns/no_ns.ts b/cli/tests/039_worker_deno_ns/no_ns.ts
new file mode 100644
index 000000000..0489a00a3
--- /dev/null
+++ b/cli/tests/039_worker_deno_ns/no_ns.ts
@@ -0,0 +1,10 @@
+onmessage = (msg): void => {
+ if (msg.data === "START") {
+ postMessage("no_ns.ts: is window.Deno available: " + !!window.Deno);
+ } else {
+ const worker = new Worker("./maybe_ns.ts");
+ worker.onmessage = (msg): void => {
+ postMessage("[SPAWNED BY no_ns.ts] " + msg.data);
+ };
+ }
+};
diff --git a/cli/tests/040_worker_blob.ts b/cli/tests/040_worker_blob.ts
new file mode 100644
index 000000000..1ba4528cf
--- /dev/null
+++ b/cli/tests/040_worker_blob.ts
@@ -0,0 +1,6 @@
+const b = new Blob(["console.log('code from Blob'); postMessage('DONE')"]);
+const blobURL = URL.createObjectURL(b);
+const worker = new Worker(blobURL);
+worker.onmessage = (): void => {
+ Deno.exit(0);
+};
diff --git a/cli/tests/040_worker_blob.ts.out b/cli/tests/040_worker_blob.ts.out
new file mode 100644
index 000000000..f49b8f3d6
--- /dev/null
+++ b/cli/tests/040_worker_blob.ts.out
@@ -0,0 +1 @@
+code from Blob
diff --git a/cli/tests/041_dyn_import_eval.out b/cli/tests/041_dyn_import_eval.out
new file mode 100644
index 000000000..1dfef2e98
--- /dev/null
+++ b/cli/tests/041_dyn_import_eval.out
@@ -0,0 +1 @@
+{ isMod4: true }
diff --git a/cli/tests/041_info_flag.out b/cli/tests/041_info_flag.out
new file mode 100644
index 000000000..c384fa892
--- /dev/null
+++ b/cli/tests/041_info_flag.out
@@ -0,0 +1,3 @@
+DENO_DIR location: "[WILDCARD]"
+Remote modules cache: "[WILDCARD]deps"
+TypeScript compiler cache: "[WILDCARD]gen"
diff --git a/cli/tests/042_dyn_import_evalcontext.ts b/cli/tests/042_dyn_import_evalcontext.ts
new file mode 100644
index 000000000..124a406d2
--- /dev/null
+++ b/cli/tests/042_dyn_import_evalcontext.ts
@@ -0,0 +1,4 @@
+// @ts-ignore
+Deno.core.evalContext(
+ "(async () => console.log(await import('./subdir/mod4.js')))()"
+);
diff --git a/cli/tests/042_dyn_import_evalcontext.ts.out b/cli/tests/042_dyn_import_evalcontext.ts.out
new file mode 100644
index 000000000..1dfef2e98
--- /dev/null
+++ b/cli/tests/042_dyn_import_evalcontext.ts.out
@@ -0,0 +1 @@
+{ isMod4: true }
diff --git a/cli/tests/044_bad_resource.ts b/cli/tests/044_bad_resource.ts
new file mode 100644
index 000000000..39ca3d120
--- /dev/null
+++ b/cli/tests/044_bad_resource.ts
@@ -0,0 +1,7 @@
+async function main(): Promise<void> {
+ const file = await Deno.open("044_bad_resource.ts", "r");
+ file.close();
+ await file.seek(10, 0);
+}
+
+main();
diff --git a/cli/tests/044_bad_resource.ts.out b/cli/tests/044_bad_resource.ts.out
new file mode 100644
index 000000000..155e4396f
--- /dev/null
+++ b/cli/tests/044_bad_resource.ts.out
@@ -0,0 +1,6 @@
+[WILDCARD]
+error: Uncaught BadResource: bad resource id
+[WILDCARD]dispatch_json.ts:[WILDCARD]
+ at DenoError ([WILDCARD]errors.ts:[WILDCARD])
+ at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
+ at sendAsync ([WILDCARD]dispatch_json.ts:[WILDCARD])
diff --git a/cli/tests/045_proxy_client.ts b/cli/tests/045_proxy_client.ts
new file mode 100644
index 000000000..4fb3db83b
--- /dev/null
+++ b/cli/tests/045_proxy_client.ts
@@ -0,0 +1,7 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+async function main(): Promise<void> {
+ const res = await fetch("http://deno.land/welcome.ts");
+ console.log(`Response http: ${await res.text()}`);
+}
+
+main();
diff --git a/cli/tests/045_proxy_test.ts b/cli/tests/045_proxy_test.ts
new file mode 100644
index 000000000..f1226f4c4
--- /dev/null
+++ b/cli/tests/045_proxy_test.ts
@@ -0,0 +1,72 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+import { serve, ServerRequest } from "../../std/http/server.ts";
+import { assertEquals } from "../../std/testing/asserts.ts";
+
+const addr = Deno.args[1] || "127.0.0.1:4555";
+
+async function proxyServer(): Promise<void> {
+ const server = serve(addr);
+
+ console.log(`Proxy server listening on http://${addr}/`);
+ for await (const req of server) {
+ proxyRequest(req);
+ }
+}
+
+async function proxyRequest(req: ServerRequest): Promise<void> {
+ console.log(`Proxy request to: ${req.url}`);
+ const resp = await fetch(req.url, {
+ method: req.method,
+ headers: req.headers
+ });
+ req.respond(resp);
+}
+
+async function testFetch(): Promise<void> {
+ const c = Deno.run({
+ args: [
+ Deno.execPath(),
+ "--no-prompt",
+ "--reload",
+ "--allow-net",
+ "045_proxy_client.ts"
+ ],
+ stdout: "piped",
+ env: {
+ HTTP_PROXY: `http://${addr}`
+ }
+ });
+
+ const status = await c.status();
+ assertEquals(status.code, 0);
+ c.close();
+}
+
+async function testModuleDownload(): Promise<void> {
+ const http = Deno.run({
+ args: [
+ Deno.execPath(),
+ "--no-prompt",
+ "--reload",
+ "fetch",
+ "http://deno.land/welcome.ts"
+ ],
+ stdout: "piped",
+ env: {
+ HTTP_PROXY: `http://${addr}`
+ }
+ });
+
+ const httpStatus = await http.status();
+ assertEquals(httpStatus.code, 0);
+ http.close();
+}
+
+async function main(): Promise<void> {
+ proxyServer();
+ await testFetch();
+ await testModuleDownload();
+ Deno.exit(0);
+}
+
+main();
diff --git a/cli/tests/045_proxy_test.ts.out b/cli/tests/045_proxy_test.ts.out
new file mode 100644
index 000000000..7b898bcf1
--- /dev/null
+++ b/cli/tests/045_proxy_test.ts.out
@@ -0,0 +1,3 @@
+Proxy server listening on [WILDCARD]
+Proxy request to: http://deno.land/welcome.ts
+Proxy request to: http://deno.land/welcome.ts
diff --git a/cli/tests/046_jsx_test.tsx b/cli/tests/046_jsx_test.tsx
new file mode 100644
index 000000000..4e9380eb8
--- /dev/null
+++ b/cli/tests/046_jsx_test.tsx
@@ -0,0 +1,9 @@
+const React = {
+ createElement(factory: any, props: any, ...children: any[]) {
+ return {factory, props, children}
+ }
+}
+const View = () => (
+ <div class="deno">land</div>
+)
+console.log(<View />)
diff --git a/cli/tests/046_jsx_test.tsx.out b/cli/tests/046_jsx_test.tsx.out
new file mode 100644
index 000000000..85cfe824b
--- /dev/null
+++ b/cli/tests/046_jsx_test.tsx.out
@@ -0,0 +1 @@
+{ factory: [Function: View], props: null, children: [] }
diff --git a/cli/tests/047_jsx_test.jsx b/cli/tests/047_jsx_test.jsx
new file mode 100644
index 000000000..553c4c5a5
--- /dev/null
+++ b/cli/tests/047_jsx_test.jsx
@@ -0,0 +1,9 @@
+const React = {
+ createElement(factory, props, ...children) {
+ return {factory, props, children}
+ }
+}
+const View = () => (
+ <div class="deno">land</div>
+)
+console.log(<View />)
diff --git a/cli/tests/047_jsx_test.jsx.out b/cli/tests/047_jsx_test.jsx.out
new file mode 100644
index 000000000..85cfe824b
--- /dev/null
+++ b/cli/tests/047_jsx_test.jsx.out
@@ -0,0 +1 @@
+{ factory: [Function: View], props: null, children: [] }
diff --git a/cli/tests/README.md b/cli/tests/README.md
new file mode 100644
index 000000000..fe9071926
--- /dev/null
+++ b/cli/tests/README.md
@@ -0,0 +1,7 @@
+# Integration Tests
+
+This path contains integration tests. See integration_tests.rs for the index.
+
+TODO(ry) Currently //tests is a symlink to //cli/tests, to simplify transition.
+In the future the symlink should be removed when all the many references have
+been updated to the new path.
diff --git a/cli/tests/async_error.ts b/cli/tests/async_error.ts
new file mode 100644
index 000000000..81c983a50
--- /dev/null
+++ b/cli/tests/async_error.ts
@@ -0,0 +1,8 @@
+console.log("hello");
+const foo = async (): Promise<never> => {
+ console.log("before error");
+ throw Error("error");
+};
+
+foo();
+console.log("world");
diff --git a/cli/tests/async_error.ts.out b/cli/tests/async_error.ts.out
new file mode 100644
index 000000000..d07ba8cfe
--- /dev/null
+++ b/cli/tests/async_error.ts.out
@@ -0,0 +1,11 @@
+[WILDCARD]hello
+before error
+world
+error: Uncaught Error: error
+[WILDCARD]tests/async_error.ts:4:9
+
+4 throw Error("error");
+ ^
+
+ at foo ([WILDCARD]tests/async_error.ts:4:9)
+ at [WILDCARD]tests/async_error.ts:7:1
diff --git a/cli/tests/badly_formatted.js b/cli/tests/badly_formatted.js
new file mode 100644
index 000000000..17e3e6be0
--- /dev/null
+++ b/cli/tests/badly_formatted.js
@@ -0,0 +1,4 @@
+
+console.log(
+ "Hello World"
+)
diff --git a/cli/tests/badly_formatted_fixed.js b/cli/tests/badly_formatted_fixed.js
new file mode 100644
index 000000000..accefceba
--- /dev/null
+++ b/cli/tests/badly_formatted_fixed.js
@@ -0,0 +1 @@
+console.log("Hello World");
diff --git a/cli/tests/cat.ts b/cli/tests/cat.ts
new file mode 100644
index 000000000..756238be6
--- /dev/null
+++ b/cli/tests/cat.ts
@@ -0,0 +1,11 @@
+const { stdout, open, copy, args } = Deno;
+
+async function main(): Promise<void> {
+ for (let i = 1; i < args.length; i++) {
+ const filename = args[i];
+ const file = await open(filename);
+ await copy(stdout, file);
+ }
+}
+
+main();
diff --git a/cli/tests/circular1.js b/cli/tests/circular1.js
new file mode 100644
index 000000000..8b2cc4960
--- /dev/null
+++ b/cli/tests/circular1.js
@@ -0,0 +1,2 @@
+import "./circular2.js";
+console.log("circular1");
diff --git a/cli/tests/circular1.js.out b/cli/tests/circular1.js.out
new file mode 100644
index 000000000..21f7fd585
--- /dev/null
+++ b/cli/tests/circular1.js.out
@@ -0,0 +1,2 @@
+circular2
+circular1
diff --git a/cli/tests/circular2.js b/cli/tests/circular2.js
new file mode 100644
index 000000000..62127e04d
--- /dev/null
+++ b/cli/tests/circular2.js
@@ -0,0 +1,2 @@
+import "./circular1.js";
+console.log("circular2");
diff --git a/cli/tests/config.ts b/cli/tests/config.ts
new file mode 100644
index 000000000..e08061e77
--- /dev/null
+++ b/cli/tests/config.ts
@@ -0,0 +1,5 @@
+const map = new Map<string, { foo: string }>();
+
+if (map.get("bar").foo) {
+ console.log("here");
+}
diff --git a/cli/tests/config.ts.out b/cli/tests/config.ts.out
new file mode 100644
index 000000000..db5a8340e
--- /dev/null
+++ b/cli/tests/config.ts.out
@@ -0,0 +1,10 @@
+[WILDCARD]Unsupported compiler options in "[WILDCARD]config.tsconfig.json"
+ The following options were ignored:
+ module, target
+[WILDCARD]error TS2532: Object is possibly 'undefined'.
+
+[WILDCARD]tests/config.ts:3:5
+
+3 if (map.get("bar").foo) {
+ ~~~~~~~~~~~~~~
+
diff --git a/cli/tests/config.tsconfig.json b/cli/tests/config.tsconfig.json
new file mode 100644
index 000000000..074d7ac0b
--- /dev/null
+++ b/cli/tests/config.tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "compilerOptions": {
+ "module": "amd",
+ "strict": true,
+ "target": "es5"
+ }
+}
diff --git a/cli/tests/echo_server.ts b/cli/tests/echo_server.ts
new file mode 100644
index 000000000..5c6b5954b
--- /dev/null
+++ b/cli/tests/echo_server.ts
@@ -0,0 +1,12 @@
+const { args, listen, copy } = Deno;
+const addr = args[1] || "0.0.0.0:4544";
+const [hostname, port] = addr.split(":");
+const listener = listen({ hostname, port: Number(port) });
+console.log("listening on", addr);
+listener.accept().then(
+ async (conn): Promise<void> => {
+ await copy(conn, conn);
+ conn.close();
+ listener.close();
+ }
+);
diff --git a/cli/tests/error_001.ts b/cli/tests/error_001.ts
new file mode 100644
index 000000000..f06f80cb4
--- /dev/null
+++ b/cli/tests/error_001.ts
@@ -0,0 +1,9 @@
+function foo(): never {
+ throw Error("bad");
+}
+
+function bar(): void {
+ foo();
+}
+
+bar();
diff --git a/cli/tests/error_001.ts.out b/cli/tests/error_001.ts.out
new file mode 100644
index 000000000..3c7e2828e
--- /dev/null
+++ b/cli/tests/error_001.ts.out
@@ -0,0 +1,9 @@
+[WILDCARD]error: Uncaught Error: bad
+[WILDCARD]tests/error_001.ts:2:9
+
+2 throw Error("bad");
+ ^
+
+ at foo ([WILDCARD]tests/error_001.ts:2:9)
+ at bar ([WILDCARD]tests/error_001.ts:6:3)
+ at [WILDCARD]tests/error_001.ts:9:1
diff --git a/cli/tests/error_002.ts b/cli/tests/error_002.ts
new file mode 100644
index 000000000..eb66764b7
--- /dev/null
+++ b/cli/tests/error_002.ts
@@ -0,0 +1,7 @@
+import { throwsError } from "./subdir/mod1.ts";
+
+function foo(): void {
+ throwsError();
+}
+
+foo();
diff --git a/cli/tests/error_002.ts.out b/cli/tests/error_002.ts.out
new file mode 100644
index 000000000..292544a33
--- /dev/null
+++ b/cli/tests/error_002.ts.out
@@ -0,0 +1,9 @@
+[WILDCARD]error: Uncaught Error: exception from mod1
+[WILDCARD]tests/subdir/mod1.ts:16:9
+
+16 throw Error("exception from mod1");
+ ^
+
+ at throwsError ([WILDCARD]tests/subdir/mod1.ts:16:9)
+ at foo ([WILDCARD]tests/error_002.ts:4:3)
+ at [WILDCARD]tests/error_002.ts:7:1
diff --git a/cli/tests/error_003_typescript.ts b/cli/tests/error_003_typescript.ts
new file mode 100644
index 000000000..4ce86bb83
--- /dev/null
+++ b/cli/tests/error_003_typescript.ts
@@ -0,0 +1,20 @@
+/* eslint-disable */
+let x = {
+ a: {
+ b: {
+ c() {
+ return { d: "hello" };
+ }
+ }
+ }
+};
+let y = {
+ a: {
+ b: {
+ c() {
+ return { d: 1234 };
+ }
+ }
+ }
+};
+x = y;
diff --git a/cli/tests/error_003_typescript.ts.out b/cli/tests/error_003_typescript.ts.out
new file mode 100644
index 000000000..0b1d94db4
--- /dev/null
+++ b/cli/tests/error_003_typescript.ts.out
@@ -0,0 +1,16 @@
+[WILDCARD]error TS2322: Type '{ a: { b: { c(): { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c(): { d: string; }; }; }; }'.
+ Types of property 'a' are incompatible.
+ Type '{ b: { c(): { d: number; }; }; }' is not assignable to type '{ b: { c(): { d: string; }; }; }'.
+ Types of property 'b' are incompatible.
+ Type '{ c(): { d: number; }; }' is not assignable to type '{ c(): { d: string; }; }'.
+ Types of property 'c' are incompatible.
+ Type '() => { d: number; }' is not assignable to type '() => { d: string; }'.
+ Type '{ d: number; }' is not assignable to type '{ d: string; }'.
+ Types of property 'd' are incompatible.
+ Type 'number' is not assignable to type 'string'.
+
+[WILDCARD]/tests/error_003_typescript.ts:20:1
+
+20 x = y;
+ ^
+
diff --git a/cli/tests/error_004_missing_module.ts b/cli/tests/error_004_missing_module.ts
new file mode 100644
index 000000000..24ae52cf7
--- /dev/null
+++ b/cli/tests/error_004_missing_module.ts
@@ -0,0 +1,2 @@
+// eslint-disable-next-line
+import * as badModule from "./bad-module.ts";
diff --git a/cli/tests/error_004_missing_module.ts.out b/cli/tests/error_004_missing_module.ts.out
new file mode 100644
index 000000000..7a5f50938
--- /dev/null
+++ b/cli/tests/error_004_missing_module.ts.out
@@ -0,0 +1,5 @@
+[WILDCARD]error: Uncaught NotFound: Cannot resolve module "[WILDCARD]/bad-module.ts"
+[WILDCARD]dispatch_json.ts:[WILDCARD]
+ at DenoError ([WILDCARD]errors.ts:[WILDCARD])
+ at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
+ at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD])
diff --git a/cli/tests/error_005_missing_dynamic_import.ts b/cli/tests/error_005_missing_dynamic_import.ts
new file mode 100644
index 000000000..4c09feb5f
--- /dev/null
+++ b/cli/tests/error_005_missing_dynamic_import.ts
@@ -0,0 +1,4 @@
+(async (): Promise<void> => {
+ // eslint-disable-next-line
+ const badModule = await import("./bad-module.ts");
+})();
diff --git a/cli/tests/error_005_missing_dynamic_import.ts.out b/cli/tests/error_005_missing_dynamic_import.ts.out
new file mode 100644
index 000000000..7a5f50938
--- /dev/null
+++ b/cli/tests/error_005_missing_dynamic_import.ts.out
@@ -0,0 +1,5 @@
+[WILDCARD]error: Uncaught NotFound: Cannot resolve module "[WILDCARD]/bad-module.ts"
+[WILDCARD]dispatch_json.ts:[WILDCARD]
+ at DenoError ([WILDCARD]errors.ts:[WILDCARD])
+ at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
+ at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD])
diff --git a/cli/tests/error_006_import_ext_failure.ts b/cli/tests/error_006_import_ext_failure.ts
new file mode 100644
index 000000000..3c32303a3
--- /dev/null
+++ b/cli/tests/error_006_import_ext_failure.ts
@@ -0,0 +1 @@
+import "./non-existent";
diff --git a/cli/tests/error_006_import_ext_failure.ts.out b/cli/tests/error_006_import_ext_failure.ts.out
new file mode 100644
index 000000000..d88477df8
--- /dev/null
+++ b/cli/tests/error_006_import_ext_failure.ts.out
@@ -0,0 +1,5 @@
+[WILDCARD]error: Uncaught NotFound: Cannot resolve module "[WILDCARD]/non-existent"
+[WILDCARD]dispatch_json.ts:[WILDCARD]
+ at DenoError ([WILDCARD]errors.ts:[WILDCARD])
+ at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
+ at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD])
diff --git a/cli/tests/error_007_any.ts b/cli/tests/error_007_any.ts
new file mode 100644
index 000000000..778886fcb
--- /dev/null
+++ b/cli/tests/error_007_any.ts
@@ -0,0 +1 @@
+throw {};
diff --git a/cli/tests/error_007_any.ts.out b/cli/tests/error_007_any.ts.out
new file mode 100644
index 000000000..45dbffd04
--- /dev/null
+++ b/cli/tests/error_007_any.ts.out
@@ -0,0 +1 @@
+[WILDCARD]error: Uncaught #<Object>
diff --git a/cli/tests/error_008_checkjs.js b/cli/tests/error_008_checkjs.js
new file mode 100644
index 000000000..628d3e376
--- /dev/null
+++ b/cli/tests/error_008_checkjs.js
@@ -0,0 +1,6 @@
+// console.log intentionally misspelled to trigger a type error
+consol.log("hello world!");
+
+// the following error should be ignored and not output to the console
+// eslint-disable-next-line
+const foo = new Foo();
diff --git a/cli/tests/error_008_checkjs.js.out b/cli/tests/error_008_checkjs.js.out
new file mode 100644
index 000000000..5c50e8513
--- /dev/null
+++ b/cli/tests/error_008_checkjs.js.out
@@ -0,0 +1,7 @@
+[WILDCARD]error: Uncaught ReferenceError: consol is not defined
+[WILDCARD]tests/error_008_checkjs.js:2:1
+
+2 consol.log("hello world!");
+ ^
+
+ at [WILDCARD]tests/error_008_checkjs.js:2:1
diff --git a/cli/tests/error_009_missing_js_module.disabled b/cli/tests/error_009_missing_js_module.disabled
new file mode 100644
index 000000000..b16bb232b
--- /dev/null
+++ b/cli/tests/error_009_missing_js_module.disabled
@@ -0,0 +1,4 @@
+args: tests/error_009_missing_js_module.js
+check_stderr: true
+exit_code: 1
+output: tests/error_009_missing_js_module.js.out \ No newline at end of file
diff --git a/cli/tests/error_009_missing_js_module.js b/cli/tests/error_009_missing_js_module.js
new file mode 100644
index 000000000..e6ca88934
--- /dev/null
+++ b/cli/tests/error_009_missing_js_module.js
@@ -0,0 +1 @@
+import "./bad-module.js";
diff --git a/cli/tests/error_009_missing_js_module.js.out b/cli/tests/error_009_missing_js_module.js.out
new file mode 100644
index 000000000..edb08da1c
--- /dev/null
+++ b/cli/tests/error_009_missing_js_module.js.out
@@ -0,0 +1 @@
+Cannot resolve module "./bad-module.js" from "[WILDCARD]error_009_missing_js_module.js"
diff --git a/cli/tests/error_010_nonexistent_arg.disabled b/cli/tests/error_010_nonexistent_arg.disabled
new file mode 100644
index 000000000..9d183107c
--- /dev/null
+++ b/cli/tests/error_010_nonexistent_arg.disabled
@@ -0,0 +1,4 @@
+args: not-a-valid-filename.ts
+output: tests/error_010_nonexistent_arg.out
+exit_code: 1
+check_stderr: true
diff --git a/cli/tests/error_010_nonexistent_arg.out b/cli/tests/error_010_nonexistent_arg.out
new file mode 100644
index 000000000..ef4f7b041
--- /dev/null
+++ b/cli/tests/error_010_nonexistent_arg.out
@@ -0,0 +1 @@
+[WILDCARD]Cannot resolve module "file:[WILDCARD]not-a-valid-filename.ts" from "."
diff --git a/cli/tests/error_011_bad_module_specifier.ts b/cli/tests/error_011_bad_module_specifier.ts
new file mode 100644
index 000000000..e74d6b821
--- /dev/null
+++ b/cli/tests/error_011_bad_module_specifier.ts
@@ -0,0 +1,2 @@
+// eslint-disable-next-line
+import * as badModule from "bad-module.ts";
diff --git a/cli/tests/error_011_bad_module_specifier.ts.out b/cli/tests/error_011_bad_module_specifier.ts.out
new file mode 100644
index 000000000..0a90cd32c
--- /dev/null
+++ b/cli/tests/error_011_bad_module_specifier.ts.out
@@ -0,0 +1,5 @@
+[WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "bad-module.ts" not prefixed with / or ./ or ../
+[WILDCARD]dispatch_json.ts:[WILDCARD]
+ at DenoError ([WILDCARD]errors.ts:[WILDCARD])
+ at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
+ at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD])
diff --git a/cli/tests/error_012_bad_dynamic_import_specifier.ts b/cli/tests/error_012_bad_dynamic_import_specifier.ts
new file mode 100644
index 000000000..0420a80bf
--- /dev/null
+++ b/cli/tests/error_012_bad_dynamic_import_specifier.ts
@@ -0,0 +1,4 @@
+(async (): Promise<void> => {
+ // eslint-disable-next-line
+ const badModule = await import("bad-module.ts");
+})();
diff --git a/cli/tests/error_012_bad_dynamic_import_specifier.ts.out b/cli/tests/error_012_bad_dynamic_import_specifier.ts.out
new file mode 100644
index 000000000..0a90cd32c
--- /dev/null
+++ b/cli/tests/error_012_bad_dynamic_import_specifier.ts.out
@@ -0,0 +1,5 @@
+[WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "bad-module.ts" not prefixed with / or ./ or ../
+[WILDCARD]dispatch_json.ts:[WILDCARD]
+ at DenoError ([WILDCARD]errors.ts:[WILDCARD])
+ at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
+ at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD])
diff --git a/cli/tests/error_013_missing_script.out b/cli/tests/error_013_missing_script.out
new file mode 100644
index 000000000..9836c361f
--- /dev/null
+++ b/cli/tests/error_013_missing_script.out
@@ -0,0 +1 @@
+Cannot resolve module "[WILDCARD]missing_file_name"
diff --git a/cli/tests/error_014_catch_dynamic_import_error.js b/cli/tests/error_014_catch_dynamic_import_error.js
new file mode 100644
index 000000000..ad3735fc3
--- /dev/null
+++ b/cli/tests/error_014_catch_dynamic_import_error.js
@@ -0,0 +1,31 @@
+(async () => {
+ try {
+ await import("does not exist");
+ } catch (err) {
+ console.log("Caught direct dynamic import error.");
+ console.log(err);
+ }
+
+ try {
+ await import("./subdir/indirect_import_error.js");
+ } catch (err) {
+ console.log("Caught indirect direct dynamic import error.");
+ console.log(err);
+ }
+
+ try {
+ await import("./subdir/throws.js");
+ } catch (err) {
+ console.log("Caught error thrown by dynamically imported module.");
+ console.log(err);
+ }
+
+ try {
+ await import("./subdir/indirect_throws.js");
+ } catch (err) {
+ console.log(
+ "Caught error thrown indirectly by dynamically imported module."
+ );
+ console.log(err);
+ }
+})();
diff --git a/cli/tests/error_014_catch_dynamic_import_error.js.out b/cli/tests/error_014_catch_dynamic_import_error.js.out
new file mode 100644
index 000000000..c18b680a1
--- /dev/null
+++ b/cli/tests/error_014_catch_dynamic_import_error.js.out
@@ -0,0 +1,12 @@
+Caught direct dynamic import error.
+TypeError: relative import path "does not exist" not prefixed with / or ./ or ../
+
+Caught indirect direct dynamic import error.
+TypeError: relative import path "does not exist either" not prefixed with / or ./ or ../
+
+Caught error thrown by dynamically imported module.
+Error: An error
+ at file:///[WILDCARD]tests/subdir/throws.js:5:7
+Caught error thrown indirectly by dynamically imported module.
+Error: An error
+ at file:///[WILDCARD]tests/subdir/throws.js:5:7
diff --git a/cli/tests/error_015_dynamic_import_permissions.js b/cli/tests/error_015_dynamic_import_permissions.js
new file mode 100644
index 000000000..3460ca787
--- /dev/null
+++ b/cli/tests/error_015_dynamic_import_permissions.js
@@ -0,0 +1,3 @@
+(async () => {
+ await import("http://localhost:4545/tests/subdir/mod4.js");
+})();
diff --git a/cli/tests/error_015_dynamic_import_permissions.out b/cli/tests/error_015_dynamic_import_permissions.out
new file mode 100644
index 000000000..90ccd0d1a
--- /dev/null
+++ b/cli/tests/error_015_dynamic_import_permissions.out
@@ -0,0 +1 @@
+error: Uncaught TypeError: permission denied
diff --git a/cli/tests/error_016_dynamic_import_permissions2.js b/cli/tests/error_016_dynamic_import_permissions2.js
new file mode 100644
index 000000000..71c70815c
--- /dev/null
+++ b/cli/tests/error_016_dynamic_import_permissions2.js
@@ -0,0 +1,5 @@
+// If this is executed with --allow-net but not --allow-read the following
+// import should cause a permission denied error.
+(async () => {
+ await import("http://localhost:4545/tests/subdir/evil_remote_import.js");
+})();
diff --git a/cli/tests/error_016_dynamic_import_permissions2.out b/cli/tests/error_016_dynamic_import_permissions2.out
new file mode 100644
index 000000000..f52186481
--- /dev/null
+++ b/cli/tests/error_016_dynamic_import_permissions2.out
@@ -0,0 +1,2 @@
+[WILDCARD]
+error: Uncaught TypeError: permission denied
diff --git a/cli/tests/error_stack.ts b/cli/tests/error_stack.ts
new file mode 100644
index 000000000..f2125d662
--- /dev/null
+++ b/cli/tests/error_stack.ts
@@ -0,0 +1,10 @@
+function foo(): never {
+ throw new Error("foo");
+}
+
+try {
+ foo();
+} catch (e) {
+ console.log(e);
+ throw e;
+}
diff --git a/cli/tests/error_stack.ts.out b/cli/tests/error_stack.ts.out
new file mode 100644
index 000000000..2bb629e2d
--- /dev/null
+++ b/cli/tests/error_stack.ts.out
@@ -0,0 +1,6 @@
+[WILDCARD]Error: foo
+ at foo ([WILDCARD]tests/error_stack.ts:2:9)
+ at [WILDCARD]tests/error_stack.ts:6:3
+error: Uncaught Error: foo
+ at foo ([WILDCARD]tests/error_stack.ts:2:9)
+ at [WILDCARD]tests/error_stack.ts:6:3
diff --git a/cli/tests/error_syntax.js b/cli/tests/error_syntax.js
new file mode 100644
index 000000000..0c0c09855
--- /dev/null
+++ b/cli/tests/error_syntax.js
@@ -0,0 +1,3 @@
+
+// prettier-ignore
+(the following is a syntax error ^^ ! )
diff --git a/cli/tests/error_syntax.js.out b/cli/tests/error_syntax.js.out
new file mode 100644
index 000000000..6253f3dd5
--- /dev/null
+++ b/cli/tests/error_syntax.js.out
@@ -0,0 +1,6 @@
+error: Uncaught SyntaxError: Unexpected identifier
+[WILDCARD]tests/error_syntax.js:3:6
+
+3 (the following is a syntax error ^^ ! )
+ ~~~~~~~~~
+
diff --git a/cli/tests/error_type_definitions.ts b/cli/tests/error_type_definitions.ts
new file mode 100644
index 000000000..ceb11787e
--- /dev/null
+++ b/cli/tests/error_type_definitions.ts
@@ -0,0 +1,5 @@
+// @deno-types="./type_definitions/bar.d.ts"
+import { Bar } from "./type_definitions/bar.js";
+
+const bar = new Bar();
+console.log(bar);
diff --git a/cli/tests/error_type_definitions.ts.out b/cli/tests/error_type_definitions.ts.out
new file mode 100644
index 000000000..d0b599862
--- /dev/null
+++ b/cli/tests/error_type_definitions.ts.out
@@ -0,0 +1,5 @@
+[WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "baz" not prefixed with / or ./ or ../
+[WILDCARD]dispatch_json.ts:[WILDCARD]
+ at DenoError ([WILDCARD]errors.ts:[WILDCARD])
+ at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
+ at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD])
diff --git a/cli/tests/error_worker_dynamic.ts b/cli/tests/error_worker_dynamic.ts
new file mode 100644
index 000000000..16fadf573
--- /dev/null
+++ b/cli/tests/error_worker_dynamic.ts
@@ -0,0 +1,3 @@
+const b = new Blob(['throw new Error("hello");']);
+const blobURL = URL.createObjectURL(b);
+new Worker(blobURL);
diff --git a/cli/tests/error_worker_dynamic.ts.out b/cli/tests/error_worker_dynamic.ts.out
new file mode 100644
index 000000000..4bea7b656
--- /dev/null
+++ b/cli/tests/error_worker_dynamic.ts.out
@@ -0,0 +1,3 @@
+[WILDCARD]error: Uncaught Error: hello
+[WILDCARD]__anonymous__:1:7
+ at [WILDCARD]__anonymous__:1:7
diff --git a/cli/tests/esm_imports_a.js b/cli/tests/esm_imports_a.js
new file mode 100644
index 000000000..673cd9aa3
--- /dev/null
+++ b/cli/tests/esm_imports_a.js
@@ -0,0 +1,3 @@
+import { retb } from "./esm_imports_b.js";
+
+if (retb() != "b") throw Error();
diff --git a/cli/tests/esm_imports_b.js b/cli/tests/esm_imports_b.js
new file mode 100644
index 000000000..321dfc05a
--- /dev/null
+++ b/cli/tests/esm_imports_b.js
@@ -0,0 +1,3 @@
+export function retb() {
+ return "b";
+}
diff --git a/cli/tests/exec_path.ts b/cli/tests/exec_path.ts
new file mode 100644
index 000000000..b70b23237
--- /dev/null
+++ b/cli/tests/exec_path.ts
@@ -0,0 +1 @@
+console.log(Deno.execPath());
diff --git a/cli/tests/exit_error42.ts b/cli/tests/exit_error42.ts
new file mode 100644
index 000000000..e4db41f3a
--- /dev/null
+++ b/cli/tests/exit_error42.ts
@@ -0,0 +1,3 @@
+console.log("before");
+Deno.exit(42);
+console.log("after");
diff --git a/cli/tests/exit_error42.ts.out b/cli/tests/exit_error42.ts.out
new file mode 100644
index 000000000..90be1f305
--- /dev/null
+++ b/cli/tests/exit_error42.ts.out
@@ -0,0 +1 @@
+before
diff --git a/cli/tests/fetch_deps.ts b/cli/tests/fetch_deps.ts
new file mode 100644
index 000000000..e6ef8854e
--- /dev/null
+++ b/cli/tests/fetch_deps.ts
@@ -0,0 +1,14 @@
+// Run ./tools/http_server.py too in order for this test to run.
+import { assert } from "../std/testing/asserts.ts";
+
+// TODO Top level await https://github.com/denoland/deno/issues/471
+async function main(): Promise<void> {
+ const response = await fetch("http://localhost:4545/package.json");
+ const json = await response.json();
+ const deps = Object.keys(json.devDependencies);
+ console.log("Deno JS Deps");
+ console.log(deps.map((d): string => `* ${d}`).join("\n"));
+ assert(deps.includes("typescript"));
+}
+
+main();
diff --git a/cli/tests/hello.txt b/cli/tests/hello.txt
new file mode 100644
index 000000000..6769dd60b
--- /dev/null
+++ b/cli/tests/hello.txt
@@ -0,0 +1 @@
+Hello world! \ No newline at end of file
diff --git a/cli/tests/https_import.ts b/cli/tests/https_import.ts
new file mode 100644
index 000000000..faaf2175f
--- /dev/null
+++ b/cli/tests/https_import.ts
@@ -0,0 +1,5 @@
+// TODO Use https://localhost:4555/ but we need more infrastructure to
+// support verifying self-signed certificates.
+import { printHello } from "https://gist.githubusercontent.com/ry/f12b2aa3409e6b52645bc346a9e22929/raw/79318f239f51d764384a8bded8d7c6a833610dde/print_hello.ts";
+
+printHello();
diff --git a/cli/tests/https_import.ts.out b/cli/tests/https_import.ts.out
new file mode 100644
index 000000000..e965047ad
--- /dev/null
+++ b/cli/tests/https_import.ts.out
@@ -0,0 +1 @@
+Hello
diff --git a/cli/tests/if_main.ts b/cli/tests/if_main.ts
new file mode 100644
index 000000000..b47066b2d
--- /dev/null
+++ b/cli/tests/if_main.ts
@@ -0,0 +1,7 @@
+if (window.location.toString() == import.meta.url) {
+ console.log("main");
+} else {
+ console.log("import.meta.url", import.meta.url);
+ console.log("window.location", window.location.toString());
+ throw Error("not main");
+}
diff --git a/cli/tests/if_main.ts.out b/cli/tests/if_main.ts.out
new file mode 100644
index 000000000..ba2906d06
--- /dev/null
+++ b/cli/tests/if_main.ts.out
@@ -0,0 +1 @@
+main
diff --git a/cli/tests/import_meta.ts b/cli/tests/import_meta.ts
new file mode 100644
index 000000000..d111059ea
--- /dev/null
+++ b/cli/tests/import_meta.ts
@@ -0,0 +1,3 @@
+console.log("import_meta", import.meta.url, import.meta.main);
+
+import "./import_meta2.ts";
diff --git a/cli/tests/import_meta.ts.out b/cli/tests/import_meta.ts.out
new file mode 100644
index 000000000..f38aa98ea
--- /dev/null
+++ b/cli/tests/import_meta.ts.out
@@ -0,0 +1,2 @@
+import_meta2 [WILDCARD]import_meta2.ts false
+import_meta [WILDCARD]import_meta.ts true
diff --git a/cli/tests/import_meta2.ts b/cli/tests/import_meta2.ts
new file mode 100644
index 000000000..7f59a5a46
--- /dev/null
+++ b/cli/tests/import_meta2.ts
@@ -0,0 +1 @@
+console.log("import_meta2", import.meta.url, import.meta.main);
diff --git a/cli/tests/importmaps/import_map.json b/cli/tests/importmaps/import_map.json
new file mode 100644
index 000000000..601874aab
--- /dev/null
+++ b/cli/tests/importmaps/import_map.json
@@ -0,0 +1,14 @@
+{
+ "imports": {
+ "moment": "./moment/moment.ts",
+ "moment/": "./moment/",
+ "lodash": "./lodash/lodash.ts",
+ "lodash/": "./lodash/",
+ "https://www.unpkg.com/vue/dist/vue.runtime.esm.js": "./vue.ts"
+ },
+ "scopes": {
+ "scope/": {
+ "moment": "./scoped_moment.ts"
+ }
+ }
+}
diff --git a/cli/tests/importmaps/lodash/lodash.ts b/cli/tests/importmaps/lodash/lodash.ts
new file mode 100644
index 000000000..2ec04ed3c
--- /dev/null
+++ b/cli/tests/importmaps/lodash/lodash.ts
@@ -0,0 +1 @@
+console.log("Hello from remapped lodash!");
diff --git a/cli/tests/importmaps/lodash/other_file.ts b/cli/tests/importmaps/lodash/other_file.ts
new file mode 100644
index 000000000..714adae3f
--- /dev/null
+++ b/cli/tests/importmaps/lodash/other_file.ts
@@ -0,0 +1 @@
+console.log("Hello from remapped lodash dir!");
diff --git a/cli/tests/importmaps/moment/moment.ts b/cli/tests/importmaps/moment/moment.ts
new file mode 100644
index 000000000..2b54a431e
--- /dev/null
+++ b/cli/tests/importmaps/moment/moment.ts
@@ -0,0 +1 @@
+console.log("Hello from remapped moment!");
diff --git a/cli/tests/importmaps/moment/other_file.ts b/cli/tests/importmaps/moment/other_file.ts
new file mode 100644
index 000000000..24f3a0226
--- /dev/null
+++ b/cli/tests/importmaps/moment/other_file.ts
@@ -0,0 +1 @@
+console.log("Hello from remapped moment dir!");
diff --git a/cli/tests/importmaps/scope/scoped.ts b/cli/tests/importmaps/scope/scoped.ts
new file mode 100644
index 000000000..9a0b5d8e3
--- /dev/null
+++ b/cli/tests/importmaps/scope/scoped.ts
@@ -0,0 +1,2 @@
+import "moment";
+console.log("Hello from scoped!");
diff --git a/cli/tests/importmaps/scoped_moment.ts b/cli/tests/importmaps/scoped_moment.ts
new file mode 100644
index 000000000..9f67f88d4
--- /dev/null
+++ b/cli/tests/importmaps/scoped_moment.ts
@@ -0,0 +1 @@
+console.log("Hello from scoped moment!");
diff --git a/cli/tests/importmaps/test.ts b/cli/tests/importmaps/test.ts
new file mode 100644
index 000000000..9b09e9953
--- /dev/null
+++ b/cli/tests/importmaps/test.ts
@@ -0,0 +1,6 @@
+import "moment";
+import "moment/other_file.ts";
+import "lodash";
+import "lodash/other_file.ts";
+import "https://www.unpkg.com/vue/dist/vue.runtime.esm.js";
+import "./scope/scoped.ts";
diff --git a/cli/tests/importmaps/vue.ts b/cli/tests/importmaps/vue.ts
new file mode 100644
index 000000000..76dbe1917
--- /dev/null
+++ b/cli/tests/importmaps/vue.ts
@@ -0,0 +1 @@
+console.log("Hello from remapped Vue!");
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
new file mode 100644
index 000000000..4271036d1
--- /dev/null
+++ b/cli/tests/integration_tests.rs
@@ -0,0 +1,578 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+#[macro_use]
+extern crate lazy_static;
+extern crate tempfile;
+mod util;
+use util::*;
+
+#[test]
+fn benchmark_test() {
+ run_python_script("tools/benchmark_test.py")
+}
+
+#[test]
+fn deno_dir_test() {
+ let g = http_server();
+ run_python_script("tools/deno_dir_test.py");
+ drop(g);
+}
+
+// TODO(#2933): Rewrite this test in rust.
+#[test]
+fn fetch_test() {
+ let g = http_server();
+ run_python_script("tools/fetch_test.py");
+ drop(g);
+}
+
+// TODO(#2933): Rewrite this test in rust.
+#[test]
+fn fmt_test() {
+ let g = http_server();
+ run_python_script("tools/fmt_test.py");
+ drop(g);
+}
+
+#[test]
+fn js_unit_tests() {
+ let g = http_server();
+ let mut deno = deno_cmd()
+ .current_dir(root_path())
+ .arg("run")
+ .arg("--reload")
+ .arg("--allow-run")
+ .arg("--allow-env")
+ .arg("cli/js/unit_test_runner.ts")
+ .spawn()
+ .expect("failed to spawn script");
+ let status = deno.wait().expect("failed to wait for the child process");
+ assert_eq!(Some(0), status.code());
+ assert!(status.success());
+ drop(g);
+}
+
+// TODO(#2933): Rewrite this test in rust.
+#[test]
+fn repl_test() {
+ run_python_script("tools/repl_test.py")
+}
+
+#[test]
+fn setup_test() {
+ run_python_script("tools/setup_test.py")
+}
+
+#[test]
+fn target_test() {
+ run_python_script("tools/target_test.py")
+}
+
+#[test]
+fn util_test() {
+ run_python_script("tools/util_test.py")
+}
+
+macro_rules! itest(
+ ($name:ident {$( $key:ident: $value:expr,)*}) => {
+ #[test]
+ fn $name() {
+ (CheckOutputIntegrationTest {
+ $(
+ $key: $value,
+ )*
+ .. Default::default()
+ }).run()
+ }
+ }
+);
+
+itest!(_001_hello {
+ args: "run --reload 001_hello.js",
+ output: "001_hello.js.out",
+});
+
+itest!(_002_hello {
+ args: "run --reload 002_hello.ts",
+ output: "002_hello.ts.out",
+});
+
+itest!(_003_relative_import {
+ args: "run --reload 003_relative_import.ts",
+ output: "003_relative_import.ts.out",
+});
+
+itest!(_004_set_timeout {
+ args: "run --reload 004_set_timeout.ts",
+ output: "004_set_timeout.ts.out",
+});
+
+itest!(_005_more_imports {
+ args: "run --reload 005_more_imports.ts",
+ output: "005_more_imports.ts.out",
+});
+
+itest!(_006_url_imports {
+ args: "run --reload 006_url_imports.ts",
+ output: "006_url_imports.ts.out",
+ http_server: true,
+});
+
+itest!(_012_async {
+ args: "run --reload 012_async.ts",
+ output: "012_async.ts.out",
+});
+
+itest!(_013_dynamic_import {
+ args: "013_dynamic_import.ts --reload --allow-read",
+ output: "013_dynamic_import.ts.out",
+});
+
+itest!(_014_duplicate_import {
+ args: "014_duplicate_import.ts --reload --allow-read",
+ output: "014_duplicate_import.ts.out",
+});
+
+itest!(_015_duplicate_parallel_import {
+ args: "015_duplicate_parallel_import.js --reload --allow-read",
+ output: "015_duplicate_parallel_import.js.out",
+});
+
+itest!(_016_double_await {
+ args: "run --allow-read --reload 016_double_await.ts",
+ output: "016_double_await.ts.out",
+});
+
+itest!(_017_import_redirect {
+ args: "run --reload 017_import_redirect.ts",
+ output: "017_import_redirect.ts.out",
+});
+
+itest!(_018_async_catch {
+ args: "run --reload 018_async_catch.ts",
+ output: "018_async_catch.ts.out",
+});
+
+itest!(_019_media_types {
+ args: "run --reload 019_media_types.ts",
+ output: "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",
+});
+
+itest!(_021_mjs_modules {
+ args: "run --reload 021_mjs_modules.ts",
+ output: "021_mjs_modules.ts.out",
+});
+
+itest!(_022_info_flag_script {
+ args: "info http://127.0.0.1:4545/cli/tests/019_media_types.ts",
+ output: "022_info_flag_script.out",
+ http_server: true,
+});
+
+itest!(_023_no_ext_with_headers {
+ args: "run --reload 023_no_ext_with_headers",
+ output: "023_no_ext_with_headers.out",
+});
+
+// FIXME(bartlomieju): this test should use remote file
+// itest!(_024_import_no_ext_with_headers {
+// args: "run --reload 024_import_no_ext_with_headers.ts",
+// output: "024_import_no_ext_with_headers.ts.out",
+// });
+
+itest!(_025_hrtime {
+ args: "run --allow-hrtime --reload 025_hrtime.ts",
+ output: "025_hrtime.ts.out",
+});
+
+itest!(_025_reload_js_type_error {
+ args: "run --reload 025_reload_js_type_error.js",
+ output: "025_reload_js_type_error.js.out",
+});
+
+itest!(_026_redirect_javascript {
+ args: "run --reload 026_redirect_javascript.js",
+ output: "026_redirect_javascript.js.out",
+ http_server: true,
+});
+
+itest!(_026_workers {
+ args: "run --reload 026_workers.ts",
+ output: "026_workers.ts.out",
+});
+
+itest!(_027_redirect_typescript {
+ args: "run --reload 027_redirect_typescript.ts",
+ output: "027_redirect_typescript.ts.out",
+ http_server: true,
+});
+
+itest!(_028_args {
+ args: "run --reload 028_args.ts --arg1 val1 --arg2=val2 -- arg3 arg4",
+ output: "028_args.ts.out",
+});
+
+itest!(_029_eval {
+ args: "eval console.log(\"hello\")",
+ output: "029_eval.out",
+});
+
+itest!(_030_xeval {
+ args: "xeval console.log($.toUpperCase())",
+ input: Some("a\nb\n\nc"),
+ output: "030_xeval.out",
+});
+
+itest!(_031_xeval_replvar {
+ args: "xeval -I val console.log(val.toUpperCase());",
+ input: Some("a\nb\n\nc"),
+ output: "031_xeval_replvar.out",
+});
+
+itest!(_032_xeval_delim {
+ args: "xeval -d DELIM console.log($.toUpperCase());",
+ input: Some("aDELIMbDELIMDELIMc"),
+ output: "032_xeval_delim.out",
+});
+
+itest!(_033_import_map {
+ args:
+ "run --reload --importmap=importmaps/import_map.json importmaps/test.ts",
+ output: "033_import_map.out",
+});
+
+itest!(_034_onload {
+ args: "run --reload 034_onload/main.ts",
+ output: "034_onload.out",
+});
+
+itest!(_035_no_fetch_flag {
+ args:
+ "--reload --no-fetch http://127.0.0.1:4545/cli/tests/019_media_types.ts",
+ output: "035_no_fetch_flag.out",
+ exit_code: 1,
+ check_stderr: true,
+ http_server: true,
+});
+
+itest!(_036_import_map_fetch {
+ args:
+ "fetch --reload --importmap=importmaps/import_map.json importmaps/test.ts",
+ output: "036_import_map_fetch.out",
+});
+
+itest!(_037_current_thread {
+ args: "run --current-thread --reload 034_onload/main.ts",
+ output: "034_onload.out",
+});
+
+itest!(_038_checkjs {
+ // checking if JS file is run through TS compiler
+ args: "run --reload --config 038_checkjs.tsconfig.json 038_checkjs.js",
+ check_stderr: true,
+ exit_code: 1,
+ output: "038_checkjs.js.out",
+});
+
+itest!(_039_worker_deno_ns {
+ args: "run --reload 039_worker_deno_ns.ts",
+ output: "039_worker_deno_ns.ts.out",
+});
+
+itest!(_040_worker_blob {
+ args: "run --reload 040_worker_blob.ts",
+ output: "040_worker_blob.ts.out",
+});
+
+itest!(_041_dyn_import_eval {
+ args: "eval import('./subdir/mod4.js').then(console.log)",
+ output: "041_dyn_import_eval.out",
+});
+
+itest!(_041_info_flag {
+ args: "info",
+ output: "041_info_flag.out",
+});
+
+itest!(_042_dyn_import_evalcontext {
+ args: "run --allow-read --reload 042_dyn_import_evalcontext.ts",
+ output: "042_dyn_import_evalcontext.ts.out",
+});
+
+itest!(_044_bad_resource {
+ args: "run --reload --allow-read 044_bad_resource.ts",
+ output: "044_bad_resource.ts.out",
+ check_stderr: true,
+ exit_code: 1,
+});
+
+itest!(_045_proxy {
+ args: "run --allow-net --allow-env --allow-run --reload 045_proxy_test.ts",
+ output: "045_proxy_test.ts.out",
+});
+
+itest!(_046_tsx {
+ args: "run --reload 046_jsx_test.tsx",
+ output: "046_jsx_test.tsx.out",
+});
+
+itest!(_047_jsx {
+ args: "run --reload 047_jsx_test.jsx",
+ output: "047_jsx_test.jsx.out",
+});
+
+itest!(async_error {
+ exit_code: 1,
+ args: "run --reload async_error.ts",
+ check_stderr: true,
+ output: "async_error.ts.out",
+});
+
+itest!(circular1 {
+ args: "run --reload circular1.js",
+ output: "circular1.js.out",
+});
+
+itest!(config {
+ args: "run --reload --config config.tsconfig.json config.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "config.ts.out",
+});
+
+itest!(error_001 {
+ args: "run --reload error_001.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_001.ts.out",
+});
+
+itest!(error_002 {
+ args: "run --reload error_002.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_002.ts.out",
+});
+
+itest!(error_003_typescript {
+ args: "run --reload error_003_typescript.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_003_typescript.ts.out",
+});
+
+// Supposing that we've already attempted to run error_003_typescript.ts
+// we want to make sure that JS wasn't emitted. Running again without reload flag
+// should result in the same output.
+// https://github.com/denoland/deno/issues/2436
+itest!(error_003_typescript2 {
+ args: "run error_003_typescript.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_003_typescript.ts.out",
+});
+
+itest!(error_004_missing_module {
+ args: "run --reload error_004_missing_module.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_004_missing_module.ts.out",
+});
+
+itest!(error_005_missing_dynamic_import {
+ args: "run --reload error_005_missing_dynamic_import.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_005_missing_dynamic_import.ts.out",
+});
+
+itest!(error_006_import_ext_failure {
+ args: "run --reload error_006_import_ext_failure.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_006_import_ext_failure.ts.out",
+});
+
+itest!(error_007_any {
+ args: "run --reload error_007_any.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_007_any.ts.out",
+});
+
+itest!(error_008_checkjs {
+ args: "run --reload error_008_checkjs.js",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_008_checkjs.js.out",
+});
+
+itest!(error_011_bad_module_specifier {
+ args: "run --reload error_011_bad_module_specifier.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_011_bad_module_specifier.ts.out",
+});
+
+itest!(error_012_bad_dynamic_import_specifier {
+ args: "run --reload error_012_bad_dynamic_import_specifier.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_012_bad_dynamic_import_specifier.ts.out",
+});
+
+itest!(error_013_missing_script {
+ args: "run --reload missing_file_name",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_013_missing_script.out",
+});
+
+itest!(error_014_catch_dynamic_import_error {
+ args: "error_014_catch_dynamic_import_error.js --reload --allow-read",
+ output: "error_014_catch_dynamic_import_error.js.out",
+ exit_code: 1,
+});
+
+itest!(error_015_dynamic_import_permissions {
+ args: "--reload --no-prompt error_015_dynamic_import_permissions.js",
+ output: "error_015_dynamic_import_permissions.out",
+ check_stderr: true,
+ 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:
+ "--no-prompt --reload --allow-net error_016_dynamic_import_permissions2.js",
+ output: "error_016_dynamic_import_permissions2.out",
+ check_stderr: true,
+ exit_code: 1,
+ http_server: true,
+});
+
+itest!(error_stack {
+ args: "run --reload error_stack.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_stack.ts.out",
+});
+
+itest!(error_syntax {
+ args: "run --reload error_syntax.js",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_syntax.js.out",
+});
+
+itest!(error_type_definitions {
+ args: "run --reload error_type_definitions.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_type_definitions.ts.out",
+});
+
+itest!(error_worker_dynamic {
+ args: "run --reload error_worker_dynamic.ts",
+ check_stderr: true,
+ exit_code: 1,
+ output: "error_worker_dynamic.ts.out",
+});
+
+itest!(exit_error42 {
+ exit_code: 42,
+ args: "run --reload exit_error42.ts",
+ output: "exit_error42.ts.out",
+});
+
+itest!(https_import {
+ args: "run --reload https_import.ts",
+ output: "https_import.ts.out",
+});
+
+itest!(if_main {
+ args: "run --reload if_main.ts",
+ output: "if_main.ts.out",
+});
+
+itest!(import_meta {
+ args: "run --reload import_meta.ts",
+ output: "import_meta.ts.out",
+});
+
+itest!(seed_random {
+ args: "run --seed=100 seed_random.js",
+ output: "seed_random.js.out",
+});
+
+itest!(type_definitions {
+ args: "run --reload type_definitions.ts",
+ output: "type_definitions.ts.out",
+});
+
+itest!(types {
+ args: "types",
+ output: "types.out",
+});
+
+itest!(unbuffered_stderr {
+ args: "run --reload unbuffered_stderr.ts",
+ check_stderr: true,
+ output: "unbuffered_stderr.ts.out",
+});
+
+itest!(unbuffered_stdout {
+ args: "run --reload unbuffered_stdout.ts",
+ output: "unbuffered_stdout.ts.out",
+});
+
+itest!(v8_flags {
+ args: "run --v8-flags=--expose-gc v8_flags.js",
+ output: "v8_flags.js.out",
+});
+
+itest!(v8_help {
+ args: "--v8-options",
+ output: "v8_help.out",
+});
+
+itest!(version {
+ args: "version",
+ output: "version.out",
+});
+
+itest!(version_long_flag {
+ args: "--version",
+ output: "version.out",
+});
+
+itest!(version_short_flag {
+ args: "-v",
+ output: "version.out",
+});
+
+itest!(wasm {
+ args: "run wasm.ts",
+ output: "wasm.ts.out",
+});
+
+itest!(wasm_async {
+ args: "wasm_async.js",
+ output: "wasm_async.out",
+});
+
+itest!(top_level_await {
+ args: "--allow-read top_level_await.js",
+ output: "top_level_await.out",
+});
+
+itest!(top_level_await_ts {
+ args: "--allow-read top_level_await.ts",
+ output: "top_level_await.out",
+});
diff --git a/cli/tests/is_tty.ts b/cli/tests/is_tty.ts
new file mode 100644
index 000000000..2e3fdb49f
--- /dev/null
+++ b/cli/tests/is_tty.ts
@@ -0,0 +1 @@
+console.log(Deno.isTTY().stdin);
diff --git a/cli/tests/no_color.js b/cli/tests/no_color.js
new file mode 100644
index 000000000..cea11a52f
--- /dev/null
+++ b/cli/tests/no_color.js
@@ -0,0 +1 @@
+console.log("noColor", Deno.noColor);
diff --git a/cli/tests/seed_random.js b/cli/tests/seed_random.js
new file mode 100644
index 000000000..7f6e336df
--- /dev/null
+++ b/cli/tests/seed_random.js
@@ -0,0 +1,11 @@
+for (let i = 0; i < 10; ++i) {
+ console.log(Math.random());
+}
+
+const arr = new Uint8Array(32);
+
+crypto.getRandomValues(arr);
+console.log(arr);
+
+crypto.getRandomValues(arr);
+console.log(arr);
diff --git a/cli/tests/seed_random.js.out b/cli/tests/seed_random.js.out
new file mode 100644
index 000000000..c65e40f97
--- /dev/null
+++ b/cli/tests/seed_random.js.out
@@ -0,0 +1,12 @@
+0.858562739044346
+0.8973397944553141
+0.15335012655691727
+0.36867387434349963
+0.3591039342838782
+0.7044499748617652
+0.7461423057751548
+0.3824611207183364
+0.5950178237266042
+0.22440633214343908
+Uint8Array [ 116, 125, 169, 69, 106, 231, 99, 39, 148, 188, 211, 41, 46, 211, 236, 141, 55, 10, 214, 63, 118, 230, 218, 249, 125, 161, 137, 110, 214, 36, 159, 154 ]
+Uint8Array [ 248, 21, 21, 9, 41, 0, 71, 124, 244, 209, 252, 151, 7, 10, 168, 250, 84, 170, 243, 140, 53, 47, 99, 212, 18, 146, 68, 48, 66, 222, 67, 112 ]
diff --git a/cli/tests/subdir/auto_print_hello.ts b/cli/tests/subdir/auto_print_hello.ts
new file mode 100644
index 000000000..5efa72e03
--- /dev/null
+++ b/cli/tests/subdir/auto_print_hello.ts
@@ -0,0 +1,2 @@
+console.log("hello!");
+export default {};
diff --git a/cli/tests/subdir/bench_worker.ts b/cli/tests/subdir/bench_worker.ts
new file mode 100644
index 000000000..094cefb80
--- /dev/null
+++ b/cli/tests/subdir/bench_worker.ts
@@ -0,0 +1,20 @@
+onmessage = function(e): void {
+ const { cmdId, action, data } = e.data;
+ switch (action) {
+ case 0: // Static response
+ postMessage({
+ cmdId,
+ data: "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n"
+ });
+ break;
+ case 1: // Respond with request data
+ postMessage({ cmdId, data });
+ break;
+ case 2: // Ping
+ postMessage({ cmdId });
+ break;
+ case 3: // Close
+ workerClose();
+ break;
+ }
+};
diff --git a/cli/tests/subdir/config.json b/cli/tests/subdir/config.json
new file mode 100644
index 000000000..01c3b5e79
--- /dev/null
+++ b/cli/tests/subdir/config.json
@@ -0,0 +1,6 @@
+{
+ "foo": {
+ "bar": true,
+ "baz": ["qat", 1]
+ }
+}
diff --git a/cli/tests/subdir/evil_remote_import.js b/cli/tests/subdir/evil_remote_import.js
new file mode 100644
index 000000000..4ff7d1b97
--- /dev/null
+++ b/cli/tests/subdir/evil_remote_import.js
@@ -0,0 +1,4 @@
+// We expect to get a permission denied error if we dynamically
+// import this module without --allow-read.
+export * from "file:///c:/etc/passwd";
+console.log("Hello from evil_remote_import.js");
diff --git a/cli/tests/subdir/form_urlencoded.txt b/cli/tests/subdir/form_urlencoded.txt
new file mode 100644
index 000000000..70e087c20
--- /dev/null
+++ b/cli/tests/subdir/form_urlencoded.txt
@@ -0,0 +1 @@
+field_1=Hi&field_2=%3CDeno%3E \ No newline at end of file
diff --git a/cli/tests/subdir/indirect_import_error.js b/cli/tests/subdir/indirect_import_error.js
new file mode 100644
index 000000000..84011d291
--- /dev/null
+++ b/cli/tests/subdir/indirect_import_error.js
@@ -0,0 +1 @@
+export * from "does not exist either";
diff --git a/cli/tests/subdir/indirect_throws.js b/cli/tests/subdir/indirect_throws.js
new file mode 100644
index 000000000..e1810a66c
--- /dev/null
+++ b/cli/tests/subdir/indirect_throws.js
@@ -0,0 +1 @@
+export * from "./throws.js";
diff --git a/cli/tests/subdir/mismatch_ext.ts b/cli/tests/subdir/mismatch_ext.ts
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mismatch_ext.ts
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mod1.ts b/cli/tests/subdir/mod1.ts
new file mode 100644
index 000000000..393535588
--- /dev/null
+++ b/cli/tests/subdir/mod1.ts
@@ -0,0 +1,17 @@
+import { returnsFoo, printHello2 } from "./subdir2/mod2.ts";
+
+export function returnsHi(): string {
+ return "Hi";
+}
+
+export function returnsFoo2(): string {
+ return returnsFoo();
+}
+
+export function printHello3(): void {
+ printHello2();
+}
+
+export function throwsError(): void {
+ throw Error("exception from mod1");
+}
diff --git a/cli/tests/subdir/mod2.ts b/cli/tests/subdir/mod2.ts
new file mode 100644
index 000000000..ce1adc0e8
--- /dev/null
+++ b/cli/tests/subdir/mod2.ts
@@ -0,0 +1 @@
+export { printHello } from "./print_hello.ts";
diff --git a/cli/tests/subdir/mod3.js b/cli/tests/subdir/mod3.js
new file mode 100644
index 000000000..ce534f570
--- /dev/null
+++ b/cli/tests/subdir/mod3.js
@@ -0,0 +1 @@
+export const isTSFile = false;
diff --git a/cli/tests/subdir/mod4.js b/cli/tests/subdir/mod4.js
new file mode 100644
index 000000000..71332dbc4
--- /dev/null
+++ b/cli/tests/subdir/mod4.js
@@ -0,0 +1 @@
+export const isMod4 = true;
diff --git a/cli/tests/subdir/mod5.mjs b/cli/tests/subdir/mod5.mjs
new file mode 100644
index 000000000..f21d8862b
--- /dev/null
+++ b/cli/tests/subdir/mod5.mjs
@@ -0,0 +1 @@
+export const isMod5 = true;
diff --git a/cli/tests/subdir/mt_application_ecmascript.j2.js b/cli/tests/subdir/mt_application_ecmascript.j2.js
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_application_ecmascript.j2.js
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_application_x_javascript.j4.js b/cli/tests/subdir/mt_application_x_javascript.j4.js
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_application_x_javascript.j4.js
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_application_x_typescript.t4.ts b/cli/tests/subdir/mt_application_x_typescript.t4.ts
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_application_x_typescript.t4.ts
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_javascript.js b/cli/tests/subdir/mt_javascript.js
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_javascript.js
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_text_ecmascript.j3.js b/cli/tests/subdir/mt_text_ecmascript.j3.js
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_text_ecmascript.j3.js
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_text_javascript.j1.js b/cli/tests/subdir/mt_text_javascript.j1.js
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_text_javascript.j1.js
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_text_typescript.t1.ts b/cli/tests/subdir/mt_text_typescript.t1.ts
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_text_typescript.t1.ts
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_video_mp2t.t3.ts b/cli/tests/subdir/mt_video_mp2t.t3.ts
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_video_mp2t.t3.ts
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/mt_video_vdn.t2.ts b/cli/tests/subdir/mt_video_vdn.t2.ts
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/mt_video_vdn.t2.ts
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/no_ext b/cli/tests/subdir/no_ext
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/no_ext
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/subdir/print_hello.ts b/cli/tests/subdir/print_hello.ts
new file mode 100644
index 000000000..7ecce5040
--- /dev/null
+++ b/cli/tests/subdir/print_hello.ts
@@ -0,0 +1,3 @@
+export function printHello(): void {
+ console.log("Hello");
+}
diff --git a/cli/tests/subdir/redirects/redirect1.js b/cli/tests/subdir/redirects/redirect1.js
new file mode 100644
index 000000000..d674be88c
--- /dev/null
+++ b/cli/tests/subdir/redirects/redirect1.js
@@ -0,0 +1 @@
+export const redirect = 1;
diff --git a/cli/tests/subdir/redirects/redirect1.ts b/cli/tests/subdir/redirects/redirect1.ts
new file mode 100644
index 000000000..d674be88c
--- /dev/null
+++ b/cli/tests/subdir/redirects/redirect1.ts
@@ -0,0 +1 @@
+export const redirect = 1;
diff --git a/cli/tests/subdir/redirects/redirect2.js b/cli/tests/subdir/redirects/redirect2.js
new file mode 100644
index 000000000..e4244f638
--- /dev/null
+++ b/cli/tests/subdir/redirects/redirect2.js
@@ -0,0 +1 @@
+import "./redirect1.js";
diff --git a/cli/tests/subdir/redirects/redirect3.js b/cli/tests/subdir/redirects/redirect3.js
new file mode 100644
index 000000000..e24f2af32
--- /dev/null
+++ b/cli/tests/subdir/redirects/redirect3.js
@@ -0,0 +1,2 @@
+import { redirect } from "./redirect1.js";
+export const value = `3 imports ${redirect}`;
diff --git a/cli/tests/subdir/redirects/redirect4.ts b/cli/tests/subdir/redirects/redirect4.ts
new file mode 100644
index 000000000..45c65c5eb
--- /dev/null
+++ b/cli/tests/subdir/redirects/redirect4.ts
@@ -0,0 +1,2 @@
+import { redirect } from "./redirect1.ts";
+export const value = `4 imports ${redirect}`;
diff --git a/cli/tests/subdir/subdir2/mod2.ts b/cli/tests/subdir/subdir2/mod2.ts
new file mode 100644
index 000000000..c88d4708c
--- /dev/null
+++ b/cli/tests/subdir/subdir2/mod2.ts
@@ -0,0 +1,9 @@
+import { printHello } from "../print_hello.ts";
+
+export function returnsFoo(): string {
+ return "Foo";
+}
+
+export function printHello2(): void {
+ printHello();
+}
diff --git a/cli/tests/subdir/test_worker.js b/cli/tests/subdir/test_worker.js
new file mode 100644
index 000000000..53d38ba96
--- /dev/null
+++ b/cli/tests/subdir/test_worker.js
@@ -0,0 +1,7 @@
+onmessage = function(e) {
+ console.log(e.data);
+
+ postMessage(e.data);
+
+ workerClose();
+};
diff --git a/cli/tests/subdir/test_worker.ts b/cli/tests/subdir/test_worker.ts
new file mode 100644
index 000000000..c8109d131
--- /dev/null
+++ b/cli/tests/subdir/test_worker.ts
@@ -0,0 +1,7 @@
+onmessage = function(e): void {
+ console.log(e.data);
+
+ postMessage(e.data);
+
+ workerClose();
+};
diff --git a/cli/tests/subdir/throws.js b/cli/tests/subdir/throws.js
new file mode 100644
index 000000000..b77e7104f
--- /dev/null
+++ b/cli/tests/subdir/throws.js
@@ -0,0 +1,5 @@
+export function boo() {
+ console.log("Boo!");
+}
+
+throw new Error("An error");
diff --git a/cli/tests/subdir/unknown_ext.deno b/cli/tests/subdir/unknown_ext.deno
new file mode 100644
index 000000000..e67d2a017
--- /dev/null
+++ b/cli/tests/subdir/unknown_ext.deno
@@ -0,0 +1 @@
+export const loaded = true;
diff --git a/cli/tests/top_level_await.js b/cli/tests/top_level_await.js
new file mode 100644
index 000000000..af6fbd662
--- /dev/null
+++ b/cli/tests/top_level_await.js
@@ -0,0 +1,3 @@
+const buf = await Deno.readFile("hello.txt");
+const n = await Deno.stdout.write(buf);
+console.log(`\n\nwrite ${n}`);
diff --git a/cli/tests/top_level_await.out b/cli/tests/top_level_await.out
new file mode 100644
index 000000000..4b65d15fe
--- /dev/null
+++ b/cli/tests/top_level_await.out
@@ -0,0 +1,3 @@
+Hello world!
+
+write 12
diff --git a/cli/tests/top_level_await.ts b/cli/tests/top_level_await.ts
new file mode 100644
index 000000000..65de253ea
--- /dev/null
+++ b/cli/tests/top_level_await.ts
@@ -0,0 +1,3 @@
+const buf: Uint8Array = await Deno.readFile("hello.txt");
+const n: number = await Deno.stdout.write(buf);
+console.log(`\n\nwrite ${n}`);
diff --git a/cli/tests/tty_tests.rs b/cli/tests/tty_tests.rs
new file mode 100644
index 000000000..413d39caf
--- /dev/null
+++ b/cli/tests/tty_tests.rs
@@ -0,0 +1,18 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+#[macro_use]
+extern crate lazy_static;
+extern crate tempfile;
+mod util;
+use util::*;
+
+// TODO(#2933): Rewrite these tests in rust.
+// TODO(ry) These tests can't run in parallel.
+#[test]
+fn tty_tests() {
+ let g = http_server();
+ run_python_script("tools/complex_permissions_test.py");
+ run_python_script("tools/permission_prompt_test.py");
+ // TODO(ry) is_tty_test is not passing on travis when run with "cargo test"
+ // run_python_script("tools/is_tty_test.py");
+ drop(g);
+}
diff --git a/cli/tests/type_definitions.ts b/cli/tests/type_definitions.ts
new file mode 100644
index 000000000..ecf3ae0b2
--- /dev/null
+++ b/cli/tests/type_definitions.ts
@@ -0,0 +1,10 @@
+// @deno-types="./type_definitions/foo.d.ts"
+import { foo } from "./type_definitions/foo.js";
+// @deno-types="./type_definitions/fizz.d.ts"
+import "./type_definitions/fizz.js";
+
+import * as qat from "./type_definitions/qat.ts";
+
+console.log(foo);
+console.log(fizz);
+console.log(qat.qat);
diff --git a/cli/tests/type_definitions.ts.out b/cli/tests/type_definitions.ts.out
new file mode 100644
index 000000000..b4fa88c50
--- /dev/null
+++ b/cli/tests/type_definitions.ts.out
@@ -0,0 +1,3 @@
+[WILDCARD]foo
+fizz
+qat
diff --git a/cli/tests/type_definitions/bar.d.ts b/cli/tests/type_definitions/bar.d.ts
new file mode 100644
index 000000000..d43335dbb
--- /dev/null
+++ b/cli/tests/type_definitions/bar.d.ts
@@ -0,0 +1,7 @@
+/// <reference types="baz" />
+
+declare namespace bar {
+ export class Bar {
+ baz: string;
+ }
+}
diff --git a/cli/tests/type_definitions/fizz.d.ts b/cli/tests/type_definitions/fizz.d.ts
new file mode 100644
index 000000000..34eb41b96
--- /dev/null
+++ b/cli/tests/type_definitions/fizz.d.ts
@@ -0,0 +1,2 @@
+/** A global value. */
+declare const fizz: string;
diff --git a/cli/tests/type_definitions/fizz.js b/cli/tests/type_definitions/fizz.js
new file mode 100644
index 000000000..852162c94
--- /dev/null
+++ b/cli/tests/type_definitions/fizz.js
@@ -0,0 +1 @@
+globalThis.fizz = "fizz";
diff --git a/cli/tests/type_definitions/foo.d.ts b/cli/tests/type_definitions/foo.d.ts
new file mode 100644
index 000000000..ce39201e1
--- /dev/null
+++ b/cli/tests/type_definitions/foo.d.ts
@@ -0,0 +1,2 @@
+/** An exported value. */
+export const foo: string;
diff --git a/cli/tests/type_definitions/foo.js b/cli/tests/type_definitions/foo.js
new file mode 100644
index 000000000..61d366eb2
--- /dev/null
+++ b/cli/tests/type_definitions/foo.js
@@ -0,0 +1 @@
+export const foo = "foo";
diff --git a/cli/tests/type_definitions/qat.ts b/cli/tests/type_definitions/qat.ts
new file mode 100644
index 000000000..6196c9d38
--- /dev/null
+++ b/cli/tests/type_definitions/qat.ts
@@ -0,0 +1 @@
+export const qat = "qat";
diff --git a/cli/tests/types.out b/cli/tests/types.out
new file mode 100644
index 000000000..6c17b0f90
--- /dev/null
+++ b/cli/tests/types.out
@@ -0,0 +1,14 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+[WILDCARD]
+
+declare namespace Deno {
+[WILDCARD]
+}
+[WILDCARD]
+declare interface Window {
+[WILDCARD]
+ Deno: typeof Deno;
+}
+
+declare const window: Window & typeof globalThis;
+[WILDCARD]
diff --git a/cli/tests/unbuffered_stderr.ts b/cli/tests/unbuffered_stderr.ts
new file mode 100644
index 000000000..f4bceb1fc
--- /dev/null
+++ b/cli/tests/unbuffered_stderr.ts
@@ -0,0 +1,3 @@
+const { stderr } = Deno;
+
+stderr.write(new TextEncoder().encode("x"));
diff --git a/cli/tests/unbuffered_stderr.ts.out b/cli/tests/unbuffered_stderr.ts.out
new file mode 100644
index 000000000..500019738
--- /dev/null
+++ b/cli/tests/unbuffered_stderr.ts.out
@@ -0,0 +1,2 @@
+[WILDCARD]
+x \ No newline at end of file
diff --git a/cli/tests/unbuffered_stdout.ts b/cli/tests/unbuffered_stdout.ts
new file mode 100644
index 000000000..fdb1a0e23
--- /dev/null
+++ b/cli/tests/unbuffered_stdout.ts
@@ -0,0 +1,3 @@
+const { stdout } = Deno;
+
+stdout.write(new TextEncoder().encode("a"));
diff --git a/cli/tests/unbuffered_stdout.ts.out b/cli/tests/unbuffered_stdout.ts.out
new file mode 100644
index 000000000..2e65efe2a
--- /dev/null
+++ b/cli/tests/unbuffered_stdout.ts.out
@@ -0,0 +1 @@
+a \ No newline at end of file
diff --git a/cli/tests/util/mod.rs b/cli/tests/util/mod.rs
new file mode 100644
index 000000000..a91e5367b
--- /dev/null
+++ b/cli/tests/util/mod.rs
@@ -0,0 +1,218 @@
+//! Test utilites shared between integration_tests.rs and tty_tests.rs
+use deno_cli::colors::strip_ansi_codes;
+pub use deno_cli::test_util::*;
+use os_pipe::pipe;
+use std::io::Read;
+use std::io::Write;
+use std::process::Command;
+use std::process::Stdio;
+use tempfile::TempDir;
+
+lazy_static! {
+ static ref DENO_DIR: TempDir = { TempDir::new().expect("tempdir fail") };
+}
+
+#[allow(dead_code)]
+pub fn deno_cmd() -> Command {
+ let mut c = Command::new(deno_exe_path());
+ c.env("DENO_DIR", DENO_DIR.path());
+ c
+}
+
+pub fn run_python_script(script: &str) {
+ let output = Command::new("python")
+ .env("DENO_DIR", DENO_DIR.path())
+ .current_dir(root_path())
+ .arg(script)
+ .arg(format!("--executable={}", deno_exe_path().display()))
+ .env("DENO_BUILD_PATH", target_dir())
+ .output()
+ .expect("failed to spawn script");
+ if !output.status.success() {
+ let stdout = String::from_utf8(output.stdout).unwrap();
+ let stderr = String::from_utf8(output.stderr).unwrap();
+ panic!(
+ "{} executed with failing error code\n{}{}",
+ script, stdout, stderr
+ );
+ }
+}
+
+#[derive(Debug, Default)]
+pub struct CheckOutputIntegrationTest {
+ pub args: &'static str,
+ pub output: &'static str,
+ pub input: Option<&'static str>,
+ pub exit_code: i32,
+ pub check_stderr: bool,
+ pub http_server: bool,
+}
+
+impl CheckOutputIntegrationTest {
+ #[allow(dead_code)]
+ pub fn run(&self) {
+ let args = self.args.split_whitespace();
+ let root = root_path();
+ let deno_exe = deno_exe_path();
+ println!("root path {}", root.display());
+ println!("deno_exe path {}", deno_exe.display());
+
+ let http_server_guard = if self.http_server {
+ Some(http_server())
+ } else {
+ None
+ };
+
+ let (mut reader, writer) = pipe().unwrap();
+ let tests_dir = root.join("cli").join("tests");
+ let mut command = deno_cmd();
+ command.args(args);
+ command.current_dir(&tests_dir);
+ command.stdin(Stdio::piped());
+ command.stderr(Stdio::null());
+
+ if self.check_stderr {
+ let writer_clone = writer.try_clone().unwrap();
+ command.stderr(writer_clone);
+ }
+
+ command.stdout(writer);
+
+ let mut process = command.spawn().expect("failed to execute process");
+
+ if let Some(input) = self.input {
+ let mut p_stdin = process.stdin.take().unwrap();
+ write!(p_stdin, "{}", input).unwrap();
+ }
+
+ // Very important when using pipes: This parent process is still
+ // holding its copies of the write ends, and we have to close them
+ // before we read, otherwise the read end will never report EOF. The
+ // Command object owns the writers now, and dropping it closes them.
+ drop(command);
+
+ let mut actual = String::new();
+ reader.read_to_string(&mut actual).unwrap();
+
+ let status = process.wait().expect("failed to finish process");
+ let exit_code = status.code().unwrap();
+
+ drop(http_server_guard);
+
+ actual = strip_ansi_codes(&actual).to_string();
+
+ if self.exit_code != exit_code {
+ println!("OUTPUT\n{}\nOUTPUT", actual);
+ panic!(
+ "bad exit code, expected: {:?}, actual: {:?}",
+ self.exit_code, exit_code
+ );
+ }
+
+ let output_path = tests_dir.join(self.output);
+ println!("output path {}", output_path.display());
+ let expected =
+ std::fs::read_to_string(output_path).expect("cannot read output");
+
+ if !wildcard_match(&expected, &actual) {
+ println!("OUTPUT\n{}\nOUTPUT", actual);
+ println!("EXPECTED\n{}\nEXPECTED", expected);
+ panic!("pattern match failed");
+ }
+ }
+}
+
+fn wildcard_match(pattern: &str, s: &str) -> bool {
+ pattern_match(pattern, s, "[WILDCARD]")
+}
+
+fn pattern_match(pattern: &str, s: &str, wildcard: &str) -> bool {
+ // Normalize line endings
+ let s = s.replace("\r\n", "\n");
+ let pattern = pattern.replace("\r\n", "\n");
+
+ if pattern == wildcard {
+ return true;
+ }
+
+ let parts = pattern.split(wildcard).collect::<Vec<&str>>();
+ if parts.len() == 1 {
+ return pattern == s;
+ }
+
+ if !s.starts_with(parts[0]) {
+ return false;
+ }
+
+ let mut t = s.split_at(parts[0].len());
+
+ for (i, part) in parts.iter().enumerate() {
+ if i == 0 {
+ continue;
+ }
+ dbg!(part, i);
+ if i == parts.len() - 1 && (*part == "" || *part == "\n") {
+ dbg!("exit 1 true", i);
+ return true;
+ }
+ if let Some(found) = t.1.find(*part) {
+ dbg!("found ", found);
+ t = t.1.split_at(found + part.len());
+ } else {
+ dbg!("exit false ", i);
+ return false;
+ }
+ }
+
+ dbg!("end ", t.1.len());
+ t.1.is_empty()
+}
+
+#[test]
+fn test_wildcard_match() {
+ let fixtures = vec![
+ ("foobarbaz", "foobarbaz", true),
+ ("[WILDCARD]", "foobarbaz", true),
+ ("foobar", "foobarbaz", false),
+ ("foo[WILDCARD]baz", "foobarbaz", true),
+ ("foo[WILDCARD]baz", "foobazbar", false),
+ ("foo[WILDCARD]baz[WILDCARD]qux", "foobarbazqatqux", true),
+ ("foo[WILDCARD]", "foobar", true),
+ ("foo[WILDCARD]baz[WILDCARD]", "foobarbazqat", true),
+ // check with different line endings
+ ("foo[WILDCARD]\nbaz[WILDCARD]\n", "foobar\nbazqat\n", true),
+ (
+ "foo[WILDCARD]\nbaz[WILDCARD]\n",
+ "foobar\r\nbazqat\r\n",
+ true,
+ ),
+ (
+ "foo[WILDCARD]\r\nbaz[WILDCARD]\n",
+ "foobar\nbazqat\r\n",
+ true,
+ ),
+ (
+ "foo[WILDCARD]\r\nbaz[WILDCARD]\r\n",
+ "foobar\nbazqat\n",
+ true,
+ ),
+ (
+ "foo[WILDCARD]\r\nbaz[WILDCARD]\r\n",
+ "foobar\r\nbazqat\r\n",
+ true,
+ ),
+ ];
+
+ // Iterate through the fixture lists, testing each one
+ for (pattern, string, expected) in fixtures {
+ let actual = wildcard_match(pattern, string);
+ dbg!(pattern, string, expected);
+ assert_eq!(actual, expected);
+ }
+}
+
+#[test]
+fn test_pattern_match() {
+ assert!(pattern_match("foo[BAR]baz", "foobarbaz", "[BAR]"));
+ assert!(!pattern_match("foo[BAR]baz", "foobazbar", "[BAR]"));
+}
diff --git a/cli/tests/v8_flags.js b/cli/tests/v8_flags.js
new file mode 100644
index 000000000..f7999c4af
--- /dev/null
+++ b/cli/tests/v8_flags.js
@@ -0,0 +1 @@
+console.log(typeof gc);
diff --git a/cli/tests/v8_flags.js.out b/cli/tests/v8_flags.js.out
new file mode 100644
index 000000000..e2dbde096
--- /dev/null
+++ b/cli/tests/v8_flags.js.out
@@ -0,0 +1 @@
+function
diff --git a/cli/tests/v8_help.out b/cli/tests/v8_help.out
new file mode 100644
index 000000000..3d7aac28d
--- /dev/null
+++ b/cli/tests/v8_help.out
@@ -0,0 +1,3 @@
+[WILDCARD]
+Synopsis:
+[WILDCARD]d8[WILDCARD] \ No newline at end of file
diff --git a/cli/tests/version.out b/cli/tests/version.out
new file mode 100644
index 000000000..de13d769f
--- /dev/null
+++ b/cli/tests/version.out
@@ -0,0 +1,3 @@
+deno:[WILDCARD]
+v8:[WILDCARD]
+typescript:[WILDCARD] \ No newline at end of file
diff --git a/cli/tests/wasm.ts b/cli/tests/wasm.ts
new file mode 100644
index 000000000..26ad7ba28
--- /dev/null
+++ b/cli/tests/wasm.ts
@@ -0,0 +1,15 @@
+// prettier-ignore
+const wasmCode = new Uint8Array([
+ 0, 97, 115, 109, 1, 0, 0, 0, 1, 133, 128, 128, 128, 0, 1, 96, 0, 1, 127,
+ 3, 130, 128, 128, 128, 0, 1, 0, 4, 132, 128, 128, 128, 0, 1, 112, 0, 0,
+ 5, 131, 128, 128, 128, 0, 1, 0, 1, 6, 129, 128, 128, 128, 0, 0, 7, 145,
+ 128, 128, 128, 0, 2, 6, 109, 101, 109, 111, 114, 121, 2, 0, 4, 109, 97,
+ 105, 110, 0, 0, 10, 138, 128, 128, 128, 0, 1, 132, 128, 128, 128, 0, 0,
+ 65, 42, 11
+ ]);
+
+const wasmModule = new WebAssembly.Module(wasmCode);
+
+const wasmInstance = new WebAssembly.Instance(wasmModule);
+
+console.log(wasmInstance.exports.main().toString());
diff --git a/cli/tests/wasm.ts.out b/cli/tests/wasm.ts.out
new file mode 100644
index 000000000..d81cc0710
--- /dev/null
+++ b/cli/tests/wasm.ts.out
@@ -0,0 +1 @@
+42
diff --git a/cli/tests/wasm_async.js b/cli/tests/wasm_async.js
new file mode 100644
index 000000000..98a178aad
--- /dev/null
+++ b/cli/tests/wasm_async.js
@@ -0,0 +1,27 @@
+// The following blob can be created by taking the following s-expr and pass
+// it through wat2wasm.
+// (module
+// (func $add (param $a i32) (param $b i32) (result i32)
+// local.get $a
+// local.get $b
+// i32.add)
+// (export "add" (func $add))
+// )
+// prettier-ignore
+const bytes = new Uint8Array([
+ 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x60,
+ 0x02, 0x7f, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, 0x07, 0x01,
+ 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x09, 0x01, 0x07, 0x00, 0x20,
+ 0x00, 0x20, 0x01, 0x6a, 0x0b
+]);
+
+async function main() {
+ const wasm = await WebAssembly.instantiate(bytes);
+ const result = wasm.instance.exports.add(1, 3);
+ console.log("1 + 3 =", result);
+ if (result != 4) {
+ throw Error("bad");
+ }
+}
+
+main();
diff --git a/cli/tests/wasm_async.out b/cli/tests/wasm_async.out
new file mode 100644
index 000000000..5cdf17de7
--- /dev/null
+++ b/cli/tests/wasm_async.out
@@ -0,0 +1 @@
+1 + 3 = 4
diff --git a/cli/tests/workers_round_robin_bench.ts b/cli/tests/workers_round_robin_bench.ts
new file mode 100644
index 000000000..7c34e75e5
--- /dev/null
+++ b/cli/tests/workers_round_robin_bench.ts
@@ -0,0 +1,79 @@
+// Benchmark measures time it takes to send a message to a group of workers one
+// at a time and wait for a response from all of them. Just a general
+// throughput and consistency benchmark.
+const data = "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n";
+const workerCount = 4;
+const cmdsPerWorker = 400;
+
+export interface ResolvableMethods<T> {
+ resolve: (value?: T | PromiseLike<T>) => void;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ reject: (reason?: any) => void;
+}
+
+export type Resolvable<T> = Promise<T> & ResolvableMethods<T>;
+
+export function createResolvable<T>(): Resolvable<T> {
+ let methods: ResolvableMethods<T>;
+ const promise = new Promise<T>(
+ (resolve, reject): void => {
+ methods = { resolve, reject };
+ }
+ );
+ // TypeScript doesn't know that the Promise callback occurs synchronously
+ // therefore use of not null assertion (`!`)
+ return Object.assign(promise, methods!) as Resolvable<T>;
+}
+
+function handleAsyncMsgFromWorker(
+ promiseTable: Map<number, Resolvable<string>>,
+ msg: { cmdId: number; data: string }
+): void {
+ const promise = promiseTable.get(msg.cmdId);
+ if (promise === null) {
+ throw new Error(`Failed to find promise: cmdId: ${msg.cmdId}, msg: ${msg}`);
+ }
+ promise.resolve(data);
+}
+
+async function main(): Promise<void> {
+ const workers: Array<[Map<number, Resolvable<string>>, Worker]> = [];
+ for (let i = 1; i <= workerCount; ++i) {
+ const worker = new Worker("./subdir/bench_worker.ts");
+ const promise = new Promise(
+ (resolve): void => {
+ worker.onmessage = (e): void => {
+ if (e.data.cmdId === 0) resolve();
+ };
+ }
+ );
+ worker.postMessage({ cmdId: 0, action: 2 });
+ await promise;
+ workers.push([new Map(), worker]);
+ }
+ // assign callback function
+ for (const [promiseTable, worker] of workers) {
+ worker.onmessage = (e): void => {
+ handleAsyncMsgFromWorker(promiseTable, e.data);
+ };
+ }
+ for (const cmdId of Array(cmdsPerWorker).keys()) {
+ const promises: Array<Promise<string>> = [];
+ for (const [promiseTable, worker] of workers) {
+ const promise = createResolvable<string>();
+ promiseTable.set(cmdId, promise);
+ worker.postMessage({ cmdId: cmdId, action: 1, data });
+ promises.push(promise);
+ }
+ for (const promise of promises) {
+ await promise;
+ }
+ }
+ for (const [, worker] of workers) {
+ worker.postMessage({ action: 3 });
+ await worker.closed; // Required to avoid a cmdId not in table error.
+ }
+ console.log("Finished!");
+}
+
+main();
diff --git a/cli/tests/workers_startup_bench.ts b/cli/tests/workers_startup_bench.ts
new file mode 100644
index 000000000..fbea4dc40
--- /dev/null
+++ b/cli/tests/workers_startup_bench.ts
@@ -0,0 +1,27 @@
+// Benchmark measures time it takes to start and stop a number of workers.
+const workerCount = 50;
+
+async function bench(): Promise<void> {
+ const workers: Worker[] = [];
+ for (let i = 1; i <= workerCount; ++i) {
+ const worker = new Worker("./subdir/bench_worker.ts");
+ const promise = new Promise(
+ (resolve): void => {
+ worker.onmessage = (e): void => {
+ if (e.data.cmdId === 0) resolve();
+ };
+ }
+ );
+ worker.postMessage({ cmdId: 0, action: 2 });
+ await promise;
+ workers.push(worker);
+ }
+ console.log("Done creating workers closing workers!");
+ for (const worker of workers) {
+ worker.postMessage({ action: 3 });
+ await worker.closed; // Required to avoid a cmdId not in table error.
+ }
+ console.log("Finished!");
+}
+
+bench();