Skip to content

Commit 35e59bb

Browse files
committed
[Tests] Add coverage for the continueing and stepping
1 parent f88542e commit 35e59bb

2 files changed

Lines changed: 59 additions & 2 deletions

File tree

editors/code/src/debugAdapter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,13 @@ export class DebugSession extends LoggingDebugSession {
281281

282282
protected continueRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments): void {
283283
console.log(`continueRequest ${JSON.stringify(args)}`);
284-
285284
this._logDebugger.gotoBreakpoint();
286285
this.sendEvent(new StoppedEvent('breakpoint', DebugSession._threadID));
287286
this.sendResponse(response);
288287
}
289288

290289
protected reverseContinueRequest(response: DebugProtocol.ReverseContinueResponse, args: DebugProtocol.ReverseContinueArguments): void {
291290
console.log(`reverseContinueRequest ${JSON.stringify(args)}`);
292-
293291
this._logDebugger.gotoBreakpoint(true);
294292
this.sendEvent(new StoppedEvent('breakpoint', DebugSession._threadID));
295293
this.sendResponse(response);

editors/code/src/test/suite/debugAdapter.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,63 @@ suite('DebugAdapter Test Suite', () => {
301301
assert.strictEqual(focusedLine, logDebugger.linenum(), 'Should focus current debugger line');
302302
});
303303
});
304+
305+
suite('Continue/Stepping Request Tests', () => {
306+
setup(() => {
307+
const logPath = "path-to-log";
308+
debugSession = createSession(logDebugger);
309+
logDebugger.setToLog(logPath, 5);
310+
logDebugger.setBreakpoints(logPath, [{line: 1}, {line: 3}]);
311+
});
312+
313+
test('continue moves to next breakpoint', () => {
314+
const session = debugSession as PatchedSession;
315+
const { response: captured, eventCount } = captureRequest(
316+
session,
317+
() => (session as any).continueRequest({body: undefined}, {threadId: 1})
318+
);
319+
320+
assert.ok(captured);
321+
assert.strictEqual(eventCount, 1);
322+
assert.strictEqual(logDebugger.linenum(), 3);
323+
});
324+
325+
test('reverse continue moves to previous breakpoint', () => {
326+
logDebugger.gotoBreakpoint();
327+
const session = debugSession as PatchedSession;
328+
const { response: captured, eventCount } = captureRequest(
329+
session,
330+
() => (session as any).reverseContinueRequest({body: undefined}, {threadId: 1})
331+
);
332+
333+
assert.ok(captured);
334+
assert.strictEqual(eventCount, 1);
335+
assert.strictEqual(logDebugger.linenum(), 1);
336+
});
337+
338+
test('next request moves to next line', () => {
339+
const session = debugSession as PatchedSession;
340+
const { response: captured, eventCount } = captureRequest(
341+
session,
342+
() => (session as any).nextRequest({body: undefined}, {threadId: 1})
343+
);
344+
345+
assert.ok(captured);
346+
assert.strictEqual(eventCount, 1);
347+
assert.strictEqual(logDebugger.linenum(), 2);
348+
});
349+
350+
test('step back request moves to previous line', () => {
351+
logDebugger.gotoBreakpoint();
352+
const session = debugSession as PatchedSession;
353+
const { response: captured, eventCount } = captureRequest(
354+
session,
355+
() => (session as any).stepBackRequest({body: undefined}, {threadId: 1})
356+
);
357+
358+
assert.ok(captured);
359+
assert.strictEqual(eventCount, 1);
360+
assert.strictEqual(logDebugger.linenum(), 2);
361+
});
362+
});
304363
});

0 commit comments

Comments
 (0)