Pass stack trace limit to parallel workers, and always convert to number (#22527)

* Pass stackTraceLimit to parallel workers

Specifying it breaks some output, both in parallel and normal runners.
I'll look at that in another commit, probably another PR, depending on
how simple the problem is.

* Always convert stackTraceLimit to a number

Sometimes it's not a number, even though the type claims it is.
This commit is contained in:
Nathan Shively-Sanders
2018-03-14 07:05:32 -07:00
committed by GitHub
parent 8d172aa353
commit 24fdb5201d
3 changed files with 9 additions and 2 deletions

View File

@@ -144,7 +144,7 @@ namespace Harness.Parallel.Host {
let closedWorkers = 0;
for (let i = 0; i < workerCount; i++) {
// TODO: Just send the config over the IPC channel or in the command line arguments
const config: TestConfig = { light: lightMode, listenForWork: true, runUnitTests };
const config: TestConfig = { light: lightMode, listenForWork: true, runUnitTests, stackTraceLimit };
const configPath = ts.combinePaths(taskConfigsFolder, `task-config${i}.json`);
IO.writeFile(configPath, JSON.stringify(config));
const child = fork(__filename, [`--config="${configPath}"`]);

View File

@@ -88,6 +88,7 @@ let testConfigContent =
let taskConfigsFolder: string;
let workerCount: number;
let runUnitTests: boolean | undefined;
let stackTraceLimit: number | "full" | undefined;
let noColors = false;
interface TestConfig {
@@ -132,9 +133,11 @@ function handleTestConfig() {
if (testConfig.stackTraceLimit === "full") {
(<any>Error).stackTraceLimit = Infinity;
stackTraceLimit = testConfig.stackTraceLimit;
}
else if ((+testConfig.stackTraceLimit | 0) > 0) {
(<any>Error).stackTraceLimit = testConfig.stackTraceLimit;
(<any>Error).stackTraceLimit = +testConfig.stackTraceLimit | 0;
stackTraceLimit = +testConfig.stackTraceLimit | 0;
}
if (testConfig.listenForWork) {
return true;

View File

@@ -421,13 +421,17 @@ namespace ts.server {
// Disable sourcemap support for the duration of the test, as sourcemapping the errors generated during this test is slow and not something we care to test
let oldPrepare: AnyFunction;
let oldStackTraceLimit: number;
before(() => {
oldStackTraceLimit = (Error as any).stackTraceLimit;
oldPrepare = (Error as any).prepareStackTrace;
delete (Error as any).prepareStackTrace;
(Error as any).stackTraceLimit = 10;
});
after(() => {
(Error as any).prepareStackTrace = oldPrepare;
(Error as any).stackTraceLimit = oldStackTraceLimit;
});
const command = "testhandler";