summaryrefslogtreecommitdiff
path: root/tests/specs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/specs')
-rw-r--r--tests/specs/README.md4
-rw-r--r--tests/specs/lint/no_slow_types/no_slow_types.out3
-rw-r--r--tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out3
-rw-r--r--tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out3
-rw-r--r--tests/specs/lint/no_slow_types_workspace/output.out4
-rw-r--r--tests/specs/mod.rs36
-rw-r--r--tests/specs/npm/workers/__test__.jsonc5
-rw-r--r--tests/specs/npm/workers/main.out5
-rw-r--r--tests/specs/npm/workers/main.ts9
-rw-r--r--tests/specs/npm/workers/worker1.ts9
-rw-r--r--tests/specs/npm/workers/worker2.ts6
-rw-r--r--tests/specs/npm/workers/worker3.ts6
-rw-r--r--tests/specs/publish/banned_triple_slash_directives/publish.out2
-rw-r--r--tests/specs/publish/has_slow_types/has_slow_types.out1
-rw-r--r--tests/specs/publish/invalid_import/invalid_import.out2
-rw-r--r--tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out2
-rw-r--r--tests/specs/publish/missing_constraint/publish.out3
-rw-r--r--tests/specs/publish/prefer_fast_check_graph/main.out1
-rw-r--r--tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out1
-rw-r--r--tests/specs/schema.json6
20 files changed, 101 insertions, 10 deletions
diff --git a/tests/specs/README.md b/tests/specs/README.md
index 61fa60f53..bd3430f05 100644
--- a/tests/specs/README.md
+++ b/tests/specs/README.md
@@ -76,9 +76,7 @@ Or if you want to run several tests at the same time:
### Top level properties
-- `base` - The base config to use for the test. Options:
- - `jsr` - Uses env vars for jsr.
- - `npm` - Uses env vars for npm.
+- `repeat` (number) - Number of times to repeat a test.
- `tempDir` (boolean) - Copy all the non-test files to a temporary directory and
execute the command in that temporary directory.
- By default, tests are executed with a current working directory of the test,
diff --git a/tests/specs/lint/no_slow_types/no_slow_types.out b/tests/specs/lint/no_slow_types/no_slow_types.out
index 5828906e7..1093d032c 100644
--- a/tests/specs/lint/no_slow_types/no_slow_types.out
+++ b/tests/specs/lint/no_slow_types/no_slow_types.out
@@ -3,6 +3,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function add(a: number, b: number) {
| ^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -14,6 +15,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function addB(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -25,6 +27,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
2 | export function addD(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
diff --git a/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out b/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out
index b8c1013bf..895dcb6cd 100644
--- a/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out
+++ b/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out
@@ -3,6 +3,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function add(a: number, b: number) {
| ^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -14,6 +15,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function addB(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -25,6 +27,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
2 | export function addD(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
diff --git a/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out
index b8c1013bf..895dcb6cd 100644
--- a/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out
+++ b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out
@@ -3,6 +3,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function add(a: number, b: number) {
| ^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -14,6 +15,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function addB(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -25,6 +27,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
2 | export function addD(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
diff --git a/tests/specs/lint/no_slow_types_workspace/output.out b/tests/specs/lint/no_slow_types_workspace/output.out
index 05f54099b..1f19fbab8 100644
--- a/tests/specs/lint/no_slow_types_workspace/output.out
+++ b/tests/specs/lint/no_slow_types_workspace/output.out
@@ -3,6 +3,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function addB(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -14,6 +15,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
2 | export function addD(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -25,6 +27,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
1 | export function add(a: number, b: number) {
| ^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
@@ -36,6 +39,7 @@ error[no-slow-types]: missing explicit return type in the public API
|
2 | export function addC(a: number, b: number) {
| ^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs
index a153322db..3a52ab29e 100644
--- a/tests/specs/mod.rs
+++ b/tests/specs/mod.rs
@@ -17,6 +17,7 @@ use file_test_runner::collection::CollectTestsError;
use file_test_runner::collection::CollectedCategoryOrTest;
use file_test_runner::collection::CollectedTest;
use file_test_runner::collection::CollectedTestCategory;
+use file_test_runner::SubTestResult;
use file_test_runner::TestResult;
use serde::Deserialize;
use test_util::tests_path;
@@ -109,6 +110,8 @@ struct MultiStepMetaData {
#[serde(default)]
pub envs: HashMap<String, String>,
#[serde(default)]
+ pub repeat: Option<usize>,
+ #[serde(default)]
pub steps: Vec<StepMetaData>,
}
@@ -119,6 +122,8 @@ struct SingleTestMetaData {
pub base: Option<String>,
#[serde(default)]
pub temp_dir: bool,
+ #[serde(default)]
+ pub repeat: Option<usize>,
#[serde(flatten)]
pub step: StepMetaData,
}
@@ -128,6 +133,7 @@ impl SingleTestMetaData {
MultiStepMetaData {
base: self.base,
temp_dir: self.temp_dir,
+ repeat: self.repeat,
envs: Default::default(),
steps: vec![self.step],
}
@@ -213,8 +219,26 @@ fn run_test(test: &CollectedTest<serde_json::Value>) -> TestResult {
let cwd = PathRef::new(&test.path).parent();
let metadata_value = test.data.clone();
let diagnostic_logger = Rc::new(RefCell::new(Vec::<u8>::new()));
- let result = TestResult::from_maybe_panic(AssertUnwindSafe(|| {
- run_test_inner(metadata_value, &cwd, diagnostic_logger.clone())
+ let result = TestResult::from_maybe_panic_or_result(AssertUnwindSafe(|| {
+ let metadata = deserialize_value(metadata_value);
+ if let Some(repeat) = metadata.repeat {
+ TestResult::SubTests(
+ (0..repeat)
+ .map(|i| {
+ let diagnostic_logger = diagnostic_logger.clone();
+ SubTestResult {
+ name: format!("run {}", i + 1),
+ result: TestResult::from_maybe_panic(AssertUnwindSafe(|| {
+ run_test_inner(&metadata, &cwd, diagnostic_logger);
+ })),
+ }
+ })
+ .collect(),
+ )
+ } else {
+ run_test_inner(&metadata, &cwd, diagnostic_logger.clone());
+ TestResult::Passed
+ }
}));
match result {
TestResult::Failed {
@@ -232,15 +256,13 @@ fn run_test(test: &CollectedTest<serde_json::Value>) -> TestResult {
}
fn run_test_inner(
- metadata_value: serde_json::Value,
+ metadata: &MultiStepMetaData,
cwd: &PathRef,
diagnostic_logger: Rc<RefCell<Vec<u8>>>,
) {
- let metadata = deserialize_value(metadata_value);
-
- let context = test_context_from_metadata(&metadata, cwd, diagnostic_logger);
+ let context = test_context_from_metadata(metadata, cwd, diagnostic_logger);
for step in metadata.steps.iter().filter(|s| should_run_step(s)) {
- let run_func = || run_step(step, &metadata, cwd, &context);
+ let run_func = || run_step(step, metadata, cwd, &context);
if step.flaky {
run_flaky(run_func);
} else {
diff --git a/tests/specs/npm/workers/__test__.jsonc b/tests/specs/npm/workers/__test__.jsonc
new file mode 100644
index 000000000..f2066c17f
--- /dev/null
+++ b/tests/specs/npm/workers/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "tempDir": true,
+ "args": "run -A --quiet --lock=deno.lock main.ts",
+ "output": "main.out"
+}
diff --git a/tests/specs/npm/workers/main.out b/tests/specs/npm/workers/main.out
new file mode 100644
index 000000000..55ff51cd3
--- /dev/null
+++ b/tests/specs/npm/workers/main.out
@@ -0,0 +1,5 @@
+[UNORDERED_START]
+1
+2
+3
+[UNORDERED_END]
diff --git a/tests/specs/npm/workers/main.ts b/tests/specs/npm/workers/main.ts
new file mode 100644
index 000000000..f51cf4d90
--- /dev/null
+++ b/tests/specs/npm/workers/main.ts
@@ -0,0 +1,9 @@
+new Worker(new URL("./worker1.ts", import.meta.url), {
+ type: "module",
+});
+new Worker(new URL("./worker2.ts", import.meta.url), {
+ type: "module",
+});
+new Worker(new URL("./worker3.ts", import.meta.url), {
+ type: "module",
+});
diff --git a/tests/specs/npm/workers/worker1.ts b/tests/specs/npm/workers/worker1.ts
new file mode 100644
index 000000000..1cdc91d56
--- /dev/null
+++ b/tests/specs/npm/workers/worker1.ts
@@ -0,0 +1,9 @@
+import "npm:chalk@4";
+import "npm:react@18.2";
+import "npm:preact@10.19";
+import "npm:ajv";
+import "npm:has";
+import "npm:picocolors";
+
+console.log(1);
+self.close();
diff --git a/tests/specs/npm/workers/worker2.ts b/tests/specs/npm/workers/worker2.ts
new file mode 100644
index 000000000..2495ebacc
--- /dev/null
+++ b/tests/specs/npm/workers/worker2.ts
@@ -0,0 +1,6 @@
+import "npm:@denotest/esm-basic";
+import "npm:@denotest/add";
+import "npm:@denotest/subtract";
+
+console.log(2);
+self.close();
diff --git a/tests/specs/npm/workers/worker3.ts b/tests/specs/npm/workers/worker3.ts
new file mode 100644
index 000000000..ae18d6aa9
--- /dev/null
+++ b/tests/specs/npm/workers/worker3.ts
@@ -0,0 +1,6 @@
+import "npm:@denotest/subtract";
+import "npm:@denotest/add";
+import "npm:@denotest/esm-basic";
+
+console.log(3);
+self.close();
diff --git a/tests/specs/publish/banned_triple_slash_directives/publish.out b/tests/specs/publish/banned_triple_slash_directives/publish.out
index a67736bc2..f1827538a 100644
--- a/tests/specs/publish/banned_triple_slash_directives/publish.out
+++ b/tests/specs/publish/banned_triple_slash_directives/publish.out
@@ -6,6 +6,7 @@ error[banned-triple-slash-directives]: triple slash directives that modify globa
|
1 | /// <reference lib="deno.ns" />
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the triple slash directive
+ |
= hint: remove the triple slash directive
info: instead instruct the user of your package to specify these directives
@@ -17,6 +18,7 @@ error[banned-triple-slash-directives]: triple slash directives that modify globa
|
2 | /// <reference no-default-lib="true" />
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the triple slash directive
+ |
= hint: remove the triple slash directive
info: instead instruct the user of your package to specify these directives
diff --git a/tests/specs/publish/has_slow_types/has_slow_types.out b/tests/specs/publish/has_slow_types/has_slow_types.out
index 43ac86658..b77134902 100644
--- a/tests/specs/publish/has_slow_types/has_slow_types.out
+++ b/tests/specs/publish/has_slow_types/has_slow_types.out
@@ -5,6 +5,7 @@ error[missing-explicit-return-type]: missing explicit return type in the public
|
2 | export function getRandom() {
| ^^^^^^^^^ this function is missing an explicit return type
+ |
= hint: add an explicit return type to the function
info: all functions in the public API must have an explicit return type
diff --git a/tests/specs/publish/invalid_import/invalid_import.out b/tests/specs/publish/invalid_import/invalid_import.out
index 1f95290dc..929fc72cd 100644
--- a/tests/specs/publish/invalid_import/invalid_import.out
+++ b/tests/specs/publish/invalid_import/invalid_import.out
@@ -10,6 +10,7 @@ error[invalid-external-import]: invalid import to a non-JSR 'http' specifier
|
1 | import "http://localhost:4545/welcome.ts";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the specifier
+ |
= hint: replace this import with one from jsr or npm, or vendor the dependency into your package
info: the import was resolved to 'http://localhost:4545/welcome.ts'
@@ -22,6 +23,7 @@ error[invalid-external-import]: invalid import to a non-JSR 'http' specifier
|
2 | import "$echo";
| ^^^^^^^ the specifier
+ |
= hint: replace this import with one from jsr or npm, or vendor the dependency into your package
info: the import was resolved to 'http://localhost:4545/echo.ts'
diff --git a/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out b/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out
index a014f3de6..a7235cbf1 100644
--- a/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out
+++ b/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out
@@ -7,10 +7,12 @@ error[invalid-external-import]: invalid import to a non-JSR 'http' specifier
|
1 | import "http://esm.sh/react-dom@18.2.0/server";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the specifier
+ |
= hint: replace this import with one from jsr or npm, or vendor the dependency into your package
|
1 | "npm:react-dom@18.2.0"
| ---------------------- try this specifier
+ |
info: the import was resolved to 'http://esm.sh/react-dom@18.2.0/server'
info: this specifier is not allowed to be imported on jsr
diff --git a/tests/specs/publish/missing_constraint/publish.out b/tests/specs/publish/missing_constraint/publish.out
index 846612979..601035b05 100644
--- a/tests/specs/publish/missing_constraint/publish.out
+++ b/tests/specs/publish/missing_constraint/publish.out
@@ -6,6 +6,7 @@ error[missing-constraint]: specifier 'jsr:@denotest/add' is missing a version co
|
1 | import { add } from "add";
| ^^^^^ the specifier
+ |
= hint: specify a version constraint for the specifier in the import map
info: the specifier resolved to version 1.0.0 today, but will resolve to a different
@@ -17,6 +18,7 @@ error[missing-constraint]: specifier 'npm:@denotest/esm-basic' is missing a vers
|
2 | import * as basic from "basic";
| ^^^^^^^ the specifier
+ |
= hint: specify a version constraint for the specifier in the import map
info: the specifier resolved to version 1.0.0 today, but will resolve to a different
@@ -28,6 +30,7 @@ error[missing-constraint]: specifier 'jsr:@denotest/deps' is missing a version c
|
3 | import * as deps from "jsr:@denotest/deps";
| ^^^^^^^^^^^^^^^^^^^^ the specifier
+ |
= hint: specify a version constraint for the specifier
info: the specifier resolved to version 1.0.0 today, but will resolve to a different
diff --git a/tests/specs/publish/prefer_fast_check_graph/main.out b/tests/specs/publish/prefer_fast_check_graph/main.out
index a68fac83a..6c68dde8a 100644
--- a/tests/specs/publish/prefer_fast_check_graph/main.out
+++ b/tests/specs/publish/prefer_fast_check_graph/main.out
@@ -7,6 +7,7 @@ error[invalid-external-import]: invalid import to a non-JSR 'https' specifier
|
1 | export * from "https://deno.land/std/assert/assert.ts";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the specifier
+ |
= hint: replace this import with one from jsr or npm, or vendor the dependency into your package
info: the import was resolved to 'https://deno.land/std/assert/assert.ts'
diff --git a/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out b/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out
index 7f3ca5555..af92d46b9 100644
--- a/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out
+++ b/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out
@@ -6,6 +6,7 @@ warning[unanalyzable-dynamic-import]: unable to analyze dynamic import
|
2 | await import("asd " + asd);
| ^^^^^^^^^^^^ the unanalyzable dynamic import
+ |
info: after publishing this package, imports from the local import map / package.json do not work
info: dynamic imports that can not be analyzed at publish time will not be rewritten automatically
diff --git a/tests/specs/schema.json b/tests/specs/schema.json
index 0edfb4507..d41babd19 100644
--- a/tests/specs/schema.json
+++ b/tests/specs/schema.json
@@ -69,6 +69,9 @@
"type": "string"
}
},
+ "repeat": {
+ "type": "number"
+ },
"steps": {
"type": "array",
"items": {
@@ -112,6 +115,9 @@
"type": "string"
}
},
+ "repeat": {
+ "type": "number"
+ },
"tests": {
"type": "object",
"additionalProperties": {