From c6ae41fd8701b0fc5735ae4a6fa288f5cb35f03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 4 Oct 2021 18:16:49 +0200 Subject: test: refactor lint tests into directories (#12317) Just reorganizing lint tests in such a way that adding new file in a directory doesn't change result of other tests. --- cli/tests/integration/lint_tests.rs | 30 +++++++++++----------- cli/tests/testdata/lint/Deno.jsonc | 4 +-- cli/tests/testdata/lint/Deno.malformed.jsonc | 4 +-- cli/tests/testdata/lint/Deno.malformed2.jsonc | 4 +-- cli/tests/testdata/lint/file1.js | 2 -- cli/tests/testdata/lint/file2.ts | 6 ----- cli/tests/testdata/lint/ignored_file.ts | 3 --- cli/tests/testdata/lint/lint_with_config.out | 18 ------------- cli/tests/testdata/lint/lint_with_config/a.ts | 4 --- cli/tests/testdata/lint/lint_with_config/b.ts | 4 --- .../testdata/lint/lint_with_config_and_flags.out | 18 ------------- .../testdata/lint/lint_with_malformed_config.out | 4 --- .../testdata/lint/lint_with_malformed_config2.out | 4 --- cli/tests/testdata/lint/malformed.js | 4 --- cli/tests/testdata/lint/with_config.out | 18 +++++++++++++ cli/tests/testdata/lint/with_config/a.ts | 4 +++ cli/tests/testdata/lint/with_config/b.ts | 4 +++ cli/tests/testdata/lint/with_config_and_flags.out | 18 +++++++++++++ cli/tests/testdata/lint/with_malformed_config.out | 4 +++ cli/tests/testdata/lint/with_malformed_config2.out | 4 +++ cli/tests/testdata/lint/without_config/file1.js | 2 ++ cli/tests/testdata/lint/without_config/file2.ts | 6 +++++ .../testdata/lint/without_config/ignored_file.ts | 3 +++ .../testdata/lint/without_config/malformed.js | 4 +++ 24 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 cli/tests/testdata/lint/file1.js delete mode 100644 cli/tests/testdata/lint/file2.ts delete mode 100644 cli/tests/testdata/lint/ignored_file.ts delete mode 100644 cli/tests/testdata/lint/lint_with_config.out delete mode 100644 cli/tests/testdata/lint/lint_with_config/a.ts delete mode 100644 cli/tests/testdata/lint/lint_with_config/b.ts delete mode 100644 cli/tests/testdata/lint/lint_with_config_and_flags.out delete mode 100644 cli/tests/testdata/lint/lint_with_malformed_config.out delete mode 100644 cli/tests/testdata/lint/lint_with_malformed_config2.out delete mode 100644 cli/tests/testdata/lint/malformed.js create mode 100644 cli/tests/testdata/lint/with_config.out create mode 100644 cli/tests/testdata/lint/with_config/a.ts create mode 100644 cli/tests/testdata/lint/with_config/b.ts create mode 100644 cli/tests/testdata/lint/with_config_and_flags.out create mode 100644 cli/tests/testdata/lint/with_malformed_config.out create mode 100644 cli/tests/testdata/lint/with_malformed_config2.out create mode 100644 cli/tests/testdata/lint/without_config/file1.js create mode 100644 cli/tests/testdata/lint/without_config/file2.ts create mode 100644 cli/tests/testdata/lint/without_config/ignored_file.ts create mode 100644 cli/tests/testdata/lint/without_config/malformed.js diff --git a/cli/tests/integration/lint_tests.rs b/cli/tests/integration/lint_tests.rs index b11cc5b9a..4f4cf1984 100644 --- a/cli/tests/integration/lint_tests.rs +++ b/cli/tests/integration/lint_tests.rs @@ -24,33 +24,33 @@ fn ignore_unexplicit_files() { } itest!(all { - args: "lint lint/file1.js lint/file2.ts lint/ignored_file.ts", + args: "lint lint/without_config/file1.js lint/without_config/file2.ts lint/without_config/ignored_file.ts", output: "lint/expected.out", exit_code: 1, }); itest!(quiet { - args: "lint --quiet lint/file1.js", + args: "lint --quiet lint/without_config/file1.js", output: "lint/expected_quiet.out", exit_code: 1, }); itest!(json { - args: - "lint --json lint/file1.js lint/file2.ts lint/ignored_file.ts lint/malformed.js", - output: "lint/expected_json.out", - exit_code: 1, - }); + args: + "lint --json lint/without_config/file1.js lint/without_config/file2.ts lint/without_config/ignored_file.ts lint/without_config/malformed.js", + output: "lint/expected_json.out", + exit_code: 1, +}); itest!(ignore { args: - "lint --ignore=lint/file1.js,lint/malformed.js,lint/lint_with_config/ lint/", + "lint --ignore=lint/without_config/file1.js,lint/without_config/malformed.js,lint/without_config/lint_with_config/ lint/without_config/", output: "lint/expected_ignore.out", exit_code: 1, }); itest!(glob { - args: "lint --ignore=lint/malformed.js,lint/lint_with_config/ lint/", + args: "lint --ignore=lint/without_config/malformed.js,lint/with_config/ lint/without_config/", output: "lint/expected_glob.out", exit_code: 1, }); @@ -83,26 +83,26 @@ itest!(rules_quiet { }); itest!(lint_with_config { - args: "lint --config lint/Deno.jsonc lint/lint_with_config/", - output: "lint/lint_with_config.out", + args: "lint --config lint/Deno.jsonc lint/with_config/", + output: "lint/with_config.out", exit_code: 1, }); // Check if CLI flags take precedence itest!(lint_with_config_and_flags { - args: "lint --config lint/Deno.jsonc --ignore=lint/lint_with_config/a.ts", - output: "lint/lint_with_config_and_flags.out", + args: "lint --config lint/Deno.jsonc --ignore=lint/with_config/a.ts", + output: "lint/with_config_and_flags.out", exit_code: 1, }); itest!(lint_with_malformed_config { args: "lint --config lint/Deno.malformed.jsonc", - output: "lint/lint_with_malformed_config.out", + output: "lint/with_malformed_config.out", exit_code: 1, }); itest!(lint_with_malformed_config2 { args: "lint --config lint/Deno.malformed2.jsonc", - output: "lint/lint_with_malformed_config2.out", + output: "lint/with_malformed_config2.out", exit_code: 1, }); diff --git a/cli/tests/testdata/lint/Deno.jsonc b/cli/tests/testdata/lint/Deno.jsonc index dc0a12eab..9cd521592 100644 --- a/cli/tests/testdata/lint/Deno.jsonc +++ b/cli/tests/testdata/lint/Deno.jsonc @@ -1,8 +1,8 @@ { "lint": { "files": { - "include": ["lint/lint_with_config/"], - "exclude": ["lint/lint_with_config/b.ts"] + "include": ["lint/with_config/"], + "exclude": ["lint/with_config/b.ts"] }, "rules": { "tags": ["recommended"], diff --git a/cli/tests/testdata/lint/Deno.malformed.jsonc b/cli/tests/testdata/lint/Deno.malformed.jsonc index c6225d6a9..f0d654114 100644 --- a/cli/tests/testdata/lint/Deno.malformed.jsonc +++ b/cli/tests/testdata/lint/Deno.malformed.jsonc @@ -1,8 +1,8 @@ { "lint": { "files": { - "include": ["lint/lint_with_config/"], - "exclude": ["lint/lint_with_config/b.ts"] + "include": ["lint/with_config/"], + "exclude": ["lint/with_config/b.ts"] }, "dont_know_this_field": {}, "rules": { diff --git a/cli/tests/testdata/lint/Deno.malformed2.jsonc b/cli/tests/testdata/lint/Deno.malformed2.jsonc index 473dafc4b..741e0321b 100644 --- a/cli/tests/testdata/lint/Deno.malformed2.jsonc +++ b/cli/tests/testdata/lint/Deno.malformed2.jsonc @@ -1,8 +1,8 @@ { "lint": { "files": { - "include": ["lint/lint_with_config/"], - "exclude": ["lint/lint_with_config/b.ts"], + "include": ["lint/with_config/"], + "exclude": ["lint/with_config/b.ts"], "dont_know_this_field": {} }, "rules": { diff --git a/cli/tests/testdata/lint/file1.js b/cli/tests/testdata/lint/file1.js deleted file mode 100644 index 737f26818..000000000 --- a/cli/tests/testdata/lint/file1.js +++ /dev/null @@ -1,2 +0,0 @@ -// deno-lint-ignore -while (false) {} diff --git a/cli/tests/testdata/lint/file2.ts b/cli/tests/testdata/lint/file2.ts deleted file mode 100644 index 73c612c35..000000000 --- a/cli/tests/testdata/lint/file2.ts +++ /dev/null @@ -1,6 +0,0 @@ -try { - await Deno.open("./some/file.txt"); -} catch (_e) {} - -// deno-lint-ignore no-explicit-any -function _foo(): any {} diff --git a/cli/tests/testdata/lint/ignored_file.ts b/cli/tests/testdata/lint/ignored_file.ts deleted file mode 100644 index 97befafa3..000000000 --- a/cli/tests/testdata/lint/ignored_file.ts +++ /dev/null @@ -1,3 +0,0 @@ -// deno-lint-ignore-file - -function foo(): any {} diff --git a/cli/tests/testdata/lint/lint_with_config.out b/cli/tests/testdata/lint/lint_with_config.out deleted file mode 100644 index ea4581af8..000000000 --- a/cli/tests/testdata/lint/lint_with_config.out +++ /dev/null @@ -1,18 +0,0 @@ -(ban-untagged-todo) TODO should be tagged with (@username) or (#issue) -// TODO: foo -^^^^^^^^^^^^ - at [WILDCARD]a.ts:1:0 - - hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123) - help: for further information visit https://lint.deno.land/#ban-untagged-todo - -(no-unused-vars) `add` is never used -function add(a: number, b: number): number { - ^^^ - at [WILDCARD]a.ts:2:9 - - hint: If this is intentional, prefix it with an underscore like `_add` - help: for further information visit https://lint.deno.land/#no-unused-vars - -Found 2 problems -Checked 1 file diff --git a/cli/tests/testdata/lint/lint_with_config/a.ts b/cli/tests/testdata/lint/lint_with_config/a.ts deleted file mode 100644 index c378218a3..000000000 --- a/cli/tests/testdata/lint/lint_with_config/a.ts +++ /dev/null @@ -1,4 +0,0 @@ -// TODO: foo -function add(a: number, b: number): number { - return a + b; -} diff --git a/cli/tests/testdata/lint/lint_with_config/b.ts b/cli/tests/testdata/lint/lint_with_config/b.ts deleted file mode 100644 index d5647067e..000000000 --- a/cli/tests/testdata/lint/lint_with_config/b.ts +++ /dev/null @@ -1,4 +0,0 @@ -// TODO: this file should be ignored -function subtract(a: number, b: number): number { - return a - b; -} diff --git a/cli/tests/testdata/lint/lint_with_config_and_flags.out b/cli/tests/testdata/lint/lint_with_config_and_flags.out deleted file mode 100644 index 0a409343e..000000000 --- a/cli/tests/testdata/lint/lint_with_config_and_flags.out +++ /dev/null @@ -1,18 +0,0 @@ -(ban-untagged-todo) TODO should be tagged with (@username) or (#issue) -// TODO: this file should be ignored -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - at [WILDCARD]b.ts:1:0 - - hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123) - help: for further information visit https://lint.deno.land/#ban-untagged-todo - -(no-unused-vars) `subtract` is never used -function subtract(a: number, b: number): number { - ^^^^^^^^ - at [WILDCARD]b.ts:2:9 - - hint: If this is intentional, prefix it with an underscore like `_subtract` - help: for further information visit https://lint.deno.land/#no-unused-vars - -Found 2 problems -Checked 1 file diff --git a/cli/tests/testdata/lint/lint_with_malformed_config.out b/cli/tests/testdata/lint/lint_with_malformed_config.out deleted file mode 100644 index 88fb8c457..000000000 --- a/cli/tests/testdata/lint/lint_with_malformed_config.out +++ /dev/null @@ -1,4 +0,0 @@ -error: Failed to parse "lint" configuration - -Caused by: - unknown field `dont_know_this_field`, expected `rules` or `files` diff --git a/cli/tests/testdata/lint/lint_with_malformed_config2.out b/cli/tests/testdata/lint/lint_with_malformed_config2.out deleted file mode 100644 index 11e878f00..000000000 --- a/cli/tests/testdata/lint/lint_with_malformed_config2.out +++ /dev/null @@ -1,4 +0,0 @@ -error: Failed to parse "lint" configuration - -Caused by: - unknown field `dont_know_this_field`, expected `include` or `exclude` diff --git a/cli/tests/testdata/lint/malformed.js b/cli/tests/testdata/lint/malformed.js deleted file mode 100644 index 5ad4650d6..000000000 --- a/cli/tests/testdata/lint/malformed.js +++ /dev/null @@ -1,4 +0,0 @@ -// deno-fmt-ignore-file - -// intentionally malformed file -export class A { \ No newline at end of file diff --git a/cli/tests/testdata/lint/with_config.out b/cli/tests/testdata/lint/with_config.out new file mode 100644 index 000000000..ea4581af8 --- /dev/null +++ b/cli/tests/testdata/lint/with_config.out @@ -0,0 +1,18 @@ +(ban-untagged-todo) TODO should be tagged with (@username) or (#issue) +// TODO: foo +^^^^^^^^^^^^ + at [WILDCARD]a.ts:1:0 + + hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123) + help: for further information visit https://lint.deno.land/#ban-untagged-todo + +(no-unused-vars) `add` is never used +function add(a: number, b: number): number { + ^^^ + at [WILDCARD]a.ts:2:9 + + hint: If this is intentional, prefix it with an underscore like `_add` + help: for further information visit https://lint.deno.land/#no-unused-vars + +Found 2 problems +Checked 1 file diff --git a/cli/tests/testdata/lint/with_config/a.ts b/cli/tests/testdata/lint/with_config/a.ts new file mode 100644 index 000000000..c378218a3 --- /dev/null +++ b/cli/tests/testdata/lint/with_config/a.ts @@ -0,0 +1,4 @@ +// TODO: foo +function add(a: number, b: number): number { + return a + b; +} diff --git a/cli/tests/testdata/lint/with_config/b.ts b/cli/tests/testdata/lint/with_config/b.ts new file mode 100644 index 000000000..d5647067e --- /dev/null +++ b/cli/tests/testdata/lint/with_config/b.ts @@ -0,0 +1,4 @@ +// TODO: this file should be ignored +function subtract(a: number, b: number): number { + return a - b; +} diff --git a/cli/tests/testdata/lint/with_config_and_flags.out b/cli/tests/testdata/lint/with_config_and_flags.out new file mode 100644 index 000000000..0a409343e --- /dev/null +++ b/cli/tests/testdata/lint/with_config_and_flags.out @@ -0,0 +1,18 @@ +(ban-untagged-todo) TODO should be tagged with (@username) or (#issue) +// TODO: this file should be ignored +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + at [WILDCARD]b.ts:1:0 + + hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123) + help: for further information visit https://lint.deno.land/#ban-untagged-todo + +(no-unused-vars) `subtract` is never used +function subtract(a: number, b: number): number { + ^^^^^^^^ + at [WILDCARD]b.ts:2:9 + + hint: If this is intentional, prefix it with an underscore like `_subtract` + help: for further information visit https://lint.deno.land/#no-unused-vars + +Found 2 problems +Checked 1 file diff --git a/cli/tests/testdata/lint/with_malformed_config.out b/cli/tests/testdata/lint/with_malformed_config.out new file mode 100644 index 000000000..88fb8c457 --- /dev/null +++ b/cli/tests/testdata/lint/with_malformed_config.out @@ -0,0 +1,4 @@ +error: Failed to parse "lint" configuration + +Caused by: + unknown field `dont_know_this_field`, expected `rules` or `files` diff --git a/cli/tests/testdata/lint/with_malformed_config2.out b/cli/tests/testdata/lint/with_malformed_config2.out new file mode 100644 index 000000000..11e878f00 --- /dev/null +++ b/cli/tests/testdata/lint/with_malformed_config2.out @@ -0,0 +1,4 @@ +error: Failed to parse "lint" configuration + +Caused by: + unknown field `dont_know_this_field`, expected `include` or `exclude` diff --git a/cli/tests/testdata/lint/without_config/file1.js b/cli/tests/testdata/lint/without_config/file1.js new file mode 100644 index 000000000..737f26818 --- /dev/null +++ b/cli/tests/testdata/lint/without_config/file1.js @@ -0,0 +1,2 @@ +// deno-lint-ignore +while (false) {} diff --git a/cli/tests/testdata/lint/without_config/file2.ts b/cli/tests/testdata/lint/without_config/file2.ts new file mode 100644 index 000000000..73c612c35 --- /dev/null +++ b/cli/tests/testdata/lint/without_config/file2.ts @@ -0,0 +1,6 @@ +try { + await Deno.open("./some/file.txt"); +} catch (_e) {} + +// deno-lint-ignore no-explicit-any +function _foo(): any {} diff --git a/cli/tests/testdata/lint/without_config/ignored_file.ts b/cli/tests/testdata/lint/without_config/ignored_file.ts new file mode 100644 index 000000000..97befafa3 --- /dev/null +++ b/cli/tests/testdata/lint/without_config/ignored_file.ts @@ -0,0 +1,3 @@ +// deno-lint-ignore-file + +function foo(): any {} diff --git a/cli/tests/testdata/lint/without_config/malformed.js b/cli/tests/testdata/lint/without_config/malformed.js new file mode 100644 index 000000000..5ad4650d6 --- /dev/null +++ b/cli/tests/testdata/lint/without_config/malformed.js @@ -0,0 +1,4 @@ +// deno-fmt-ignore-file + +// intentionally malformed file +export class A { \ No newline at end of file -- cgit v1.2.3