Skip to content
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

merge log panels 2 #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ npm-debug.log
yarn.*
[Bb]in/
[Oo]bj/
lcov.info
lcov.info
.vscode-test
*.vsix
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"icon": "testexplorer_dark.png",
"engines": {
"vscode": "^1.25.1"
"vscode": "^1.45.1"
},
"categories": [
"Programming Languages"
Expand Down Expand Up @@ -267,6 +267,11 @@
"type": "boolean",
"default": false,
"description": "If true, will discover/build and run test in parallel if you have multiple test projects"
},
"dotnet-test-explorer.clearTerminalBeforeTestRun": {
"type": "boolean",
"default": false,
"description": "If true, clears the output panel before running/debugging test"
}
}
},
Expand Down
10 changes: 7 additions & 3 deletions src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { platform } from "os";
import * as vscode from "vscode";
import { Debug, IDebugRunnerInfo } from "./debug";
import { Logger } from "./logger";
import { Utility } from "./utility";

export class Executor {

Expand Down Expand Up @@ -31,6 +32,9 @@ export class Executor {
Logger.Log(`Process ${childProcess.pid} started`);

this.processes.push(childProcess);
childProcess.stdout.on("data", (buf) => {
Logger.LogRaw(buf);
});

childProcess.on("close", (code: number) => {

Expand Down Expand Up @@ -63,6 +67,7 @@ export class Executor {
if (addToProcessList) {

Logger.Log(`Process ${childProcess.pid} started`);
Logger.Log(`Waiting for debugger to attach`);

this.processes.push(childProcess);

Expand All @@ -72,15 +77,14 @@ export class Executor {
return;
}

Logger.Log(`Waiting for debugger to attach`);

const stdout = String(buf);
Logger.LogRaw(stdout);

this.debugRunnerInfo = debug.onData(stdout, this.debugRunnerInfo);

if (this.debugRunnerInfo.config) {

Logger.Log(`Debugger process found, attaching`);
Logger.Log(`Debugger process found (pid: ${this.debugRunnerInfo.processId}), attaching`);

this.debugRunnerInfo.isRunning = true;

Expand Down
16 changes: 12 additions & 4 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
import * as vscode from "vscode";

export class Logger {
public static Log(message: string, output: string = this.defaultOutput): void {
public static LogRaw(message: string, output: string = this.defaultOutput): void {
if (this.outputTerminals[output] === undefined ) {
this.outputTerminals[output] = vscode.window.createOutputChannel(output);
}

this.outputTerminals[output].appendLine(message);
this.outputTerminals[output].appendLine(message.trim());
}

public static Log(message: string): void {
Logger.LogRaw(`[INFO] ${message}`);
}

public static LogError(message: string, error: any): void {
Logger.Log(`[ERROR] ${message} - ${Logger.formatError(error)}`);
Logger.LogRaw(`[ERROR] ${message} - ${Logger.formatError(error)}`);
}

public static LogWarning(message: string): void {
Logger.Log(`[WARNING] ${message}`);
Logger.LogRaw(`[WARNING] ${message}`);
}

public static Clear(output: string = this.defaultOutput): void {
this.outputTerminals[output].clear();
}

public static Show(): void {
Expand Down
8 changes: 4 additions & 4 deletions src/testCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ export class TestCommands implements Disposable {

this.runBuildCommandForSpecificDirectory(testDirectoryPath)
.then(() => {
if (Utility.clearTerminalBeforeTestRun){
Logger.Clear();
Logger.Show();
}
Logger.Log(`Executing ${command} in ${testDirectoryPath}`);

if (!debug) {
Expand All @@ -272,8 +276,6 @@ export class TestCommands implements Disposable {
reject(new Error("UserAborted"));
}

Logger.Log(stdout, "Test Explorer (Test runner output)");

resolve();
}, testDirectoryPath, true);
} else {
Expand All @@ -284,8 +286,6 @@ export class TestCommands implements Disposable {
reject(new Error("UserAborted"));
}

Logger.Log(stdout, "Test Explorer (Test runner output)");

resolve();
}, testDirectoryPath, true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class Utility {

public static skipBuild: boolean;
public static runInParallel: boolean;
public static clearTerminalBeforeTestRun: boolean;

public static get codeLensEnabled(): boolean {
return Utility.showCodeLens;
Expand Down Expand Up @@ -74,6 +75,7 @@ export class Utility {
Utility.autoExpandTree = configuration.get<boolean>("autoExpandTree", false);
Utility.skipBuild = Utility.additionalArgumentsOption.indexOf("--no-build") > -1;
Utility.runInParallel = configuration.get<boolean>("runInParallel", false);
Utility.clearTerminalBeforeTestRun = configuration.get<boolean>("clearTerminalBeforeTestRun", false);
}

/**
Expand Down