test: disconnect from the debug adapter after each test
This change stops the debug adapter (or disconnects from the server)
after each test is run. There was also a bug that would crash the server
if the debug adapter was not running a delve instance and was asked to
disconnect.
Change-Id: I0c41fff7a051f5bf0eca6094fbc3dc022ed2f7ca
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/259957
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/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts
index 0054a12..bb8c1dd 100644
--- a/src/debugAdapter/goDebug.ts
+++ b/src/debugAdapter/goDebug.ts
@@ -854,6 +854,13 @@
args: DebugProtocol.DisconnectArguments
): Promise<void> {
log('DisconnectRequest');
+ if (!this.delve) {
+ log('DisconnectRequest to parent');
+ super.disconnectRequest(response, args);
+ log('DisconnectResponse');
+ return;
+ }
+
// For remote process, we have to issue a continue request
// before disconnecting.
if (this.delve.isRemoteDebugging) {
diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts
index 3b9a7d1..49de274 100644
--- a/test/integration/goDebug.test.ts
+++ b/test/integration/goDebug.test.ts
@@ -280,8 +280,8 @@
const DEBUG_ADAPTER = './dist/debugAdapter.js';
- const PROJECT_ROOT = path.join(__dirname, '../../../');
- const DATA_ROOT = path.join(PROJECT_ROOT, 'test/fixtures/');
+ const PROJECT_ROOT = path.join(__dirname, '..', '..', '..');
+ const DATA_ROOT = path.join(PROJECT_ROOT, 'test', 'fixtures');
let dc: DebugClient;
@@ -290,6 +290,8 @@
return dc.start();
});
+ teardown( () => dc.stop() );
+
suite('basic', () => {
test('unknown request should produce error', (done) => {
@@ -378,7 +380,7 @@
test('should stop on a breakpoint', () => {
const PROGRAM = path.join(DATA_ROOT, 'baseTest');
- const FILE = path.join(DATA_ROOT, 'baseTest/test.go');
+ const FILE = path.join(DATA_ROOT, 'baseTest', 'test.go');
const BREAKPOINT_LINE = 11;