diff options
Diffstat (limited to 'tests/specs')
40 files changed, 310 insertions, 17 deletions
diff --git a/tests/specs/coverage/no_files_found/__test__.jsonc b/tests/specs/coverage/no_files_found/__test__.jsonc new file mode 100644 index 000000000..3637b41fe --- /dev/null +++ b/tests/specs/coverage/no_files_found/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "coverage does_not_exit.js", + "output": "does_not_exist.out", + "exitCode": 1 +} diff --git a/tests/specs/coverage/no_files_found/does_not_exist.out b/tests/specs/coverage/no_files_found/does_not_exist.out new file mode 100644 index 000000000..0b679bcb4 --- /dev/null +++ b/tests/specs/coverage/no_files_found/does_not_exist.out @@ -0,0 +1 @@ +error: No coverage files found diff --git a/tests/specs/flags/help_flag/__test__.jsonc b/tests/specs/flags/help_flag/__test__.jsonc new file mode 100644 index 000000000..4cf04538b --- /dev/null +++ b/tests/specs/flags/help_flag/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "--help", + "output": "[WILDCARD]" +} diff --git a/tests/specs/flags/types/__test__.jsonc b/tests/specs/flags/types/__test__.jsonc new file mode 100644 index 000000000..ce0d61d34 --- /dev/null +++ b/tests/specs/flags/types/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "types", + "output": "types.out" +} diff --git a/tests/specs/flags/types/types.out b/tests/specs/flags/types/types.out new file mode 100644 index 000000000..089a9381f --- /dev/null +++ b/tests/specs/flags/types/types.out @@ -0,0 +1,3 @@ +[WILDCARD] +declare namespace Deno [WILDCARD] +declare var window: Window [WILDCARD] diff --git a/tests/specs/flags/version_flag/__test__.jsonc b/tests/specs/flags/version_flag/__test__.jsonc new file mode 100644 index 000000000..e8c3c1646 --- /dev/null +++ b/tests/specs/flags/version_flag/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "steps": [{ + "args": "-V", + "output": "[WILDCARD]" + }, { + "args": "--version", + "output": "[WILDCARD]" + }] +} diff --git a/tests/specs/jsr/deps/__test__.jsonc b/tests/specs/jsr/deps/__test__.jsonc new file mode 100644 index 000000000..2528003b5 --- /dev/null +++ b/tests/specs/jsr/deps/__test__.jsonc @@ -0,0 +1,11 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run main.ts", + "output": "main.out" + }, { + "cleanDenoDir": true, + "args": "info main.ts", + "output": "main_info.out" + }] +} diff --git a/tests/specs/jsr/deps/main.out b/tests/specs/jsr/deps/main.out new file mode 100644 index 000000000..621703c4b --- /dev/null +++ b/tests/specs/jsr/deps/main.out @@ -0,0 +1,13 @@ +Download http://127.0.0.1:4250/@denotest/deps/meta.json +Download http://127.0.0.1:4250/@denotest/deps/1.0.0_meta.json +Download http://127.0.0.1:4250/@denotest/module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1_meta.json +[UNORDERED_START] +Download http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/mod.ts +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/TestClass.ts +[UNORDERED_END] +{ version: "0.1.1", other: Other {} } diff --git a/tests/specs/jsr/deps/main.ts b/tests/specs/jsr/deps/main.ts new file mode 100644 index 000000000..f48255299 --- /dev/null +++ b/tests/specs/jsr/deps/main.ts @@ -0,0 +1,3 @@ +import value from "jsr:@denotest/deps"; + +console.log(value); diff --git a/tests/specs/jsr/deps/main_info.out b/tests/specs/jsr/deps/main_info.out new file mode 100644 index 000000000..c4d412707 --- /dev/null +++ b/tests/specs/jsr/deps/main_info.out @@ -0,0 +1,22 @@ +Download http://127.0.0.1:4250/@denotest/deps/meta.json +Download http://127.0.0.1:4250/@denotest/deps/1.0.0_meta.json +Download http://127.0.0.1:4250/@denotest/module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1_meta.json +[UNORDERED_START] +Download http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/mod.ts +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/TestClass.ts +[UNORDERED_END] +local: [WILDCARD]main.ts +type: TypeScript +dependencies: 4 unique +size: [WILDCARD] + +file:///[WILDCARD]main.ts ([WILDCARD]) +└─┬ http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts ([WILDCARD]) + ├── http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts ([WILDCARD]) + └─┬ http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/mod.ts ([WILDCARD]) + └── http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/TestClass.ts ([WILDCARD]) diff --git a/tests/specs/jsr/import_https_url/__test__.jsonc b/tests/specs/jsr/import_https_url/__test__.jsonc new file mode 100644 index 000000000..597b8e009 --- /dev/null +++ b/tests/specs/jsr/import_https_url/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run -A analyzable.ts", + "output": "analyzable.out", + "exitCode": 1 + }, { + "cleanDenoDir": true, + "args": "run -A nonanalyzable.ts", + "output": "nonanalyzable.out", + "exitCode": 1 + }] +} diff --git a/tests/specs/jsr/import_https_url/analyzable.out b/tests/specs/jsr/import_https_url/analyzable.out new file mode 100644 index 000000000..dd1ca58b4 --- /dev/null +++ b/tests/specs/jsr/import_https_url/analyzable.out @@ -0,0 +1,8 @@ +Download http://127.0.0.1:4250/@denotest/import-https-url/meta.json +Download http://127.0.0.1:4250/@denotest/import-https-url/1.0.0_meta.json +Download http://127.0.0.1:4250/@denotest/import-https-url/1.0.0/analyzable.ts +Download http://localhost:4545/welcome.ts +error: Uncaught (in promise) TypeError: Importing http://localhost:4545/welcome.ts blocked. JSR packages cannot import non-JSR remote modules for security reasons. +await import("http://localhost:4545/welcome.ts"); +^ + at async http://127.0.0.1:4250/@denotest/import-https-url/1.0.0/analyzable.ts:1:1 diff --git a/tests/specs/jsr/import_https_url/analyzable.ts b/tests/specs/jsr/import_https_url/analyzable.ts new file mode 100644 index 000000000..44382867f --- /dev/null +++ b/tests/specs/jsr/import_https_url/analyzable.ts @@ -0,0 +1 @@ +import "jsr:@denotest/import-https-url/analyzable"; diff --git a/tests/specs/jsr/import_https_url/nonanalyzable.out b/tests/specs/jsr/import_https_url/nonanalyzable.out new file mode 100644 index 000000000..4ae04996c --- /dev/null +++ b/tests/specs/jsr/import_https_url/nonanalyzable.out @@ -0,0 +1,7 @@ +Download http://127.0.0.1:4250/@denotest/import-https-url/meta.json +Download http://127.0.0.1:4250/@denotest/import-https-url/1.0.0_meta.json +Download http://127.0.0.1:4250/@denotest/import-https-url/1.0.0/unanalyzable.ts +error: Uncaught (in promise) TypeError: Importing http://localhost:4545/welcome.ts blocked. JSR packages cannot import non-JSR remote modules for security reasons. +await import(nonAnalyzableUrl()); +^ + at async http://127.0.0.1:4250/@denotest/import-https-url/1.0.0/unanalyzable.ts:5:1 diff --git a/tests/specs/jsr/import_https_url/nonanalyzable.ts b/tests/specs/jsr/import_https_url/nonanalyzable.ts new file mode 100644 index 000000000..87ccdcfdc --- /dev/null +++ b/tests/specs/jsr/import_https_url/nonanalyzable.ts @@ -0,0 +1 @@ +import "jsr:@denotest/import-https-url/unanalyzable"; diff --git a/tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc b/tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc new file mode 100644 index 000000000..c2a269ea6 --- /dev/null +++ b/tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "base": "jsr", + "args": "run main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/jsr/jsx_with_no_pragmas/main.out b/tests/specs/jsr/jsx_with_no_pragmas/main.out new file mode 100644 index 000000000..c3977fe22 --- /dev/null +++ b/tests/specs/jsr/jsx_with_no_pragmas/main.out @@ -0,0 +1,7 @@ +Download [WILDCARD] +error: Uncaught (in promise) ReferenceError: React is not defined + return renderToString(<div>foo.jsx</div>); + ^ + at render (http://127.0.0.1:4250/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx:4:25) + at render (http://127.0.0.1:4250/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts:5:15) + at file:///[WILDCARD]/jsr/jsx_with_no_pragmas/main.ts:3:1 diff --git a/tests/specs/jsr/jsx_with_no_pragmas/main.ts b/tests/specs/jsr/jsx_with_no_pragmas/main.ts new file mode 100644 index 000000000..9d6e5a41e --- /dev/null +++ b/tests/specs/jsr/jsx_with_no_pragmas/main.ts @@ -0,0 +1,3 @@ +import { render } from "jsr:@denotest/jsx-with-no-pragmas@1.0.0"; + +render(); diff --git a/tests/specs/jsr/jsx_with_pragmas/__test__.jsonc b/tests/specs/jsr/jsx_with_pragmas/__test__.jsonc new file mode 100644 index 000000000..a6fa5c7c3 --- /dev/null +++ b/tests/specs/jsr/jsx_with_pragmas/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "base": "jsr", + "args": "run main.ts", + "output": "main.out" +} diff --git a/tests/specs/jsr/jsx_with_pragmas/main.out b/tests/specs/jsr/jsx_with_pragmas/main.out new file mode 100644 index 000000000..c149ba010 --- /dev/null +++ b/tests/specs/jsr/jsx_with_pragmas/main.out @@ -0,0 +1,3 @@ +Download [WILDCARD] +<div>foo.jsx</div> +<div>foo.tsx</div> diff --git a/tests/specs/jsr/jsx_with_pragmas/main.ts b/tests/specs/jsr/jsx_with_pragmas/main.ts new file mode 100644 index 000000000..4a38c56ad --- /dev/null +++ b/tests/specs/jsr/jsx_with_pragmas/main.ts @@ -0,0 +1,3 @@ +import { render } from "jsr:@denotest/jsx-with-pragmas@1.0.0"; + +render(); diff --git a/tests/specs/jsr/module_graph/__test__.jsonc b/tests/specs/jsr/module_graph/__test__.jsonc new file mode 100644 index 000000000..2528003b5 --- /dev/null +++ b/tests/specs/jsr/module_graph/__test__.jsonc @@ -0,0 +1,11 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run main.ts", + "output": "main.out" + }, { + "cleanDenoDir": true, + "args": "info main.ts", + "output": "main_info.out" + }] +} diff --git a/tests/specs/jsr/module_graph/main.out b/tests/specs/jsr/module_graph/main.out new file mode 100644 index 000000000..1cd0115b9 --- /dev/null +++ b/tests/specs/jsr/module_graph/main.out @@ -0,0 +1,7 @@ +Download http://127.0.0.1:4250/@denotest/module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json +[UNORDERED_START] +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/mod.ts +[UNORDERED_END] +Test { other: Other {} } diff --git a/tests/specs/jsr/module_graph/main.ts b/tests/specs/jsr/module_graph/main.ts new file mode 100644 index 000000000..c92823cc2 --- /dev/null +++ b/tests/specs/jsr/module_graph/main.ts @@ -0,0 +1,3 @@ +import { Test } from "jsr:@denotest/module_graph"; + +console.log(new Test()); diff --git a/tests/specs/jsr/module_graph/main_info.out b/tests/specs/jsr/module_graph/main_info.out new file mode 100644 index 000000000..c35cca5b4 --- /dev/null +++ b/tests/specs/jsr/module_graph/main_info.out @@ -0,0 +1,14 @@ +Download http://127.0.0.1:4250/@denotest/module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json +[UNORDERED_START] +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/mod.ts +Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts +[UNORDERED_END] +local: [WILDCARD]main.ts +type: TypeScript +dependencies: 2 unique +size: [WILDCARD] + +file:///[WILDCARD]/module_graph/main.ts ([WILDCARD]) +└─┬ http://127.0.0.1:4250/@denotest/module_graph/1.4.0/mod.ts ([WILDCARD]) + └── http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts ([WILDCARD]) diff --git a/tests/specs/jsr/no_module_graph/__test__.jsonc b/tests/specs/jsr/no_module_graph/__test__.jsonc new file mode 100644 index 000000000..b3915ecef --- /dev/null +++ b/tests/specs/jsr/no_module_graph/__test__.jsonc @@ -0,0 +1,14 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run main.ts", + "output": "main.out" + }, { + "cleanDenoDir": true, + "args": "info main.ts", + "output": "main_info.out" + }, { + "args": "run --quiet multiple.ts", + "output": "multiple.out" + }] +} diff --git a/tests/specs/jsr/no_module_graph/main.out b/tests/specs/jsr/no_module_graph/main.out new file mode 100644 index 000000000..da9b67e11 --- /dev/null +++ b/tests/specs/jsr/no_module_graph/main.out @@ -0,0 +1,6 @@ +Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0_meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/mod.ts +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/TestClass.ts +0.1.0 +TestClass {} diff --git a/tests/specs/jsr/no_module_graph/main.ts b/tests/specs/jsr/no_module_graph/main.ts new file mode 100644 index 000000000..6ea030c59 --- /dev/null +++ b/tests/specs/jsr/no_module_graph/main.ts @@ -0,0 +1,4 @@ +import version, { TestClass } from "jsr:@denotest/no_module_graph@0.1.0"; + +console.log(version); +console.log(new TestClass()); diff --git a/tests/specs/jsr/no_module_graph/main_info.out b/tests/specs/jsr/no_module_graph/main_info.out new file mode 100644 index 000000000..0293e4120 --- /dev/null +++ b/tests/specs/jsr/no_module_graph/main_info.out @@ -0,0 +1,12 @@ +Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0_meta.json +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/mod.ts +Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/TestClass.ts +local: [WILDCARD]main.ts +type: TypeScript +dependencies: 2 unique +size: [WILDCARD] + +file:///[WILDCARD]/jsr/no_module_graph/main.ts ([WILDCARD]) +└─┬ http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/mod.ts ([WILDCARD]) + └── http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/TestClass.ts ([WILDCARD]) diff --git a/tests/specs/jsr/no_module_graph/multiple.out b/tests/specs/jsr/no_module_graph/multiple.out new file mode 100644 index 000000000..8146276d0 --- /dev/null +++ b/tests/specs/jsr/no_module_graph/multiple.out @@ -0,0 +1,2 @@ +0.1.0 +0.2.0 diff --git a/tests/specs/jsr/no_module_graph/multiple.ts b/tests/specs/jsr/no_module_graph/multiple.ts new file mode 100644 index 000000000..660ed8be6 --- /dev/null +++ b/tests/specs/jsr/no_module_graph/multiple.ts @@ -0,0 +1,5 @@ +import version1 from "jsr:@denotest/no_module_graph@0.1.0"; +import version2 from "jsr:@denotest/no_module_graph@^0.2"; + +console.log(version1); +console.log(version2); diff --git a/tests/specs/jsr/subset_type_graph/__test__.jsonc b/tests/specs/jsr/subset_type_graph/__test__.jsonc new file mode 100644 index 000000000..85d04ed54 --- /dev/null +++ b/tests/specs/jsr/subset_type_graph/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "base": "jsr", + "args": "check --all main.ts", + "output": "main.check.out", + "exitCode": 1 +} diff --git a/tests/specs/jsr/subset_type_graph/main.check.out b/tests/specs/jsr/subset_type_graph/main.check.out new file mode 100644 index 000000000..f46610c0a --- /dev/null +++ b/tests/specs/jsr/subset_type_graph/main.check.out @@ -0,0 +1,45 @@ +Download http://127.0.0.1:4250/@denotest/subset-type-graph/meta.json +Download http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/meta.json +Download http://127.0.0.1:4250/@denotest/subset-type-graph/0.1.0_meta.json +Download http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0_meta.json +[UNORDERED_START] +Download http://127.0.0.1:4250/@denotest/subset-type-graph/0.1.0/mod.ts +Download http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0/mod.ts +[UNORDERED_END] +Check file:///[WILDCARD]/subset_type_graph/main.ts +error: TS2322 [ERROR]: Type 'string' is not assignable to type 'number'. +const invalidTypeCheck: number = ""; + ~~~~~~~~~~~~~~~~ + at http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0/mod.ts:11:7 + +TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const error1: string = new Foo1().method(); + ~~~~~~ + at file:///[WILDCARD]/subset_type_graph/main.ts:5:7 + +TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const error2: string = new Foo2().method(); + ~~~~~~ + at file:///[WILDCARD]/subset_type_graph/main.ts:6:7 + +TS2551 [ERROR]: Property 'method2' does not exist on type 'Foo'. Did you mean 'method'? +new Foo1().method2(); + ~~~~~~~ + at file:///[WILDCARD]/subset_type_graph/main.ts:12:12 + + 'method' is declared here. + method(): number { + ~~~~~~ + at http://127.0.0.1:4250/@denotest/subset-type-graph/0.1.0/mod.ts:8:3 + +TS2551 [ERROR]: Property 'method2' does not exist on type 'Foo'. Did you mean 'method'? +new Foo2().method2(); + ~~~~~~~ + at file:///[WILDCARD]/subset_type_graph/main.ts:13:12 + + 'method' is declared here. + method() { + ~~~~~~ + at http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0/mod.ts:2:3 + +Found 5 errors. diff --git a/tests/specs/jsr/subset_type_graph/main.ts b/tests/specs/jsr/subset_type_graph/main.ts new file mode 100644 index 000000000..2fff966a7 --- /dev/null +++ b/tests/specs/jsr/subset_type_graph/main.ts @@ -0,0 +1,13 @@ +import { Foo as Foo1 } from "jsr:@denotest/subset-type-graph@0.1.0"; +import { Foo as Foo2 } from "jsr:@denotest/subset-type-graph-invalid@0.1.0"; + +// these will both raise type checking errors +const error1: string = new Foo1().method(); +const error2: string = new Foo2().method(); +console.log(error1); +console.log(error2); + +// now raise some errors that will show the original code and +// these should source map to the original +new Foo1().method2(); +new Foo2().method2(); diff --git a/tests/specs/jsr/version_not_found/__test__.jsonc b/tests/specs/jsr/version_not_found/__test__.jsonc new file mode 100644 index 000000000..36335985f --- /dev/null +++ b/tests/specs/jsr/version_not_found/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "base": "jsr", + "args": "run -A main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/jsr/version_not_found/main.out b/tests/specs/jsr/version_not_found/main.out new file mode 100644 index 000000000..6a32b5d81 --- /dev/null +++ b/tests/specs/jsr/version_not_found/main.out @@ -0,0 +1,5 @@ +Download http://127.0.0.1:4250/@denotest/deps/meta.json +Download http://127.0.0.1:4250/@denotest/deps/meta.json +error: Could not find constraint in the list of versions: @denotest/deps@0.1.4 + Specifier: jsr:@denotest/deps@0.1.4/mod.ts + at file:///[WILDCARD]/version_not_found/main.ts:1:19 diff --git a/tests/specs/jsr/version_not_found/main.ts b/tests/specs/jsr/version_not_found/main.ts new file mode 100644 index 000000000..a7673b744 --- /dev/null +++ b/tests/specs/jsr/version_not_found/main.ts @@ -0,0 +1,2 @@ +import value from "jsr:@denotest/deps@0.1.4/mod.ts"; +console.log(value); diff --git a/tests/specs/jupyter/install_command_not_exists/__test__.jsonc b/tests/specs/jupyter/install_command_not_exists/__test__.jsonc new file mode 100644 index 000000000..9552157bd --- /dev/null +++ b/tests/specs/jupyter/install_command_not_exists/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "jupyter --install", + "output": "install_command_not_exists.out", + "envs": { + "PATH": "" + }, + "exitCode": 1 +} diff --git a/tests/specs/jupyter/install_command_not_exists/install_command_not_exists.out b/tests/specs/jupyter/install_command_not_exists/install_command_not_exists.out new file mode 100644 index 000000000..1bb176e20 --- /dev/null +++ b/tests/specs/jupyter/install_command_not_exists/install_command_not_exists.out @@ -0,0 +1,5 @@ +Warning "deno jupyter" is unstable and might change in the future. +error: Failed to spawn 'jupyter' command. Is JupyterLab installed (https://jupyter.org/install) and available on the PATH? + +Caused by: +[WILDCARD] diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index d010de43d..feed09871 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use std::cell::RefCell; +use std::collections::HashMap; use std::collections::HashSet; use std::panic::AssertUnwindSafe; use std::rc::Rc; @@ -127,15 +128,13 @@ fn run_test(test: &Test, diagnostic_logger: Rc<RefCell<Vec<u8>>>) { context.deno_dir().path().remove_dir_all(); } - let test_output_path = cwd.join(&step.output); - if !test_output_path.to_string_lossy().ends_with(".out") { - panic!( - "Use the .out extension for output files (invalid: {})", - test_output_path - ); - } - let expected_output = test_output_path.read_to_string(); - let command = context.new_command(); + let expected_output = if step.output.ends_with(".out") { + let test_output_path = cwd.join(&step.output); + test_output_path.read_to_string() + } else { + step.output.clone() + }; + let command = context.new_command().envs(&step.envs); let command = match &step.args { VecOrString::Vec(args) => command.args_vec(args), VecOrString::String(text) => command.args(text), @@ -195,6 +194,8 @@ struct StepMetaData { #[serde(default)] pub clean_deno_dir: bool, pub args: VecOrString, + #[serde(default)] + pub envs: HashMap<String, String>, pub output: String, #[serde(default)] pub exit_code: i32, @@ -283,14 +284,6 @@ fn collect_tests() -> Vec<TestCategory> { let test_dir = PathRef::new(entry.path()); 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 |