Skip to content

Commit be22745

Browse files
committed
Output build log on testing related integration test failures
In service of tracking down flaky test failures like #1334, dump the build/test run log when a testing related integration test fails.
1 parent 95a6e43 commit be22745

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/TestExplorer/TestRunner.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export interface TestRunState {
6767
errored: vscode.TestItem[];
6868
unknown: number;
6969
output: string[];
70+
buildConfig: string;
7071
}
7172

7273
export class TestRunProxy {
@@ -94,6 +95,7 @@ export class TestRunProxy {
9495
errored: [],
9596
unknown: 0,
9697
output: [],
98+
buildConfig: "",
9799
};
98100
}
99101

@@ -118,6 +120,10 @@ export class TestRunProxy {
118120
this.onTestRunComplete = this.testRunCompleteEmitter.event;
119121
}
120122

123+
public setBuildConfiguration(buildConfig: vscode.DebugConfiguration) {
124+
this.runState.buildConfig += "\n" + JSON.stringify(buildConfig, null, 2);
125+
}
126+
121127
public testRunStarted = () => {
122128
if (this.runStarted) {
123129
return;
@@ -589,6 +595,8 @@ export class TestRunner {
589595
return this.testRun.runState;
590596
}
591597

598+
this.testRun.setBuildConfiguration(testBuildConfig);
599+
592600
const outputStream = this.testOutputWritable(TestLibrary.swiftTesting, runState);
593601

594602
// Watch the pipe for JSONL output and parse the events into test explorer updates.
@@ -623,6 +631,8 @@ export class TestRunner {
623631
return this.testRun.runState;
624632
}
625633

634+
this.testRun.setBuildConfiguration(testBuildConfig);
635+
626636
// XCTestRuns are started immediately
627637
this.testRun.testRunStarted();
628638

@@ -957,6 +967,8 @@ export class TestRunner {
957967
});
958968
subscriptions.push(startSession);
959969

970+
this.testRun.setBuildConfiguration(config);
971+
960972
vscode.debug
961973
.startDebugging(this.folderContext.workspaceFolder, config)
962974
.then(

test/integration-tests/testexplorer/utilities.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,15 @@ export function assertTestResults(
160160
skipped: (state.skipped ?? []).sort(),
161161
errored: (state.errored ?? []).sort(),
162162
unknown: 0,
163-
}
163+
},
164+
`
165+
Test run results do not match expected results
166+
Build configuration:
167+
${testRun.runState.buildConfig}
168+
169+
Build Output:
170+
${testRun.runState.output.join("\n")}
171+
`
164172
);
165173
}
166174

0 commit comments

Comments
 (0)