MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / captureDebugSessionCustomEvents

Function captureDebugSessionCustomEvents

src/test/helpers.ts:1205–1241  ·  view source on GitHub ↗
(startDebug: () => void, expectMultipleSessions = false)

Source from the content-addressed store, hash-verified

1203}
1204
1205export async function captureDebugSessionCustomEvents(startDebug: () => void, expectMultipleSessions = false): Promise<vs.DebugSessionCustomEvent[]> {
1206 let totalSessionsStarted = 0;
1207 const sessions = new Set<vs.DebugSession>();
1208 let startSub: IAmDisposable | undefined;
1209 let endSub: IAmDisposable | undefined;
1210 const events: vs.DebugSessionCustomEvent[] = [];
1211
1212 const startPromise = new Promise<void>((resolve) => {
1213 startSub = vs.debug.onDidStartDebugSession((s) => {
1214 sessions.add(s);
1215 totalSessionsStarted++;
1216 resolve();
1217 });
1218 });
1219 const eventSub = vs.debug.onDidReceiveDebugSessionCustomEvent((e) => {
1220 if (sessions.has(e.session))
1221 events.push(e);
1222 });
1223 const endPromise = new Promise<void>((resolve) => {
1224 endSub = vs.debug.onDidTerminateDebugSession(async (s) => {
1225 sessions.delete(s);
1226 // Allow some time for another session to start in case of multi-session test runs.
1227 if (expectMultipleSessions)
1228 await waitFor(() => totalSessionsStarted > 1);
1229 if (sessions.size === 0)
1230 resolve();
1231 });
1232 });
1233
1234 startDebug();
1235 await Promise.all([startPromise, endPromise]);
1236 startSub?.dispose();
1237 endSub?.dispose();
1238 eventSub.dispose();
1239
1240 return events;
1241}
1242
1243export function prepareHasRunFile(root: string, name: string) {
1244 const hasRunFile = path.join(root, `scripts/has_run/${name}`);

Callers 3

dart_test.test.tsFile · 0.90

Calls 5

waitForFunction · 0.90
hasMethod · 0.80
deleteMethod · 0.80
disposeMethod · 0.65
addMethod · 0.45

Tested by 1