Skip to content

Commit

Permalink
v2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Dec 9, 2024
1 parent 8492542 commit 044323f
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 429 deletions.
129 changes: 0 additions & 129 deletions src/client/testing/common/runner.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/client/testing/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,3 @@ export interface IUnitTestSocketServer extends Disposable {
start(options?: { port?: number; host?: string }): Promise<number>;
stop(): void;
}

export const ITestRunner = Symbol('ITestRunner');
export interface ITestRunner {
run(testProvider: TestProvider, options: Options): Promise<string>;
}
4 changes: 0 additions & 4 deletions src/client/testing/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import { IExtensionActivationService } from '../activation/types';
import { IServiceManager } from '../ioc/types';
import { DebugLauncher } from './common/debugLauncher';
import { TestRunner } from './common/runner';
import { TestConfigSettingsService } from './common/configSettingService';
import { TestsHelper } from './common/testUtils';
import {
ITestConfigSettingsService,
ITestConfigurationManagerFactory,
ITestConfigurationService,
ITestDebugLauncher,
ITestRunner,
ITestsHelper,
IUnitTestSocketServer,
} from './common/types';
Expand All @@ -29,8 +27,6 @@ export function registerTypes(serviceManager: IServiceManager) {
serviceManager.add<ITestsHelper>(ITestsHelper, TestsHelper);
serviceManager.add<IUnitTestSocketServer>(IUnitTestSocketServer, UnitTestSocketServer);

serviceManager.add<ITestRunner>(ITestRunner, TestRunner);

serviceManager.addSingleton<ITestConfigurationService>(ITestConfigurationService, UnitTestConfigurationService);
serviceManager.addSingleton<ITestingService>(ITestingService, TestingService);

Expand Down
7 changes: 0 additions & 7 deletions src/client/testing/testController/common/testItemUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,6 @@ export async function updateTestItemFromRawData(
item.busy = false;
}

export function getUri(node: TestItem): Uri | undefined {
if (!node.uri && node.parent) {
return getUri(node.parent);
}
return node.uri;
}

export function getTestCaseNodes(testNode: TestItem, collection: TestItem[] = []): TestItem[] {
if (!testNode.canResolveChildren && testNode.tags.length > 0) {
collection.push(testNode);
Expand Down
82 changes: 0 additions & 82 deletions src/client/testing/testController/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,12 @@ import { Deferred, createDeferred } from '../../../common/utils/async';
import { createReaderPipe, generateRandomPipeName } from '../../../common/pipes/namedPipes';
import { EXTENSION_ROOT_DIR } from '../../../constants';

export function fixLogLines(content: string): string {
const lines = content.split(/\r?\n/g);
return `${lines.join('\r\n')}\r\n`;
}

export function fixLogLinesNoTrailing(content: string): string {
const lines = content.split(/\r?\n/g);
return `${lines.join('\r\n')}`;
}
export interface IJSONRPCData {
extractedJSON: string;
remainingRawData: string;
}

export interface ParsedRPCHeadersAndData {
headers: Map<string, string>;
remainingRawData: string;
}

export interface ExtractOutput {
uuid: string | undefined;
cleanedJsonData: string | undefined;
remainingRawData: string;
}

export const JSONRPC_UUID_HEADER = 'Request-uuid';
export const JSONRPC_CONTENT_LENGTH_HEADER = 'Content-Length';
export const JSONRPC_CONTENT_TYPE_HEADER = 'Content-Type';
export const MESSAGE_ON_TESTING_OUTPUT_MOVE =
'Starting now, all test run output will be sent to the Test Result panel,' +
' while test discovery output will be sent to the "Python" output channel instead of the "Python Test Log" channel.' +
Expand All @@ -58,66 +36,6 @@ export function createTestingDeferred(): Deferred<void> {
}


export function parseJsonRPCHeadersAndData(rawData: string): ParsedRPCHeadersAndData {
/**
* Parses the provided raw data to extract JSON-RPC specific headers and remaining data.
*
* This function aims to extract specific JSON-RPC headers (like UUID, content length,
* and content type) from the provided raw string data. Headers are expected to be
* delimited by newlines and the format should be "key:value". The function stops parsing
* once it encounters an empty line, and the rest of the data after this line is treated
* as the remaining raw data.
*
* @param {string} rawData - The raw string containing headers and possibly other data.
* @returns {ParsedRPCHeadersAndData} An object containing the parsed headers as a map and the
* remaining raw data after the headers.
*/
const lines = rawData.split('\n');
let remainingRawData = '';
const headerMap = new Map<string, string>();
for (let i = 0; i < lines.length; i += 1) {
const line = lines[i];
if (line === '') {
remainingRawData = lines.slice(i + 1).join('\n');
break;
}
const [key, value] = line.split(':');
if (value && value.trim()) {
if ([JSONRPC_UUID_HEADER, JSONRPC_CONTENT_LENGTH_HEADER, JSONRPC_CONTENT_TYPE_HEADER].includes(key)) {
headerMap.set(key.trim(), value.trim());
}
}
}

return {
headers: headerMap,
remainingRawData,
};
}

export function ExtractJsonRPCData(payloadLength: string | undefined, rawData: string): IJSONRPCData {
/**
* Extracts JSON-RPC content based on provided headers and raw data.
*
* This function uses the `Content-Length` header from the provided headers map
* to determine how much of the rawData string represents the actual JSON content.
* After extracting the expected content, it also returns any remaining data
* that comes after the extracted content as remaining raw data.
*
* @param {string | undefined} payloadLength - The value of the `Content-Length` header.
* @param {string} rawData - The raw string data from which the JSON content will be extracted.
*
* @returns {IJSONRPCContent} An object containing the extracted JSON content and any remaining raw data.
*/
const length = parseInt(payloadLength ?? '0', 10);
const data = rawData.slice(0, length);
const remainingRawData = rawData.slice(length);
return {
extractedJSON: data,
remainingRawData,
};
}

interface ExecutionResultMessage extends Message {
params: ExecutionTestPayload;
}
Expand Down
Loading

0 comments on commit 044323f

Please sign in to comment.