Skip to content

Commit 24fdb52

Browse files
authored
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.
1 parent 8d172aa commit 24fdb52

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/harness/parallel/host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace Harness.Parallel.Host {
144144
let closedWorkers = 0;
145145
for (let i = 0; i < workerCount; i++) {
146146
// TODO: Just send the config over the IPC channel or in the command line arguments
147-
const config: TestConfig = { light: lightMode, listenForWork: true, runUnitTests };
147+
const config: TestConfig = { light: lightMode, listenForWork: true, runUnitTests, stackTraceLimit };
148148
const configPath = ts.combinePaths(taskConfigsFolder, `task-config${i}.json`);
149149
IO.writeFile(configPath, JSON.stringify(config));
150150
const child = fork(__filename, [`--config="${configPath}"`]);

src/harness/runner.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ let testConfigContent =
8888
let taskConfigsFolder: string;
8989
let workerCount: number;
9090
let runUnitTests: boolean | undefined;
91+
let stackTraceLimit: number | "full" | undefined;
9192
let noColors = false;
9293

9394
interface TestConfig {
@@ -132,9 +133,11 @@ function handleTestConfig() {
132133

133134
if (testConfig.stackTraceLimit === "full") {
134135
(<any>Error).stackTraceLimit = Infinity;
136+
stackTraceLimit = testConfig.stackTraceLimit;
135137
}
136138
else if ((+testConfig.stackTraceLimit | 0) > 0) {
137-
(<any>Error).stackTraceLimit = testConfig.stackTraceLimit;
139+
(<any>Error).stackTraceLimit = +testConfig.stackTraceLimit | 0;
140+
stackTraceLimit = +testConfig.stackTraceLimit | 0;
138141
}
139142
if (testConfig.listenForWork) {
140143
return true;

src/harness/unittests/session.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,17 @@ namespace ts.server {
421421

422422
// 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
423423
let oldPrepare: AnyFunction;
424+
let oldStackTraceLimit: number;
424425
before(() => {
426+
oldStackTraceLimit = (Error as any).stackTraceLimit;
425427
oldPrepare = (Error as any).prepareStackTrace;
426428
delete (Error as any).prepareStackTrace;
429+
(Error as any).stackTraceLimit = 10;
427430
});
428431

429432
after(() => {
430433
(Error as any).prepareStackTrace = oldPrepare;
434+
(Error as any).stackTraceLimit = oldStackTraceLimit;
431435
});
432436

433437
const command = "testhandler";

0 commit comments

Comments
 (0)