diff options
Diffstat (limited to 'cli/tests')
31 files changed, 266 insertions, 5 deletions
diff --git a/cli/tests/integration/bench_tests.rs b/cli/tests/integration/bench_tests.rs index 1d021b69b..eadca9a1c 100644 --- a/cli/tests/integration/bench_tests.rs +++ b/cli/tests/integration/bench_tests.rs @@ -155,6 +155,19 @@ itest!(no_prompt_with_denied_perms { output: "bench/no_prompt_with_denied_perms.out", }); +itest!(check_local_by_default { + args: "bench --quiet --unstable bench/check_local_by_default.ts", + output: "bench/check_local_by_default.out", + http_server: true, +}); + +itest!(check_local_by_default2 { + args: "bench --quiet --unstable bench/check_local_by_default2.ts", + output: "bench/check_local_by_default2.out", + http_server: true, + exit_code: 1, +}); + #[test] fn recursive_permissions_pledge() { let output = util::deno_cmd() diff --git a/cli/tests/integration/bundle_tests.rs b/cli/tests/integration/bundle_tests.rs index e1a75f18d..9c328abdb 100644 --- a/cli/tests/integration/bundle_tests.rs +++ b/cli/tests/integration/bundle_tests.rs @@ -456,3 +456,16 @@ itest!(bundle_ignore_directives { args: "bundle subdir/mod1.ts", output: "bundle_ignore_directives.test.out", }); + +itest!(check_local_by_default { + args: "bundle --quiet bundle/check_local_by_default.ts", + output: "bundle/check_local_by_default.out", + http_server: true, +}); + +itest!(check_local_by_default2 { + args: "bundle --quiet bundle/check_local_by_default2.ts", + output: "bundle/check_local_by_default2.out", + http_server: true, + exit_code: 1, +}); diff --git a/cli/tests/integration/cache_tests.rs b/cli/tests/integration/cache_tests.rs index 00fd95149..bf0233a28 100644 --- a/cli/tests/integration/cache_tests.rs +++ b/cli/tests/integration/cache_tests.rs @@ -78,3 +78,16 @@ fn relative_home_dir() { assert!(output.status.success()); assert_eq!(output.stdout, b""); } + +itest!(check_local_by_default { + args: "cache --quiet cache/check_local_by_default.ts", + output: "cache/check_local_by_default.out", + http_server: true, +}); + +itest!(check_local_by_default2 { + args: "cache --quiet cache/check_local_by_default2.ts", + output: "cache/check_local_by_default2.out", + http_server: true, + exit_code: 1, +}); diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs index 2f75659cf..a3f2e8697 100644 --- a/cli/tests/integration/compile_tests.rs +++ b/cli/tests/integration/compile_tests.rs @@ -479,3 +479,52 @@ fn skip_rebundle() { assert!(output.status.success()); assert_eq!(output.stdout, "Hello World\n".as_bytes()); } + +#[test] +fn check_local_by_default() { + let _guard = util::http_server(); + let dir = TempDir::new(); + let exe = if cfg!(windows) { + dir.path().join("welcome.exe") + } else { + dir.path().join("welcome") + }; + let status = util::deno_cmd() + .current_dir(util::root_path()) + .arg("compile") + .arg("--unstable") + .arg("--output") + .arg(&exe) + .arg(util::testdata_path().join("./compile/check_local_by_default.ts")) + .status() + .unwrap(); + assert!(status.success()); +} + +#[test] +fn check_local_by_default2() { + let _guard = util::http_server(); + let dir = TempDir::new(); + let exe = if cfg!(windows) { + dir.path().join("welcome.exe") + } else { + dir.path().join("welcome") + }; + let output = util::deno_cmd() + .current_dir(util::root_path()) + .env("NO_COLOR", "1") + .arg("compile") + .arg("--unstable") + .arg("--output") + .arg(&exe) + .arg(util::testdata_path().join("./compile/check_local_by_default2.ts")) + .output() + .unwrap(); + assert!(!output.status.success()); + let stdout = String::from_utf8(output.stdout).unwrap(); + let stderr = String::from_utf8(output.stderr).unwrap(); + assert!(stdout.is_empty()); + assert!(stderr.contains( + r#"error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'."# + )); +} diff --git a/cli/tests/integration/eval_tests.rs b/cli/tests/integration/eval_tests.rs index d7503ca80..a93f85286 100644 --- a/cli/tests/integration/eval_tests.rs +++ b/cli/tests/integration/eval_tests.rs @@ -66,3 +66,16 @@ itest!(v8_flags_eval { args: "eval --v8-flags=--expose-gc console.log(typeof(gc))", output: "v8_flags.js.out", }); + +itest!(check_local_by_default { + args: "eval --quiet import('http://localhost:4545/subdir/type_error.ts').then(console.log);", + output: "eval/check_local_by_default.out", + http_server: true, +}); + +itest!(check_local_by_default2 { + args: "eval --quiet import('./eval/check_local_by_default2.ts').then(console.log);", + output: "eval/check_local_by_default2.out", + http_server: true, + exit_code: 1, +}); diff --git a/cli/tests/integration/install_tests.rs b/cli/tests/integration/install_tests.rs index ebe587301..44b418e10 100644 --- a/cli/tests/integration/install_tests.rs +++ b/cli/tests/integration/install_tests.rs @@ -41,9 +41,11 @@ fn install_basic() { assert_eq!(content.chars().last().unwrap(), '\n'); if cfg!(windows) { - assert!(content.contains(r#""run" "http://localhost:4545/echo.ts""#)); + assert!( + content.contains(r#""run" "--check" "http://localhost:4545/echo.ts""#) + ); } else { - assert!(content.contains(r#"run 'http://localhost:4545/echo.ts'"#)); + assert!(content.contains(r#"run --check 'http://localhost:4545/echo.ts'"#)); } } @@ -79,9 +81,11 @@ fn install_custom_dir_env_var() { let content = fs::read_to_string(file_path).unwrap(); if cfg!(windows) { - assert!(content.contains(r#""run" "http://localhost:4545/echo.ts""#)); + assert!( + content.contains(r#""run" "--check" "http://localhost:4545/echo.ts""#) + ); } else { - assert!(content.contains(r#"run 'http://localhost:4545/echo.ts'"#)); + assert!(content.contains(r#"run --check 'http://localhost:4545/echo.ts'"#)); } } @@ -157,3 +161,50 @@ fn installer_test_remote_module_run() { .trim() .ends_with("hello, foo")); } + +#[test] +fn check_local_by_default() { + let _guard = util::http_server(); + let temp_dir = TempDir::new(); + let temp_dir_str = temp_dir.path().to_string_lossy().to_string(); + + let status = util::deno_cmd() + .current_dir(temp_dir.path()) + .arg("install") + .arg(util::testdata_path().join("./install/check_local_by_default.ts")) + .envs([ + ("HOME", temp_dir_str.as_str()), + ("USERPROFILE", temp_dir_str.as_str()), + ("DENO_INSTALL_ROOT", ""), + ]) + .status() + .unwrap(); + assert!(status.success()); +} + +#[test] +fn check_local_by_default2() { + let _guard = util::http_server(); + let temp_dir = TempDir::new(); + let temp_dir_str = temp_dir.path().to_string_lossy().to_string(); + + let output = util::deno_cmd() + .current_dir(temp_dir.path()) + .arg("install") + .arg(util::testdata_path().join("./install/check_local_by_default2.ts")) + .envs([ + ("HOME", temp_dir_str.as_str()), + ("NO_COLOR", "1"), + ("USERPROFILE", temp_dir_str.as_str()), + ("DENO_INSTALL_ROOT", ""), + ]) + .output() + .unwrap(); + assert!(!output.status.success()); + let stdout = String::from_utf8(output.stdout).unwrap(); + let stderr = String::from_utf8(output.stderr).unwrap(); + assert!(stdout.is_empty()); + assert!(stderr.contains( + r#"error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'."# + )); +} diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 4dc17bacb..c1ed59f14 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -963,7 +963,7 @@ itest!(no_check_decorators { }); itest!(check_remote { - args: "run --quiet --reload no_check_remote.ts", + args: "run --quiet --reload --check=all no_check_remote.ts", output: "no_check_remote.ts.disabled.out", exit_code: 1, http_server: true, diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 05a663215..3a7e71090 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -374,3 +374,16 @@ itest!(uncaught_errors { output: "test/uncaught_errors.out", exit_code: 1, }); + +itest!(check_local_by_default { + args: "test --quiet test/check_local_by_default.ts", + output: "test/check_local_by_default.out", + http_server: true, +}); + +itest!(check_local_by_default2 { + args: "test --quiet test/check_local_by_default2.ts", + output: "test/check_local_by_default2.out", + http_server: true, + exit_code: 1, +}); diff --git a/cli/tests/testdata/bench/check_local_by_default.out b/cli/tests/testdata/bench/check_local_by_default.out new file mode 100644 index 000000000..971c098bd --- /dev/null +++ b/cli/tests/testdata/bench/check_local_by_default.out @@ -0,0 +1,5 @@ +[WILDCARD] + +[WILDCARD]/bench/check_local_by_default.ts +benchmark time (avg) (min … max) p75 p99 p995 +------------------------------------------------- ----------------------------- diff --git a/cli/tests/testdata/bench/check_local_by_default.ts b/cli/tests/testdata/bench/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/cli/tests/testdata/bench/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/cli/tests/testdata/bench/check_local_by_default2.out b/cli/tests/testdata/bench/check_local_by_default2.out new file mode 100644 index 000000000..01aeda636 --- /dev/null +++ b/cli/tests/testdata/bench/check_local_by_default2.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]bench/check_local_by_default2.ts:3:7 diff --git a/cli/tests/testdata/bench/check_local_by_default2.ts b/cli/tests/testdata/bench/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/tests/testdata/bench/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/cli/tests/testdata/bundle/check_local_by_default.out b/cli/tests/testdata/bundle/check_local_by_default.out new file mode 100644 index 000000000..c4559d1fa --- /dev/null +++ b/cli/tests/testdata/bundle/check_local_by_default.out @@ -0,0 +1,6 @@ +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +console.log(12); + diff --git a/cli/tests/testdata/bundle/check_local_by_default.ts b/cli/tests/testdata/bundle/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/cli/tests/testdata/bundle/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/cli/tests/testdata/bundle/check_local_by_default2.out b/cli/tests/testdata/bundle/check_local_by_default2.out new file mode 100644 index 000000000..60f5760f8 --- /dev/null +++ b/cli/tests/testdata/bundle/check_local_by_default2.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]bundle/check_local_by_default2.ts:3:7 diff --git a/cli/tests/testdata/bundle/check_local_by_default2.ts b/cli/tests/testdata/bundle/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/tests/testdata/bundle/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/cli/tests/testdata/cache/check_local_by_default.out b/cli/tests/testdata/cache/check_local_by_default.out new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/cli/tests/testdata/cache/check_local_by_default.out diff --git a/cli/tests/testdata/cache/check_local_by_default.ts b/cli/tests/testdata/cache/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/cli/tests/testdata/cache/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/cli/tests/testdata/cache/check_local_by_default2.out b/cli/tests/testdata/cache/check_local_by_default2.out new file mode 100644 index 000000000..1367dc70e --- /dev/null +++ b/cli/tests/testdata/cache/check_local_by_default2.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]cache/check_local_by_default2.ts:3:7 diff --git a/cli/tests/testdata/cache/check_local_by_default2.ts b/cli/tests/testdata/cache/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/tests/testdata/cache/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/cli/tests/testdata/compile/check_local_by_default.ts b/cli/tests/testdata/compile/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/cli/tests/testdata/compile/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/cli/tests/testdata/compile/check_local_by_default2.ts b/cli/tests/testdata/compile/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/tests/testdata/compile/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/cli/tests/testdata/eval/check_local_by_default.out b/cli/tests/testdata/eval/check_local_by_default.out new file mode 100644 index 000000000..e3e1c694f --- /dev/null +++ b/cli/tests/testdata/eval/check_local_by_default.out @@ -0,0 +1 @@ +Module { a: 12 } diff --git a/cli/tests/testdata/eval/check_local_by_default2.out b/cli/tests/testdata/eval/check_local_by_default2.out new file mode 100644 index 000000000..072068827 --- /dev/null +++ b/cli/tests/testdata/eval/check_local_by_default2.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]eval/check_local_by_default2.ts:3:7 diff --git a/cli/tests/testdata/eval/check_local_by_default2.ts b/cli/tests/testdata/eval/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/tests/testdata/eval/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/cli/tests/testdata/install/check_local_by_default.ts b/cli/tests/testdata/install/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/cli/tests/testdata/install/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/cli/tests/testdata/install/check_local_by_default2.ts b/cli/tests/testdata/install/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/tests/testdata/install/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/cli/tests/testdata/test/check_local_by_default.out b/cli/tests/testdata/test/check_local_by_default.out new file mode 100644 index 000000000..29c1bbc42 --- /dev/null +++ b/cli/tests/testdata/test/check_local_by_default.out @@ -0,0 +1,4 @@ +running 0 tests from ./test/check_local_by_default.ts + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/testdata/test/check_local_by_default.ts b/cli/tests/testdata/test/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/cli/tests/testdata/test/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/cli/tests/testdata/test/check_local_by_default2.out b/cli/tests/testdata/test/check_local_by_default2.out new file mode 100644 index 000000000..b933ac483 --- /dev/null +++ b/cli/tests/testdata/test/check_local_by_default2.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]test/check_local_by_default2.ts:3:7 diff --git a/cli/tests/testdata/test/check_local_by_default2.ts b/cli/tests/testdata/test/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/cli/tests/testdata/test/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); |