summaryrefslogtreecommitdiff
path: root/cli/tests/testdata
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-24 14:42:45 -0500
committerGitHub <noreply@github.com>2023-02-24 14:42:45 -0500
commit9aebc8bc19b1dfd9bce1789018f3f6b784175171 (patch)
tree760daa99df7479e34195a4339401a3f8f55c450e /cli/tests/testdata
parenta27d0885f489f5640e38922fad8c8a1c49ae0aa4 (diff)
fix: ensure concurrent non-statically analyzable dynamic imports do not sometimes fail (#17923)
Closes #17918
Diffstat (limited to 'cli/tests/testdata')
-rw-r--r--cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.out100
-rw-r--r--cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.ts16
-rw-r--r--cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/mod.ts7
3 files changed, 123 insertions, 0 deletions
diff --git a/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.out b/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.out
new file mode 100644
index 000000000..c344d0aae
--- /dev/null
+++ b/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.out
@@ -0,0 +1,100 @@
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
diff --git a/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.ts b/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.ts
new file mode 100644
index 000000000..0832e40be
--- /dev/null
+++ b/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.ts
@@ -0,0 +1,16 @@
+import * as path from "http://localhost:4545/deno_std/path/mod.ts";
+
+const currentDir = path.dirname(path.fromFileUrl(import.meta.url));
+const url = path.toFileUrl(path.join(currentDir, "./mod.ts"));
+const urls = [];
+
+// this is hard to reproduce, but doing this will help
+for (let i = 0; i < 100; i++) {
+ urls.push(url.toString() + "#" + i);
+}
+
+const results = await Promise.all(urls.map((url) => import(url)));
+
+for (const result of results) {
+ result.outputValue();
+}
diff --git a/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/mod.ts b/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/mod.ts
new file mode 100644
index 000000000..56f2002ed
--- /dev/null
+++ b/cli/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/mod.ts
@@ -0,0 +1,7 @@
+// sleep a bit so many concurrent tasks end up
+// attempting to build the graph at the same time
+import "http://localhost:4545/sleep/10";
+
+export function outputValue() {
+ console.log(parseInt(new URL(import.meta.url).hash.slice(1), 10));
+}