Skip to content

Commit

Permalink
test: test the debug adapter on test launch configurations
Browse files Browse the repository at this point in the history
These tests check that the debugger runs when launched with test
configurations.

Updates #137

Change-Id: Ie34f8a954fd27ef6abcd896ac23575429b50cd37
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/259800
Trust: Suzy Mueller <[email protected]>
Run-TryBot: Suzy Mueller <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
  • Loading branch information
suzmue committed Oct 7, 2020
1 parent 51a4b3a commit 263c427
Showing 1 changed file with 85 additions and 3 deletions.
88 changes: 85 additions & 3 deletions test/integration/goDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ suite('Go Debug Adapter', function () {

setup( () => {
dc = new DebugClient('node', path.join(PROJECT_ROOT, DEBUG_ADAPTER), 'go');
return dc.start();
// To connect to a running debug server for debugging the tests, specify PORT.
return dc.start(/* PORT */);
});

teardown( () => dc.stop() );
Expand Down Expand Up @@ -373,6 +374,67 @@ suite('Go Debug Adapter', function () {
})
]);
});

test('should debug a file', () => {
const PROGRAM = path.join(DATA_ROOT, 'baseTest', 'test.go');
const config = {
name: 'Launch file',
type: 'go',
request: 'launch',
mode: 'auto',
program: PROGRAM
};

const debugConfig = debugConfigProvider.resolveDebugConfiguration(undefined, config);

return Promise.all([
dc.configurationSequence(),
dc.launch(debugConfig),
dc.waitForEvent('terminated')
]);
});

test('should debug a single test', () => {
const PROGRAM = path.join(DATA_ROOT, 'baseTest');
const config = {
name: 'Launch file',
type: 'go',
request: 'launch',
mode: 'test',
program: PROGRAM,
args: [
'-test.run',
'TestMe'
]
};

const debugConfig = debugConfigProvider.resolveDebugConfiguration(undefined, config);

return Promise.all([
dc.configurationSequence(),
dc.launch(debugConfig),
dc.waitForEvent('terminated')
]);
});

test('should debug a test package', () => {
const PROGRAM = path.join(DATA_ROOT, 'baseTest');
const config = {
name: 'Launch file',
type: 'go',
request: 'launch',
mode: 'test',
program: PROGRAM
};

const debugConfig = debugConfigProvider.resolveDebugConfiguration(undefined, config);

return Promise.all([
dc.configurationSequence(),
dc.launch(debugConfig),
dc.waitForEvent('terminated')
]);
});
});

suite('setBreakpoints', () => {
Expand All @@ -395,11 +457,31 @@ suite('Go Debug Adapter', function () {

return dc.hitBreakpoint(debugConfig, { path: FILE, line: BREAKPOINT_LINE } );
});

test('should stop on a breakpoint in test file', () => {

const PROGRAM = path.join(DATA_ROOT, 'baseTest');
const FILE = path.join(DATA_ROOT, 'baseTest', 'sample_test.go');

const BREAKPOINT_LINE = 15;

const config = {
name: 'Launch file',
type: 'go',
request: 'launch',
mode: 'test',
program: PROGRAM
};
const debugConfig = debugConfigProvider.resolveDebugConfiguration(undefined, config);

return dc.hitBreakpoint(debugConfig, { path: FILE, line: BREAKPOINT_LINE } );
});

});

suite('setExceptionBreakpoints', () => {
suite('panicBreakpoints', () => {

test('should stop on an exception', () => {
test('should stop on panic', () => {

const PROGRAM_WITH_EXCEPTION = path.join(DATA_ROOT, 'panic');

Expand Down

0 comments on commit 263c427

Please sign in to comment.