Skip to content

Commit 884a05c

Browse files
committed
extension/test/integration: make debug tests less verbose
Disable DAP trace logging by default. Runnint tests with "DEBUG=1" will enable trace streaming to console. In case of failure, tests should print the buffered trace any way. And, provide a bogus process ID when testing for the local attach mode configuration. Missing process ID causes the extension to show a quick pick window (so users can pick processes). That is not handled during tests so results in unhandled promise/rejection message. Change-Id: Ie67240d4dae7c775fff19ac5a4687127b7b0d36a Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/619777 Reviewed-by: Hongxiang Jiang <[email protected]> kokoro-CI: kokoro <[email protected]> Commit-Queue: Hyang-Ah Hana Kim <[email protected]>
1 parent c94bf09 commit 884a05c

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

extension/test/integration/goDebug.test.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import util = require('util');
2727
import { affectedByIssue832 } from './testutils';
2828

2929
// For debugging test and streaming the trace instead of buffering, set this.
30-
const PRINT_TO_CONSOLE = false;
30+
const DEBUG = process.env['DEBUG'] === '1';
31+
function debugLog(msg: string) {
32+
if (DEBUG) console.log(msg);
33+
}
3134

3235
// Test suite adapted from:
3336
// https://github.com/microsoft/vscode-mock-debug/blob/master/src/tests/adapter.test.ts
@@ -190,7 +193,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
190193
new Promise<void>(async (resolve) => {
191194
const debugConfigCopy = Object.assign({}, debugConfig);
192195
delete debugConfigCopy.env;
193-
console.log(`Setting up attach request for ${JSON.stringify(debugConfigCopy)}.`);
196+
debugLog(`Setting up attach request for ${JSON.stringify(debugConfigCopy)}.`);
194197
const attachResult = await dc.attachRequest(debugConfig as DebugProtocol.AttachRequestArguments);
195198
assert.ok(attachResult.success);
196199
resolve();
@@ -199,7 +202,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
199202
]);
200203

201204
if (breakpoints.length) {
202-
console.log('Sending set breakpoints request for remote attach setup.');
205+
debugLog('Sending set breakpoints request for remote attach setup.');
203206
const breakpointsResult = await dc.setBreakpointsRequest({
204207
source: { path: breakpoints[0].path },
205208
breakpoints
@@ -210,7 +213,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
210213
assert.ok(breakpoint.verified);
211214
});
212215
}
213-
console.log('Sending configuration done request for remote attach setup.');
216+
debugLog('Sending configuration done request for remote attach setup.');
214217
const configurationDoneResult = await dc.configurationDoneRequest();
215218
assert.ok(configurationDoneResult.success);
216219
}
@@ -2099,21 +2102,10 @@ class DelveDAPDebugAdapterOnSocket extends proxy.DelveDAPOutputAdapter {
20992102
}
21002103

21012104
private constructor(config: DebugConfiguration) {
2102-
const logger = {
2103-
trace: (msg: string) => {
2104-
console.log(msg);
2105-
},
2106-
debug: (msg: string) => {
2107-
console.log(msg);
2108-
},
2109-
info: (msg: string) => {
2110-
console.log(msg);
2111-
},
2112-
error: (msg: string) => {
2113-
console.error(msg);
2114-
}
2105+
const log = (msg: string) => {
2106+
debugLog(msg);
21152107
};
2116-
super(config, logger);
2108+
super(config, { trace: log, debug: log, info: log, error: log });
21172109
}
21182110

21192111
private static TWO_CRLF = '\r\n\r\n';
@@ -2277,7 +2269,7 @@ class DelveDAPDebugAdapterOnSocket extends proxy.DelveDAPOutputAdapter {
22772269
private _log = [] as string[];
22782270
private log(msg: string) {
22792271
this._log.push(msg);
2280-
if (PRINT_TO_CONSOLE) {
2272+
if (DEBUG) {
22812273
console.log(msg);
22822274
}
22832275
}

extension/test/integration/goDebugConfiguration.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,8 @@ suite('Debug Configuration Infers Default Mode Property', () => {
10231023
name: 'Attach',
10241024
type: 'go',
10251025
request: 'attach',
1026-
program: '/path/to/main.go'
1026+
program: '/path/to/main.go',
1027+
processId: 12345 // set a bogus process ID to provent process quickPick popup.
10271028
};
10281029

10291030
debugConfigProvider.resolveDebugConfiguration(undefined, config);

0 commit comments

Comments
 (0)