Repository: nodejs/node
Pull request: test: parallelize test-without-async-context-frame correctly

It previously re-einvented the pattern matching that's already supported by test.py, and was running the tests one by one, which can lead to time out on slower machines.
This move it to sequential and use wildcard support in test.py to correctly parallelize the tests.

Fixes: https://github.com/nodejs/node/issues/60268
<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: test/parallel/test-without-async-context-frame.mjs
patch: @@ -1,64 +0,0 @@
-import { isWindows } from '../common/index.mjs';
-import { spawn } from 'node:child_process';
-import { once } from 'node:events';
-import { opendir } from 'node:fs/promises';
-import { fileURLToPath } from 'node:url';
-import { describe, it } from 'node:test';
-import { sep } from 'node:path';
-import { strictEqual } from 'node:assert';
-
-const python = process.env.PYTHON || (isWindows ? 'python' : 'python3');
-
-const testRunner = fileURLToPath(
-  new URL('../../tools/test.py', import.meta.url)
-);
-
-const setNames = ['async-hooks', 'parallel'];
-
-// Get all test names for each set
-const testSets = await Promise.all(setNames.map(async (name) => {
-  const path = fileURLToPath(new URL(`../${name}`, import.meta.url));
-  const dir = await opendir(path);
-
-  const tests = [];
-  for await (const entry of dir) {
-    if (entry.name.startsWith('test-async-local-storage-')) {
-      tests.push(entry.name);
-    }
-  }
-
-  return {
-    name,
-    tests
-  };
-}));
-
-// Merge test sets with set name prefix
-const tests = testSets.reduce((m, v) => {
-  for (const test of v.tests) {
-    m.push(`${v.name}${sep}${test}`);
-  }
-  return m;
-}, []);
-
-describe('without AsyncContextFrame', {
-  // TODO(qard): I think high concurrency causes memory problems on Windows
-  // concurrency: tests.length
-}, () => {
-  for (const test of tests) {
-    it(test, async () => {
-      const proc = spawn(python, [
-        testRunner,
-        `--mode=${process.features.debug ? 'debug' : 'release'}`,
-        `--shell=${process.execPath}`,
-        '--node-args=--no-async-context-frame',
-        test,
-      ], {
-        stdio: ['ignore', 'ignore', 'inherit'],
-      });
-
-      const [code] = await once(proc, 'exit');
-      strictEqual(code, 0, `Test ${test} failed with exit code ${code}`);
-    });
-  }
-});

filename: test/sequential/test-without-async-context-frame.mjs
patch: @@ -0,0 +1,24 @@
+import { isWindows } from '../common/index.mjs';
+import { spawn } from 'node:child_process';
+import { once } from 'node:events';
+import { fileURLToPath } from 'node:url';
+import { strictEqual } from 'node:assert';
+
+const python = process.env.PYTHON || (isWindows ? 'python' : 'python3');
+
+const testRunner = fileURLToPath(
+  new URL('../../tools/test.py', import.meta.url)
+);
+
+const proc = spawn(python, [
+  testRunner,
+  `--mode=${process.features.debug ? 'debug' : 'release'}`,
+  `--shell=${process.execPath}`,
+  '--node-args=--no-async-context-frame',
+  '*/test-async-local-storage-*',
+], {
+  stdio: ['inherit', 'inherit', 'inherit'],
+});
+
+const [code] = await once(proc, 'exit');
+strictEqual(code, 0);