Skip to content

Commit

Permalink
chore: Add some more logs for troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielku15 committed Jan 19, 2025
1 parent 86050da commit 1a63ba8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class TestRunner {
const workingDir = path.dirname(config.uri.fsPath);

return async (request) => {
const runStart = performance.now();
this.logChannel.debug('Creating new test run ', request);

const run = ctrl.createTestRun(request);
Expand All @@ -79,7 +80,9 @@ export class TestRunner {
};

const spawnCts = new vscode.CancellationTokenSource();
run.token.onCancellationRequested(() => spawnCts.cancel());
run.token.onCancellationRequested(() => {
spawnCts.cancel();
});

const spawnOpts: ISpawnOptions = {
args,
Expand Down Expand Up @@ -217,11 +220,14 @@ export class TestRunner {
);

try {
const start = performance.now();
if (debug) {
await this.runDebug(spawnOpts);
} else {
await this.runWithoutDebug(spawnOpts);
}
const end = performance.now();
this.logChannel.info(`Completed test execution after ${end - start}ms`);
} catch (e) {
const errorMessage = e instanceof Error ? e : `Error executing tests ${e}`;
this.logChannel.error(errorMessage);
Expand Down Expand Up @@ -253,6 +259,9 @@ export class TestRunner {

await outputQueue.drain();
run.end();

const runEnd = performance.now();
this.logChannel.debug(`Whole testrun completed after ${runEnd - runStart}ms`);
};
}

Expand Down Expand Up @@ -365,12 +374,15 @@ export class TestRunner {
return cli.kill();
}

token.onCancellationRequested(() => cli.kill());
token.onCancellationRequested(() => {
cli.kill();
});
cli.stderr.pipe(split2()).on('data', onLine);
cli.stdout.pipe(split2()).on('data', onLine);
return new Promise<void>((resolve, reject) => {
cli.on('error', reject);
cli.on('exit', (code) => {
cli.on('close', (code) => {
this.logChannel.trace('Test Process closed');
if (code === 0) {
resolve();
} else {
Expand Down

0 comments on commit 1a63ba8

Please sign in to comment.