test: test the debug adapter on test launch configurations
These tests check that the debugger runs when launched with test
configurations.
Updates golang/vscode-go#137
Change-Id: Ie34f8a954fd27ef6abcd896ac23575429b50cd37
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/259800
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts
index 49de274..7f2311f 100644
--- a/test/integration/goDebug.test.ts
+++ b/test/integration/goDebug.test.ts
@@ -287,7 +287,8 @@
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() );
@@ -373,6 +374,67 @@
})
]);
});
+
+ 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', () => {
@@ -395,11 +457,31 @@
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');