Skip to content

Commit cae2b0a

Browse files
authored
Add XCTest.dll path to Path when testing on Windows (#978)
Add XCTest.dll to PATH and supply arguments when running swift-testing tests. Also fixes extra whitespace in output when debugging XCTests on Windows.
1 parent 284b294 commit cae2b0a

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/TestExplorer/TestRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ export class TestRunner {
808808
this.folderContext.name
809809
);
810810
LoggingDebugAdapterTracker.setDebugSessionCallback(session, output => {
811-
this.testRun.appendOutput(output);
811+
this.testRun.appendOutput(output.replace(/\n/g, "\r\n"));
812812
if (config.testType === TestLibrary.xctest) {
813813
this.xcTestOutputParser.parseResult(output, runState);
814814
}

src/debugger/buildConfig.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class TestingDebugConfigurationFactory {
9999

100100
/* eslint-disable no-case-declarations */
101101
private buildWindowsConfig(): vscode.DebugConfiguration | null {
102-
if (isDebugging(this.testKind) && this.testLibrary === TestLibrary.xctest) {
102+
if (isDebugging(this.testKind)) {
103103
const testEnv = {
104104
...swiftRuntimeEnv(),
105105
...configuration.folder(this.ctx.workspaceFolder).testEnvironmentVariables,
@@ -114,8 +114,8 @@ export class TestingDebugConfigurationFactory {
114114

115115
return {
116116
...this.baseConfig,
117-
program: this.xcTestOutputPath,
118-
args: this.testList,
117+
program: this.testExecutableOutputPath,
118+
args: this.debuggingTestExecutableArgs,
119119
env: testEnv,
120120
};
121121
} else {
@@ -403,6 +403,26 @@ export class TestingDebugConfigurationFactory {
403403
);
404404
}
405405

406+
private get testExecutableOutputPath(): string {
407+
switch (this.testLibrary) {
408+
case TestLibrary.swiftTesting:
409+
return this.swiftTestingOutputPath;
410+
case TestLibrary.xctest:
411+
return this.xcTestOutputPath;
412+
}
413+
}
414+
415+
private get debuggingTestExecutableArgs(): string[] {
416+
switch (this.testLibrary) {
417+
case TestLibrary.swiftTesting:
418+
return this.addBuildOptionsToArgs(
419+
this.addTestsToArgs(this.addSwiftTestingFlagsArgs([]))
420+
);
421+
case TestLibrary.xctest:
422+
return this.testList;
423+
}
424+
}
425+
406426
private get sanitizerRuntimeEnvironment() {
407427
return this.ctx.workspaceContext.toolchain.sanitizer(configuration.sanitizer)
408428
?.runtimeEnvironment;

0 commit comments

Comments
 (0)