Skip to content

Commit

Permalink
test: deflake test-loaders-workers-spawned
Browse files Browse the repository at this point in the history
PR-URL: nodejs#50251
Fixes: nodejs#50247
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and targos committed Nov 11, 2023
1 parent ccaa0e2 commit 8605b41
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/es-module/test-loaders-workers-spawned.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 8605b41

Please sign in to comment.