From c1a8ae38c0f787ff58c0873fb85a422569ad55bb Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 18 Oct 2023 17:18:26 +0200 Subject: [PATCH] test: deflake `test-loaders-workers-spawned` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/50251 Backport-PR-URL: https://github.com/nodejs/node/pull/50669 Fixes: https://github.com/nodejs/node/issues/50247 Reviewed-By: Yagiz Nizipli Reviewed-By: Vinícius Lourenço Claro Cardoso Reviewed-By: Luigi Pinca --- test/es-module/test-loaders-workers-spawned.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/es-module/test-loaders-workers-spawned.mjs b/test/es-module/test-loaders-workers-spawned.mjs index a04d8edb041e36..bcd651f5ad6c3f 100644 --- a/test/es-module/test-loaders-workers-spawned.mjs +++ b/test/es-module/test-loaders-workers-spawned.mjs @@ -48,8 +48,14 @@ describe('Worker threads do not spawn infinitely', { concurrency: true }, () => ]); assert.strictEqual(stderr, ''); + // We are validating that: + // 1. the `--require` flag is run first from the main thread (and A is printed). + // 2. the `--require` flag is then run on the loader thread (and A is printed). + // 3. the `--loader` module is executed (and B is printed). + // 4. the `--import` module is evaluated once, on the main thread (and C is printed). + // 5. the user code is finally executed (and D is printed). // The worker code should always run before the --import, but the console.log might arrive late. - assert.match(stdout, /^A\r?\nA\r?\n(B\r?\nC|C\r?\nB)\r?\nD\r?\n$/); + assert.match(stdout, /^A\r?\n(A\r?\nB\r?\nC|A\r?\nC\r?\nB|C\r?\nA\r?\nB)\r?\nD\r?\n$/); assert.strictEqual(code, 0); assert.strictEqual(signal, null); });