Skip to content

Commit

Permalink
Test: Rename memory-leak fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Jan 23, 2023
1 parent 589d9ed commit f503f06
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
10 changes: 4 additions & 6 deletions test/cli/cli-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,15 @@ HOOK: BCD1 @ B after`;
// https://nodejs.org/docs/v14.0.0/api/v8.html#v8_v8_getheapsnapshot
// Created in Node 11.x, but starts working the way we need from Node 14.
if (semver.gte(process.versions.node, '14.0.0')) {
QUnit.test('callbacks and hooks from modules are properly released for garbage collection', async assert => {
const command = ['node', '--expose-gc', '../../../bin/qunit.js', 'memory-leak/*.js'];
QUnit.test('memory-leak/module-closure [unfiltered]', async assert => {
const command = ['node', '--expose-gc', '../../../bin/qunit.js', 'memory-leak/module-closure.js'];
const execution = await execute(command);

assert.equal(execution.snapshot, getExpected(command));
});

QUnit.test('callbacks and hooks from filtered-out modules are properly released for garbage collection', async assert => {
const command = ['node', '--expose-gc', '../../../bin/qunit.js', '--filter', '!child', 'memory-leak/*.js'];
QUnit.test('memory-leak/module-closure [filtered module]', async assert => {
const command = ['node', '--expose-gc', '../../../bin/qunit.js', '--filter', '!child', 'memory-leak/module-closure.js'];
const execution = await execute(command);

assert.equal(execution.snapshot, getExpected(command));
});
}
Expand Down
14 changes: 7 additions & 7 deletions test/cli/fixtures/expected/tap-outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,21 +446,21 @@ ok 1 Single > has a test
# todo 0
# fail 0`,

"node --expose-gc ../../../bin/qunit.js 'memory-leak/*.js'":
"node --expose-gc ../../../bin/qunit.js memory-leak/module-closure.js":
`TAP version 13
ok 1 some nested module > can call method on foo
ok 2 some nested module > child module > child test
ok 3 later thing > has released all foos
ok 1 module-closure > example test
ok 2 module-closure > example child module > example child module test
ok 3 module-closure check > memory release
1..3
# pass 3
# skip 0
# todo 0
# fail 0`,

"node --expose-gc ../../../bin/qunit.js --filter !child 'memory-leak/*.js'":
"node --expose-gc ../../../bin/qunit.js --filter !child memory-leak/module-closure.js":
`TAP version 13
ok 1 some nested module > can call method on foo
ok 2 later thing > has released all foos
ok 1 module-closure > example test
ok 2 module-closure check > memory release
1..2
# pass 2
# skip 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function streamToString (stream) {
});
}

QUnit.module('some nested module', function (hooks) {
QUnit.module('module-closure', function (hooks) {
let foo1, foo2;

hooks.beforeEach(function () {
Expand All @@ -40,25 +40,25 @@ QUnit.module('some nested module', function (hooks) {
assert.equal(foo2.getId(), 'FooNum');
});

QUnit.test('can call method on foo', function (assert) {
QUnit.test('example test', function (assert) {
assert.equal(foo1.getId(), 'FooNum');
});

QUnit.module('child module', function (hooks) {
QUnit.module('example child module', function (hooks) {
let foo3;

hooks.beforeEach(function () {
foo3 = foo1;
});

QUnit.test('child test', function (assert) {
QUnit.test('example child module test', function (assert) {
assert.ok(foo3);
});
});
});

QUnit.module('later thing', function () {
QUnit.test('has released all foos', async function (assert) {
QUnit.module('module-closure check', function () {
QUnit.test('memory release', async function (assert) {
// The snapshot is expected to contain entries like this:
// > "FooNum<integer>"
// It is important that the regex uses \d and that the above
Expand Down

0 comments on commit f503f06

Please sign in to comment.