Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/harness/parallel/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`]);
Expand Down
5 changes: 4 additions & 1 deletion src/harness/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/harness/unittests/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down