From 998d9061ef05b3868d2ea5523317c94176498730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 24 Nov 2023 20:56:05 +0100 Subject: [PATCH] chore: deflake unit_node/crypto/crypto_key_test.ts (#21331) Ref https://github.com/denoland/deno/issues/21187 On CI we are going to run only fast tests, with an option to pass `SLOW_TESTS=1` env var to enable more comprehensive tests. --- cli/tests/unit_node/crypto/crypto_key_test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cli/tests/unit_node/crypto/crypto_key_test.ts b/cli/tests/unit_node/crypto/crypto_key_test.ts index 0e56d82550..e59874d7a5 100644 --- a/cli/tests/unit_node/crypto/crypto_key_test.ts +++ b/cli/tests/unit_node/crypto/crypto_key_test.ts @@ -17,6 +17,8 @@ import { } from "../../../../test_util/std/testing/asserts.ts"; import { createHmac } from "node:crypto"; +const RUN_SLOW_TESTS = Deno.env.get("SLOW_TESTS") === "1"; + const generateKeyPairAsync = promisify( ( type: any, @@ -77,10 +79,12 @@ Deno.test({ }, }); +const modulusLengths = RUN_SLOW_TESTS ? [2048, 3072] : [2048]; + for (const type of ["rsa", "rsa-pss", "dsa"]) { - for (const modulusLength of [2048, 3072]) { + for (const modulusLength of modulusLengths) { Deno.test({ - name: `generate ${type} key`, + name: `generate ${type} key ${modulusLength}`, fn() { const { publicKey, privateKey } = generateKeyPairSync(type as any, { modulusLength, @@ -92,7 +96,7 @@ for (const type of ["rsa", "rsa-pss", "dsa"]) { }); Deno.test({ - name: `generate ${type} key async`, + name: `generate ${type} key async ${modulusLength}`, async fn() { const x = await generateKeyPairAsync(type as any, { modulusLength, @@ -174,7 +178,9 @@ for ( }); } -for (const primeLength of [1024, 2048, 4096]) { +const primeLengths = RUN_SLOW_TESTS ? [1024, 2048, 4096] : [1024]; + +for (const primeLength of primeLengths) { Deno.test({ name: `generate dh key ${primeLength}`, fn() {