Skip to content

Commit fc258c7

Browse files
authored
Fix flakey pipe removal for debug runs (#845)
* Fix flakey pipe removal for debug runs #837 fixed this for regular runs, but more work was required for debug runs
1 parent 8fcd1a5 commit fc258c7

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/TestExplorer/TestRunner.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { TemporaryFolder } from "../utilities/tempFolder";
3737
import { TestClass, runnableTag, upsertTestItem } from "./TestDiscovery";
3838
import { TestCoverage } from "../coverage/LcovResults";
3939
import { TestingDebugConfigurationFactory } from "../debugger/buildConfig";
40+
import { SwiftExecution } from "../tasks/SwiftExecution";
4041

4142
/** Workspace Folder events */
4243
export enum TestKind {
@@ -731,6 +732,25 @@ export class TestRunner {
731732
const debugRuns = validBuildConfigs.map(config => {
732733
return () =>
733734
new Promise<void>((resolve, reject) => {
735+
let buildFailed = false;
736+
const buildTask = vscode.tasks.onDidStartTask(e => {
737+
if (e.execution.task.name === "Build All") {
738+
const exec = e.execution.task.execution as SwiftExecution;
739+
const didCloseBuildTask = exec.onDidClose(exitCode => {
740+
if (
741+
exitCode !== 0 &&
742+
config.testType === TestLibrary.swiftTesting
743+
) {
744+
buildFailed = true;
745+
this.swiftTestOutputParser.close();
746+
subscriptions.forEach(sub => sub.dispose());
747+
}
748+
});
749+
subscriptions.push(didCloseBuildTask);
750+
}
751+
});
752+
subscriptions.push(buildTask);
753+
734754
// add cancelation
735755
const startSession = vscode.debug.onDidStartDebugSession(session => {
736756
if (config.testType === TestLibrary.xctest) {
@@ -762,14 +782,18 @@ export class TestRunner {
762782
.startDebugging(this.folderContext.workspaceFolder, config)
763783
.then(
764784
started => {
785+
if (buildFailed) {
786+
reject("Build Failed");
787+
return;
788+
}
765789
if (started) {
766790
// show test results pane
767791
vscode.commands.executeCommand(
768792
"testing.showMostRecentOutput"
769793
);
770794

771795
const terminateSession =
772-
vscode.debug.onDidTerminateDebugSession(async () => {
796+
vscode.debug.onDidTerminateDebugSession(() => {
773797
this.workspaceContext.outputChannel.logDiagnostic(
774798
"Stop Test Debugging",
775799
this.folderContext.name

0 commit comments

Comments
 (0)