Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Dec 2, 2022
1 parent d79755c commit c1c9fa4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
5 changes: 4 additions & 1 deletion lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
ArrayPrototypeJoin,
ArrayPrototypePush,
ArrayPrototypeSlice,
ArrayPrototypeSome,
ArrayPrototypeSort,
ObjectAssign,
PromisePrototypeThen,
Expand All @@ -16,6 +17,7 @@ const {
SafeMap,
SafeSet,
StringPrototypeRepeat,
StringPrototypeStartsWith,
} = primordials;

const { spawn } = require('child_process');
Expand Down Expand Up @@ -117,7 +119,8 @@ function createTestFileList() {
function filterExecArgv(arg, i, arr) {
return !ArrayPrototypeIncludes(kFilterArgs, arg) &&
!ArrayPrototypeIncludes(kFilterArgValues, arg) &&
!ArrayPrototypeIncludes(kFilterArgValues, arr[i - 1]);
!ArrayPrototypeIncludes(kFilterArgValues, arr[i - 1]) &&
!ArrayPrototypeSome(kFilterArgValues, (p) => StringPrototypeStartsWith(arg, `${p}=`));
}

function getRunArgs({ path, inspectPort }) {
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
ArrayPrototypeSlice,
ArrayPrototypeSome,
ArrayPrototypeUnshift,
Boolean,
FunctionPrototype,
MathMax,
Number,
Expand Down Expand Up @@ -173,7 +174,7 @@ class Test extends AsyncResource {
this.concurrency = 1;
this.nesting = 0;
this.only = testOnlyFlag;
this.reporter = new TapStream({ objectMode: hasReporters });
this.reporter = new TapStream({ __proto__: null, objectMode: hasReporters });
this.runOnlySubtests = this.only;
this.testNumber = 0;
this.timeout = kDefaultTimeout;
Expand Down
4 changes: 2 additions & 2 deletions lib/test/reporter/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module.exports = async function*(source) {
for await (const { type } of source) {
if (type === 'test:fail' || type === 'test:pass') {
yield ".";
yield '.';
}
}
yield "\n";
yield '\n';
};
18 changes: 12 additions & 6 deletions lib/test/reporter/spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
'use strict';

const console = require('console');
const {
ArrayPrototypePop,
ArrayPrototypeShift,
ArrayPrototypeUnshift,
} = primordials;
const Transform = require('internal/streams/transform');
const { green, blue, red, white } = require('internal/util/colors');

Expand Down Expand Up @@ -34,21 +38,23 @@ class SpecReporter extends Transform {
switch (type) {
case 'test:fail':
case 'test:pass': {
this.#stack.shift();
ArrayPrototypeShift(this.#stack); // This is the matching `test:subtest` event
let prefix = '';
while (this.#stack.length) {
const msg = this.#stack.pop();
this.#reported.unshift(msg);
// Report all the parent `test:subtest` events
const msg = ArrayPrototypePop(this.#stack);
ArrayPrototypeUnshift(this.#reported, msg);
prefix += `${this.#indent(msg.nesting)}${symbols['arrow:right']}${msg.name}\n`;
}
if (this.#reported[0] && this.#reported[0].nesting === data.nesting && this.#reported[0].name === data.name) {
this.#reported.shift();
// If this test has had children - it was already reporter, so slightly modify the output
ArrayPrototypeShift(this.#reported);
return `${prefix}${this.#indent(data.nesting)}${color}${symbols['arrow:right']}${white}${data.name}\n\n`;
}
return `${prefix}${this.#indent(data.nesting)}${color}${symbol}${data.name}${white}\n`;
}
case 'test:subtest':
this.#stack.unshift(data);
ArrayPrototypeUnshift(this.#stack, data);
break;
case 'test:diagnostic':
return `${color}${symbol}${data}${white}\n`;
Expand Down

0 comments on commit c1c9fa4

Please sign in to comment.