-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest_runner.js
More file actions
60 lines (52 loc) · 1.8 KB
/
test_runner.js
File metadata and controls
60 lines (52 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
const {
ArrayPrototypePush,
StringPrototypeStartsWith,
} = primordials;
const {
markBootstrapComplete,
prepareTestRunnerMainExecution,
} = require('internal/process/pre_execution');
const { isUsingInspector } = require('internal/util/inspector');
const { run } = require('internal/test_runner/runner');
const { parseCommandLine } = require('internal/test_runner/utils');
const { exitCodes: { kGenericUserError } } = internalBinding('errors');
let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => {
debug = fn;
});
const options = parseCommandLine();
const isTestIsolationDisabled = options.isolation === 'none';
// We set initializeModules to false as we want to load user modules in the test runner run function
// if we are running with --test-isolation=none
prepareTestRunnerMainExecution(!isTestIsolationDisabled);
markBootstrapComplete();
if (isUsingInspector() && options.isolation === 'process') {
process.emitWarning('Using the inspector with --test forces running at a concurrency of 1. ' +
'Use the inspectPort option to run with concurrency');
options.concurrency = 1;
options.inspectPort = process.debugPort;
}
const userArgs = [];
const globPatterns = [];
let isArg = false;
for (let i = 1; i < process.argv.length; i++) {
const arg = process.argv[i];
if (isArg) {
ArrayPrototypePush(userArgs, arg);
} else if (arg === '--') {
isArg = true;
ArrayPrototypePush(userArgs, arg);
} else if (StringPrototypeStartsWith(arg, '-')) {
ArrayPrototypePush(userArgs, arg);
} else {
ArrayPrototypePush(globPatterns, arg);
}
}
options.globPatterns = globPatterns;
options.argv = userArgs;
debug('test runner configuration:', options);
run(options).on('test:summary', (data) => {
if (!data.success) {
process.exitCode = kGenericUserError;
}
});