diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts index 1322e028c0..8f62265c3f 100644 --- a/src/debugAdapter/goDebug.ts +++ b/src/debugAdapter/goDebug.ts @@ -639,9 +639,11 @@ export class Delve { if (launchArgs.showLog) { dlvArgs.push('--log=' + launchArgs.showLog.toString()); - } - if (launchArgs.logOutput) { - dlvArgs.push('--log-output=' + launchArgs.logOutput); + // Only add the log output flag if we have already added the log flag. + // Otherwise, delve complains. + if (launchArgs.logOutput) { + dlvArgs.push('--log-output=' + launchArgs.logOutput); + } } if (launchArgs.cwd) { dlvArgs.push('--wd=' + launchArgs.cwd); diff --git a/src/goDebugFactory.ts b/src/goDebugFactory.ts index a247e30286..142d9eea5f 100644 --- a/src/goDebugFactory.ts +++ b/src/goDebugFactory.ts @@ -379,9 +379,11 @@ function spawnDlvDapServerProcess( dlvArgs.push(`--listen=${host}:${port}`); if (launchAttachArgs.showLog) { dlvArgs.push('--log=' + launchAttachArgs.showLog.toString()); - } - if (launchAttachArgs.logOutput) { - dlvArgs.push('--log-output=' + launchAttachArgs.logOutput); + // Only add the log output flag if we have already added the log flag. + // Otherwise, delve complains. + if (launchAttachArgs.logOutput) { + dlvArgs.push('--log-output=' + launchAttachArgs.logOutput); + } } const onWindows = process.platform === 'win32'; diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts index 89a48cd52e..9328784942 100644 --- a/test/integration/goDebug.test.ts +++ b/test/integration/goDebug.test.ts @@ -654,6 +654,22 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => { throw new Error('does not report error on invalid delve flag'); }); + test('should run program with showLog=false and logOutput specified', async () => { + const PROGRAM = path.join(DATA_ROOT, 'baseTest'); + + const config = { + name: 'Launch', + type: 'go', + request: 'launch', + mode: 'debug', + program: PROGRAM, + showLog: false, + logOutput: 'dap' + }; + const debugConfig = await initializeDebugConfig(config, true); + await Promise.all([dc.configurationSequence(), dc.launch(debugConfig), dc.waitForEvent('terminated')]); + }); + test('should handle threads request after initialization', async () => { const PROGRAM = path.join(DATA_ROOT, 'baseTest'); @@ -2068,13 +2084,15 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean) => { }); let testNumber = 0; - async function initializeDebugConfig(config: DebugConfiguration) { + async function initializeDebugConfig(config: DebugConfiguration, keepUserLog?: boolean) { if (isDlvDap) { config['debugAdapter'] = 'dlv-dap'; - // Log the output for easier test debugging. - config['logOutput'] = 'dap,debugger'; - config['showLog'] = true; - config['trace'] = 'verbose'; + if (!keepUserLog) { + // Log the output for easier test debugging. + config['logOutput'] = 'dap,debugger'; + config['showLog'] = true; + config['trace'] = 'verbose'; + } } else { config['debugAdapter'] = 'legacy'; // be explicit and prevent resolveDebugConfiguration from picking