From 392579b5a673964752e38e1e0d9c2c9ae223a382 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 15 Mar 2024 13:27:52 -0400 Subject: chore(specs): use jsonc for metadata file (#22946) Avoids the comment diagnostic that vscode gives. Also, automatically renames .json to .jsonc for the time being. --- .../types_resolved_relative_config/__test__.json | 5 ---- .../types_resolved_relative_config/__test__.jsonc | 5 ++++ .../import_map/import_map_config/__test__.json | 28 ---------------------- .../import_map/import_map_config/__test__.jsonc | 28 ++++++++++++++++++++++ tests/specs/info/ts_error/__test__.json | 4 ---- tests/specs/info/ts_error/__test__.jsonc | 4 ++++ tests/specs/mod.rs | 10 +++++++- .../specs/npm/check_pkg_json_import/__test__.json | 5 ---- .../specs/npm/check_pkg_json_import/__test__.jsonc | 5 ++++ tests/specs/npm/conditional_exports/__test__.json | 5 ---- tests/specs/npm/conditional_exports/__test__.jsonc | 5 ++++ .../__test__.json | 6 ----- .../__test__.jsonc | 6 +++++ tests/specs/npm/es_module/__test__.json | 22 ----------------- tests/specs/npm/es_module/__test__.jsonc | 22 +++++++++++++++++ tests/specs/run/redirect_javascript/__test__.json | 4 ---- tests/specs/run/redirect_javascript/__test__.jsonc | 4 ++++ .../specs/test/sanitizer_with_error/__test__.json | 5 ---- .../specs/test/sanitizer_with_error/__test__.jsonc | 5 ++++ .../sanitizer_with_top_level_ops/__test__.json | 4 ---- .../sanitizer_with_top_level_ops/__test__.jsonc | 4 ++++ 21 files changed, 97 insertions(+), 89 deletions(-) delete mode 100644 tests/specs/check/types_resolved_relative_config/__test__.json create mode 100644 tests/specs/check/types_resolved_relative_config/__test__.jsonc delete mode 100644 tests/specs/import_map/import_map_config/__test__.json create mode 100644 tests/specs/import_map/import_map_config/__test__.jsonc delete mode 100644 tests/specs/info/ts_error/__test__.json create mode 100644 tests/specs/info/ts_error/__test__.jsonc delete mode 100644 tests/specs/npm/check_pkg_json_import/__test__.json create mode 100644 tests/specs/npm/check_pkg_json_import/__test__.jsonc delete mode 100644 tests/specs/npm/conditional_exports/__test__.json create mode 100644 tests/specs/npm/conditional_exports/__test__.jsonc delete mode 100644 tests/specs/npm/conditional_exports_node_modules_dir/__test__.json create mode 100644 tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc delete mode 100644 tests/specs/npm/es_module/__test__.json create mode 100644 tests/specs/npm/es_module/__test__.jsonc delete mode 100644 tests/specs/run/redirect_javascript/__test__.json create mode 100644 tests/specs/run/redirect_javascript/__test__.jsonc delete mode 100644 tests/specs/test/sanitizer_with_error/__test__.json create mode 100644 tests/specs/test/sanitizer_with_error/__test__.jsonc delete mode 100644 tests/specs/test/sanitizer_with_top_level_ops/__test__.json create mode 100644 tests/specs/test/sanitizer_with_top_level_ops/__test__.jsonc diff --git a/tests/specs/check/types_resolved_relative_config/__test__.json b/tests/specs/check/types_resolved_relative_config/__test__.json deleted file mode 100644 index 6f4937209..000000000 --- a/tests/specs/check/types_resolved_relative_config/__test__.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "args": "check --config sub_dir/deno.json main.ts", - "output": "main.out", - "exitCode": 1 -} diff --git a/tests/specs/check/types_resolved_relative_config/__test__.jsonc b/tests/specs/check/types_resolved_relative_config/__test__.jsonc new file mode 100644 index 000000000..6f4937209 --- /dev/null +++ b/tests/specs/check/types_resolved_relative_config/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check --config sub_dir/deno.json main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/import_map/import_map_config/__test__.json b/tests/specs/import_map/import_map_config/__test__.json deleted file mode 100644 index b0463a231..000000000 --- a/tests/specs/import_map/import_map_config/__test__.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "steps": [{ - "args": "run --quiet --reload --import-map=import_map.json test.ts", - "output": "run.out" - }, { - "args": "run --quiet --reload --import-map=import_map_invalid.json --config=config.json test.ts", - "output": "flag_has_precedence.out", - "exitCode": 1 - }, { - "args": "run --reload --config=config.json test.ts", - "output": "config.out" - }, { - "cleanDenoDir": true, - "args": "cache --quiet --reload --import-map=import_map.json test.ts", - "output": "cache.out" - }, { - "cleanDenoDir": true, - "args": "info --quiet --import-map=import_map.json test.ts", - "output": "info.out" - }, { - "args": "run --quiet --reload --import-map=import_map.json unmapped_bare_specifier.ts", - "output": "unmapped_bare_specifier.out", - "exitCode": 1 - }, { - "args": "run --quiet --reload --import-map import_map.json import_data_url.ts", - "output": "import_data_url.out" - }] -} diff --git a/tests/specs/import_map/import_map_config/__test__.jsonc b/tests/specs/import_map/import_map_config/__test__.jsonc new file mode 100644 index 000000000..b0463a231 --- /dev/null +++ b/tests/specs/import_map/import_map_config/__test__.jsonc @@ -0,0 +1,28 @@ +{ + "steps": [{ + "args": "run --quiet --reload --import-map=import_map.json test.ts", + "output": "run.out" + }, { + "args": "run --quiet --reload --import-map=import_map_invalid.json --config=config.json test.ts", + "output": "flag_has_precedence.out", + "exitCode": 1 + }, { + "args": "run --reload --config=config.json test.ts", + "output": "config.out" + }, { + "cleanDenoDir": true, + "args": "cache --quiet --reload --import-map=import_map.json test.ts", + "output": "cache.out" + }, { + "cleanDenoDir": true, + "args": "info --quiet --import-map=import_map.json test.ts", + "output": "info.out" + }, { + "args": "run --quiet --reload --import-map=import_map.json unmapped_bare_specifier.ts", + "output": "unmapped_bare_specifier.out", + "exitCode": 1 + }, { + "args": "run --quiet --reload --import-map import_map.json import_data_url.ts", + "output": "import_data_url.out" + }] +} diff --git a/tests/specs/info/ts_error/__test__.json b/tests/specs/info/ts_error/__test__.json deleted file mode 100644 index 9ec9b6044..000000000 --- a/tests/specs/info/ts_error/__test__.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "args": "info info_ts_error.ts", - "output": "info_ts_error.out" -} diff --git a/tests/specs/info/ts_error/__test__.jsonc b/tests/specs/info/ts_error/__test__.jsonc new file mode 100644 index 000000000..9ec9b6044 --- /dev/null +++ b/tests/specs/info/ts_error/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "info info_ts_error.ts", + "output": "info_ts_error.out" +} diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index 7795f47de..d010de43d 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -282,7 +282,15 @@ fn collect_tests() -> Vec { } let test_dir = PathRef::new(entry.path()); - let metadata_path = test_dir.join("__test__.json"); + let metadata_path = test_dir.join("__test__.jsonc"); + if !metadata_path.is_file() { + let json_path = test_dir.join("__test__.json"); + if json_path.is_file() { + // automatically rename to jsonc + json_path.rename(&metadata_path); + } + } + let metadata_value = metadata_path.read_jsonc_value(); // checking for "steps" leads to a more targeted error message // instead of when deserializing an untagged enum diff --git a/tests/specs/npm/check_pkg_json_import/__test__.json b/tests/specs/npm/check_pkg_json_import/__test__.json deleted file mode 100644 index ce8e53280..000000000 --- a/tests/specs/npm/check_pkg_json_import/__test__.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "base": "npm", - "args": "check --all main.ts", - "output": "main.out" -} diff --git a/tests/specs/npm/check_pkg_json_import/__test__.jsonc b/tests/specs/npm/check_pkg_json_import/__test__.jsonc new file mode 100644 index 000000000..ce8e53280 --- /dev/null +++ b/tests/specs/npm/check_pkg_json_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "base": "npm", + "args": "check --all main.ts", + "output": "main.out" +} diff --git a/tests/specs/npm/conditional_exports/__test__.json b/tests/specs/npm/conditional_exports/__test__.json deleted file mode 100644 index 72b058cbf..000000000 --- a/tests/specs/npm/conditional_exports/__test__.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "base": "npm", - "args": "run --allow-read main.js", - "output": "main.out" -} diff --git a/tests/specs/npm/conditional_exports/__test__.jsonc b/tests/specs/npm/conditional_exports/__test__.jsonc new file mode 100644 index 000000000..72b058cbf --- /dev/null +++ b/tests/specs/npm/conditional_exports/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "base": "npm", + "args": "run --allow-read main.js", + "output": "main.out" +} diff --git a/tests/specs/npm/conditional_exports_node_modules_dir/__test__.json b/tests/specs/npm/conditional_exports_node_modules_dir/__test__.json deleted file mode 100644 index 09ea8b23b..000000000 --- a/tests/specs/npm/conditional_exports_node_modules_dir/__test__.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "base": "npm", - "tempDir": true, - "args": "run --allow-read --node-modules-dir main.js", - "output": "main.out" -} diff --git a/tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc b/tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc new file mode 100644 index 000000000..09ea8b23b --- /dev/null +++ b/tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "base": "npm", + "tempDir": true, + "args": "run --allow-read --node-modules-dir main.js", + "output": "main.out" +} diff --git a/tests/specs/npm/es_module/__test__.json b/tests/specs/npm/es_module/__test__.json deleted file mode 100644 index f720a2bc0..000000000 --- a/tests/specs/npm/es_module/__test__.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "base": "npm", - "steps": [{ - "args": "run --allow-read --allow-env main.js", - "output": "main.out" - }, { - "cleanDenoDir": true, - "args": "test --allow-read --allow-env test.js", - "output": "test.out" - }, { - "cleanDenoDir": true, - "args": [ - "eval", - "import chalk from 'npm:chalk@5'; console.log(chalk.green('chalk esm loads'));" - ], - "output": "main.out" - }, { - "args": "bundle --quiet main.js", - "output": "bundle.out", - "exitCode": 1 - }] -} diff --git a/tests/specs/npm/es_module/__test__.jsonc b/tests/specs/npm/es_module/__test__.jsonc new file mode 100644 index 000000000..f720a2bc0 --- /dev/null +++ b/tests/specs/npm/es_module/__test__.jsonc @@ -0,0 +1,22 @@ +{ + "base": "npm", + "steps": [{ + "args": "run --allow-read --allow-env main.js", + "output": "main.out" + }, { + "cleanDenoDir": true, + "args": "test --allow-read --allow-env test.js", + "output": "test.out" + }, { + "cleanDenoDir": true, + "args": [ + "eval", + "import chalk from 'npm:chalk@5'; console.log(chalk.green('chalk esm loads'));" + ], + "output": "main.out" + }, { + "args": "bundle --quiet main.js", + "output": "bundle.out", + "exitCode": 1 + }] +} diff --git a/tests/specs/run/redirect_javascript/__test__.json b/tests/specs/run/redirect_javascript/__test__.json deleted file mode 100644 index 1fd0b4cb1..000000000 --- a/tests/specs/run/redirect_javascript/__test__.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "args": "run --quiet --reload main.js", - "output": "main.out" -} diff --git a/tests/specs/run/redirect_javascript/__test__.jsonc b/tests/specs/run/redirect_javascript/__test__.jsonc new file mode 100644 index 000000000..1fd0b4cb1 --- /dev/null +++ b/tests/specs/run/redirect_javascript/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload main.js", + "output": "main.out" +} diff --git a/tests/specs/test/sanitizer_with_error/__test__.json b/tests/specs/test/sanitizer_with_error/__test__.json deleted file mode 100644 index 67b65184f..000000000 --- a/tests/specs/test/sanitizer_with_error/__test__.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "args": "test --quiet main.js", - "output": "main.out", - "exitCode": 1 -} diff --git a/tests/specs/test/sanitizer_with_error/__test__.jsonc b/tests/specs/test/sanitizer_with_error/__test__.jsonc new file mode 100644 index 000000000..67b65184f --- /dev/null +++ b/tests/specs/test/sanitizer_with_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "test --quiet main.js", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/test/sanitizer_with_top_level_ops/__test__.json b/tests/specs/test/sanitizer_with_top_level_ops/__test__.json deleted file mode 100644 index f3862a7ab..000000000 --- a/tests/specs/test/sanitizer_with_top_level_ops/__test__.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "args": "test --quiet --allow-net main.js", - "output": "main.out" -} diff --git a/tests/specs/test/sanitizer_with_top_level_ops/__test__.jsonc b/tests/specs/test/sanitizer_with_top_level_ops/__test__.jsonc new file mode 100644 index 000000000..f3862a7ab --- /dev/null +++ b/tests/specs/test/sanitizer_with_top_level_ops/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "test --quiet --allow-net main.js", + "output": "main.out" +} -- cgit v1.2.3