Skip to content

Commit

Permalink
Core: Refactor internal ProcessingQueue into class
Browse files Browse the repository at this point in the history
This is motivated by the last remaining build warning from Rollup:

> src/qunit.js → qunit/qunit.js...
> (!) Circular dependency
> src/test.js -> src/core/processing-queue.js -> src/test.js
> created qunit/qunit.js in 2s

ProcessingQueue needs access to the `test` function defined in test.js.

Fix by turning the module into a class, that we create a singleton
of in core.js (with access to test.js) and then use that singleton
where we previously used ProcessingQueue statically.

Closes #1740.
  • Loading branch information
Krinkle committed Feb 9, 2024
1 parent 2e87e2a commit d60f27c
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 186 deletions.
4 changes: 3 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const QUnit = {};
// rather than partly in config.js and partly here.
config.currentModule.suiteReport = runSuite;

config.pq = new ProcessingQueue(test);

let globalStartCalled = false;
let runStarted = false;

Expand Down Expand Up @@ -157,7 +159,7 @@ function scheduleBegin () {

function unblockAndAdvanceQueue () {
config.blocking = false;
ProcessingQueue.advance();
config.pq.advance();
}

export function begin () {
Expand Down
3 changes: 3 additions & 0 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ const config = {
// Ref https://github.com/qunitjs/qunit/pull/1598
globalHooks: {},

// Internal: ProcessingQueue singleton, created in /src/core.js
pq: null,

// Internal state
blocking: true,
callbacks: {},
Expand Down
Loading

0 comments on commit d60f27c

Please sign in to comment.