aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/web-globals.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-19 22:35:16 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-19 22:35:16 -0800
commitbea44d948ec818408c609fffd4a516790ce57f55 (patch)
treeff3a94308d34a88c624b86988a7790b2b6d56d36 /test/bun.js/web-globals.test.js
parentb230e7a73a78e67533cba0d852cefdbbd787eae9 (diff)
downloadbun-bea44d948ec818408c609fffd4a516790ce57f55.tar.gz
bun-bea44d948ec818408c609fffd4a516790ce57f55.tar.zst
bun-bea44d948ec818408c609fffd4a516790ce57f55.zip
Fix freezing test due to calling GC 36,000 times
Diffstat (limited to 'test/bun.js/web-globals.test.js')
-rw-r--r--test/bun.js/web-globals.test.js35
1 files changed, 21 insertions, 14 deletions
diff --git a/test/bun.js/web-globals.test.js b/test/bun.js/web-globals.test.js
index 2f966aa03..06bb1cb67 100644
--- a/test/bun.js/web-globals.test.js
+++ b/test/bun.js/web-globals.test.js
@@ -1,4 +1,6 @@
+import { unsafe } from "bun";
import { expect, it, test } from "bun:test";
+import { withoutAggressiveGC } from "gc";
test("exists", () => {
expect(typeof URL !== "undefined").toBe(true);
@@ -58,11 +60,14 @@ it("crypto.getRandomValues", () => {
);
}
- // run it again to check that the fast path works
- for (var i = 0; i < 9000; i++) {
- var array = crypto.getRandomValues(foo);
- expect(array).toBe(foo);
- }
+ // disable it for this block because it tends to get stuck here running the GC forever
+ withoutAggressiveGC(() => {
+ // run it again to check that the fast path works
+ for (var i = 0; i < 9000; i++) {
+ var array = crypto.getRandomValues(foo);
+ expect(array).toBe(foo);
+ }
+ });
// run it on a large input
expect(
@@ -87,15 +92,17 @@ it("crypto.randomUUID", () => {
expect(uuid[18]).toBe("-");
expect(uuid[23]).toBe("-");
- // check that the fast path works
- for (let i = 0; i < 9000; i++) {
- var uuid2 = crypto.randomUUID();
- expect(uuid2.length).toBe(36);
- expect(uuid2[8]).toBe("-");
- expect(uuid2[13]).toBe("-");
- expect(uuid2[18]).toBe("-");
- expect(uuid2[23]).toBe("-");
- }
+ withoutAggressiveGC(() => {
+ // check that the fast path works
+ for (let i = 0; i < 9000; i++) {
+ var uuid2 = crypto.randomUUID();
+ expect(uuid2.length).toBe(36);
+ expect(uuid2[8]).toBe("-");
+ expect(uuid2[13]).toBe("-");
+ expect(uuid2[18]).toBe("-");
+ expect(uuid2[23]).toBe("-");
+ }
+ });
});
it("URL.prototype.origin", () => {