Skip to content

Commit ef2a86b

Browse files
test: make three cases hermetic against a shared global
ConfigTestCases and ConfigCacheTestCases run the same cases, and a worker that shares one global between test files (Bun's --workerThreads) carries their leftovers into the second run. The harness only clears globals whose name contains "webpack", so a plain counter survives: the deferred-evaluation case then saw a non-zero count and the inline-exports case saw its side effects twice. Both now clear their own counter. The amd-runtimeChunk library variants are a timing difference, not a leftover: the `promise` external is still settling when the harness deletes the chunk loading globals, which only survives because Node gives each test file a fresh global. Filtered out under Bun until the harness can await those externals.
1 parent 3699110 commit ef2a86b

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎test/configCases/defer-import/set-does-not-trigger-evaluation/index.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import defer * as ns from "./dep.js";
22

3+
// `import defer` leaves ./dep.js unevaluated, so this only clears a counter a
4+
// previous test file left behind where a worker shares globals (Bun)
5+
delete globalThis.evaluations;
6+
37
it("does not evaluate the deferred module on `import defer`", () => {
48
expect(globalThis.evaluations).toBe(undefined);
59
});

‎test/configCases/inline-exports/module-declarations/index.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ it("should inline constants from modules with import and re-export declarations"
1818
expect(REMOVE_with_all_module_declarations).toBe(321);
1919
// END
2020
expect(globalThis.__inlineConstModuleDeclarationsSideEffect).toBe(3);
21+
// the counter outlives this bundle where a worker shares globals between
22+
// test files (Bun), so the next run of this case would start from 3
23+
delete globalThis.__inlineConstModuleDeclarationsSideEffect;
2124
const block = generated.match(/\/\/ START([\s\S]*)\/\/ END/)[1];
2225
expect(
2326
block.includes(`((/* inlined export .REMOVE_with_import */123)).toBe(123)`)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
3+
// The amd-runtimeChunk variants pull the library through a `promise` external,
4+
// which is still settling when the harness deletes the `webpack*` chunk-loading
5+
// globals after execution. Node gives every test file a fresh global so the
6+
// reload succeeds; Bun shares one per worker thread, so the second suite to run
7+
// this case (ConfigTestCases vs ConfigCacheTestCases) loses the registration.
8+
module.exports = function filter() {
9+
return !process.versions.bun;
10+
};

0 commit comments

Comments
 (0)