Skip to content

Commit 5c06030

Browse files
committed
Strip ANSI from XCTest output when parsing
1 parent b9a7aa6 commit 5c06030

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/TestExplorer/TestParsers/XCTestOutputParser.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import { ITestRunState, TestIssueDiff } from "./TestRunState";
1616
import { sourceLocationToVSCodeLocation } from "../../utilities/utilities";
1717
import { MarkdownString, Location } from "vscode";
18+
// eslint-disable-next-line @typescript-eslint/no-require-imports
19+
import stripAnsi = require("strip-ansi");
1820

1921
/** Regex for parsing XCTest output */
2022
interface TestRegex {
@@ -148,7 +150,10 @@ export class XCTestOutputParser implements IXCTestOutputParser {
148150
* Parse results from `swift test` and update tests accordingly
149151
* @param output Output from `swift test`
150152
*/
151-
public parseResult(output: string, runState: ITestRunState) {
153+
public parseResult(rawOutput: string, runState: ITestRunState) {
154+
// Windows is inserting ANSI codes into the output to do things like clear the cursor,
155+
// which we don't care about.
156+
const output = process.platform === "win32" ? stripAnsi(rawOutput) : rawOutput;
152157
const output2 = output.replace(/\r\n/g, "\n");
153158
const lines = output2.split("\n");
154159
if (runState.excess) {

0 commit comments

Comments
 (0)