Skip to content
Merged
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
1 change: 1 addition & 0 deletions news/2 Fixes/17111.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure line feeds are changed to CRLF in test messages.
11 changes: 6 additions & 5 deletions src/client/testing/testController/common/resultsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as fsapi from 'fs-extra';
import { Location, TestItem, TestMessage, TestRun } from 'vscode';
import { getRunIdFromRawData, getTestCaseNodes } from './testItemUtilities';
import { TestData } from './types';
import { fixLogLines } from './utils';

type TestSuiteResult = {
$: {
Expand Down Expand Up @@ -113,7 +114,7 @@ export async function updateResultFromJunitXml(
}

runInstance.errored(node, message);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
} else if (result.failure) {
failures += 1;
const failure = result.failure[0];
Expand All @@ -125,23 +126,23 @@ export async function updateResultFromJunitXml(
}

runInstance.failed(node, message);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
} else if (result.skipped) {
skipped += 1;
const skip = result.skipped[0];
const text = `${rawTestCaseNode.rawId} Skipped: [${skip.$.type}]${skip.$.message}\r\n`;

runInstance.skipped(node);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
} else {
passed += 1;
const text = `${rawTestCaseNode.rawId} Passed\r\n`;
runInstance.passed(node);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
}
} else {
const text = `Test result not found for: ${rawTestCaseNode.rawId}\r\n`;
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
const message = new TestMessage(text);

if (node.uri && node.range) {
Expand Down
7 changes: 7 additions & 0 deletions src/client/testing/testController/common/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export function fixLogLines(content: string): string {
const lines = content.split(/\r?\n/g);
return `${lines.join('\r\n')}\r\n`;
}
11 changes: 6 additions & 5 deletions src/client/testing/testController/unittest/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ITestRunner, ITestDebugLauncher, IUnitTestSocketServer, LaunchOptions,
import { TEST_OUTPUT_CHANNEL } from '../../constants';
import { getTestCaseNodes } from '../common/testItemUtilities';
import { ITestRun, ITestsRunner, TestData, TestRunInstanceOptions, TestRunOptions } from '../common/types';
import { fixLogLines } from '../common/utils';
import { getTestRunArgs } from './arguments';

interface ITestData {
Expand Down Expand Up @@ -102,7 +103,7 @@ export class UnittestRunner implements ITestsRunner {
if (data.outcome === 'passed' || data.outcome === 'failed-expected') {
const text = `${rawTestCase.rawId} Passed\r\n`;
runInstance.passed(testCase);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
counts.passed += 1;
} else if (data.outcome === 'failed' || data.outcome === 'passed-unexpected') {
const traceback = data.traceback
Expand All @@ -116,7 +117,7 @@ export class UnittestRunner implements ITestsRunner {
}

runInstance.failed(testCase, message);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
counts.failed += 1;
if (failFast) {
stopTesting = true;
Expand All @@ -133,7 +134,7 @@ export class UnittestRunner implements ITestsRunner {
}

runInstance.errored(testCase, message);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
counts.errored += 1;
if (failFast) {
stopTesting = true;
Expand All @@ -144,11 +145,11 @@ export class UnittestRunner implements ITestsRunner {
: '';
const text = `${rawTestCase.rawId} Skipped: ${data.message}\r\n${traceback}\r\n`;
runInstance.skipped(testCase);
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
counts.skipped += 1;
} else {
const text = `Unknown outcome type for test ${rawTestCase.rawId}: ${data.outcome}`;
runInstance.appendOutput(text);
runInstance.appendOutput(fixLogLines(text));
const message = new TestMessage(text);
if (testCase.uri && testCase.range) {
message.location = new Location(testCase.uri, testCase.range);
Expand Down