fixed Location

Signed-off-by: René <snooz@posteo.de>
This commit is contained in:
René 2024-10-13 22:38:24 +02:00
parent edd4379078
commit 58c51f1be2
5 changed files with 33 additions and 25 deletions

View file

@ -51,7 +51,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
await this._startCollectingStacks(traceName); await this._startCollectingStacks(traceName);
} }
async group(name: string, options: { location?: string } = {}) { async group(name: string, options: { location?: { file: string, line?: number, column?: number } } = {}) {
await this._channel.tracingGroup({ name, options }); await this._channel.tracingGroup({ name, options });
} }

View file

@ -26,12 +26,13 @@ scheme.StackFrame = tObject({
column: tNumber, column: tNumber,
function: tOptional(tString), function: tOptional(tString),
}); });
scheme.Location = tObject({
file: tString,
line: tOptional(tNumber),
column: tOptional(tNumber),
});
scheme.Metadata = tObject({ scheme.Metadata = tObject({
location: tOptional(tObject({ location: tOptional(tType('Location')),
file: tString,
line: tOptional(tNumber),
column: tOptional(tNumber),
})),
apiName: tOptional(tString), apiName: tOptional(tString),
internal: tOptional(tBoolean), internal: tOptional(tBoolean),
stepId: tOptional(tString), stepId: tOptional(tString),
@ -2281,7 +2282,7 @@ scheme.DialogAcceptResult = tOptional(tObject({}));
scheme.DialogDismissParams = tOptional(tObject({})); scheme.DialogDismissParams = tOptional(tObject({}));
scheme.DialogDismissResult = tOptional(tObject({})); scheme.DialogDismissResult = tOptional(tObject({}));
scheme.TracingGroupOptions = tObject({ scheme.TracingGroupOptions = tObject({
location: tString, location: tOptional(tType('Location')),
}); });
scheme.TracingInitializer = tOptional(tObject({})); scheme.TracingInitializer = tOptional(tObject({}));
scheme.TracingTracingStartParams = tObject({ scheme.TracingTracingStartParams = tObject({

View file

@ -18,7 +18,7 @@ import fs from 'fs';
import os from 'os'; import os from 'os';
import path from 'path'; import path from 'path';
import type { NameValue } from '../../../common/types'; import type { NameValue } from '../../../common/types';
import type { TracingTracingStopChunkParams } from '@protocol/channels'; import type { TracingTracingStopChunkParams, StackFrame } from '@protocol/channels';
import { commandsWithTracingSnapshots } from '../../../protocol/debug'; import { commandsWithTracingSnapshots } from '../../../protocol/debug';
import { assert, createGuid, monotonicTime, SerializedFS, removeFolders, eventsHelper, type RegisteredListener } from '../../../utils'; import { assert, createGuid, monotonicTime, SerializedFS, removeFolders, eventsHelper, type RegisteredListener } from '../../../utils';
import { Artifact } from '../../artifact'; import { Artifact } from '../../artifact';
@ -196,9 +196,12 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
return { traceName: this._state.traceName }; return { traceName: this._state.traceName };
} }
async group(name: string, options: { location?: string } = {}): Promise<void> { async group(name: string, options: { location?: { file: string, line?: number, column?: number } } = {}): Promise<void> {
const location = options.location?.split(':', 2); const stackFrame: StackFrame = {
const file = location?.[0], line = location?.[1]; file: options.location?.file || '',
line: options.location?.line || 0,
column: options.location?.column || 0,
};
const event: trace.BeforeActionTraceEvent = { const event: trace.BeforeActionTraceEvent = {
type: 'before', type: 'before',
callId: `group-${this._groupId++}`, callId: `group-${this._groupId++}`,
@ -207,7 +210,7 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
class: 'Tracing', class: 'Tracing',
method: 'group', method: 'group',
params: { }, params: { },
stack: [{ file: file || '', line: line ? parseInt(line, 10) : 0, column: 0 }], stack: [stackFrame],
}; };
this._groupStack.push(event.callId); this._groupStack.push(event.callId);
this._appendTraceEvent(event); this._appendTraceEvent(event);

View file

@ -144,12 +144,14 @@ export type StackFrame = {
function?: string, function?: string,
}; };
export type Location = {
file: string,
line?: number,
column?: number,
};
export type Metadata = { export type Metadata = {
location?: { location?: Location,
file: string,
line?: number,
column?: number,
},
apiName?: string, apiName?: string,
internal?: boolean, internal?: boolean,
stepId?: string, stepId?: string,
@ -4078,7 +4080,7 @@ export interface DialogEvents {
} }
export type TracingGroupOptions = { export type TracingGroupOptions = {
location: string, location?: Location,
}; };
// ----------- Tracing ----------- // ----------- Tracing -----------

View file

@ -20,17 +20,19 @@ StackFrame:
column: number column: number
function: string? function: string?
Location:
type: object
properties:
file: string
line: number?
column: number?
# This object can be send with any rpc call in the "metadata" field. # This object can be send with any rpc call in the "metadata" field.
Metadata: Metadata:
type: object type: object
properties: properties:
location: location: Location?
type: object?
properties:
file: string
line: number?
column: number?
apiName: string? apiName: string?
internal: boolean? internal: boolean?
# Test runner step id. # Test runner step id.
@ -3180,7 +3182,7 @@ Dialog:
TracingGroupOptions: TracingGroupOptions:
type: object type: object
properties: properties:
location: string location: Location?
Tracing: Tracing:
type: interface type: interface