Skip to content

Commit

Permalink
Rename internal test.asyncNextPauseId to test.nextPauseId
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Aug 2, 2021
1 parent 2015f57 commit 9444070
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function run( args, options ) {
console.error( "Error: Process exited before tests finished running" );

const currentTest = QUnit.config.current;
if ( currentTest && currentTest.asyncPauses.size > 0 ) {
if ( currentTest && currentTest.pauses.size > 0 ) {
const name = currentTest.testName;
console.error( "Last test to run (" + name + ") has an async hold. " +
"Ensure all assert.async() callbacks are invoked and Promises resolve. " +
Expand Down
22 changes: 11 additions & 11 deletions src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default function Test( settings ) {
this.timeout = undefined;
this.data = undefined;
this.withData = false;
this.asyncNextPauseId = 1;
this.asyncPauses = new Map();
this.pauses = new Map();
this.nextPauseId = 1;
extend( this, settings );

// If a module is skipped, all its tests and the tests of the child suites
Expand Down Expand Up @@ -204,7 +204,7 @@ Test.prototype = {

// If the test has an async "pause" on it, but the timeout is 0, then we push a
// failure as the test should be synchronous.
if ( test.timeout === 0 && test.asyncPauses.size > 0 ) {
if ( test.timeout === 0 && test.pauses.size > 0 ) {
pushFailure(
"Test did not finish synchronously even though assert.timeout( 0 ) was used.",
sourceFromStacktrace( 2 )
Expand Down Expand Up @@ -869,12 +869,12 @@ export function resetTestTimeout( timeoutDuration ) {
export function internalStop( test, requiredCalls = 1 ) {
config.blocking = true;

const pauseId = test.asyncNextPauseId++;
const pauseId = test.nextPauseId++;
const pause = {
cancelled: false,
remaining: requiredCalls
};
test.asyncPauses.set( pauseId, pause );
test.pauses.set( pauseId, pause );

function release() {
if ( pause.cancelled ) {
Expand All @@ -896,7 +896,7 @@ export function internalStop( test, requiredCalls = 1 ) {
// The `requiredCalls` parameter exists to support `assert.async(count)`
pause.remaining--;
if ( pause.remaining === 0 ) {
test.asyncPauses.delete( pauseId );
test.pauses.delete( pauseId );
}

internalStart( test );
Expand All @@ -916,7 +916,7 @@ export function internalStop( test, requiredCalls = 1 ) {
return function() {
config.timeout = null;
pause.cancelled = true;
test.asyncPauses.delete( pauseId );
test.pauses.delete( pauseId );

test.pushFailure(
`Test took longer than ${timeout}ms; test timed out.`,
Expand All @@ -938,26 +938,26 @@ export function internalStop( test, requiredCalls = 1 ) {

// Forcefully release all processing holds.
function internalRecover( test ) {
test.asyncPauses.forEach( pause => {
test.pauses.forEach( pause => {
pause.cancelled = true;
} );
test.asyncPauses.clear();
test.pauses.clear();
internalStart( test );
}

// Release a processing hold, scheduling a resumption attempt if no holds remain.
function internalStart( test ) {

// Ignore if other async pauses still exist.
if ( test.asyncPauses.size > 0 ) {
if ( test.pauses.size > 0 ) {
return;
}

// Add a slight delay to allow more assertions etc.
if ( setTimeout ) {
clearTimeout( config.timeout );
config.timeout = setTimeout( function() {
if ( test.asyncPauses.size > 0 ) {
if ( test.pauses.size > 0 ) {
return;
}

Expand Down

0 comments on commit 9444070

Please sign in to comment.