diff --git a/src/goTest.ts b/src/goTest.ts index 0f8ed381a..6fc34fdf3 100644 --- a/src/goTest.ts +++ b/src/goTest.ts @@ -6,7 +6,6 @@ import path = require('path'); import vscode = require('vscode'); - import { applyCodeCoverageToAllEditors } from './goCover'; import { isModSupported } from './goModules'; import { diff --git a/src/testUtils.ts b/src/testUtils.ts index 5e1d6af49..2293e790f 100644 --- a/src/testUtils.ts +++ b/src/testUtils.ts @@ -250,15 +250,21 @@ export function goTest(testconfig: TestConfig): Thenable { outTargets.push(''); } else { outTargets.push(...targets); - outTargets.push(...testconfig.flags); } - outputChannel.appendLine(['Running tool:', goRuntimePath, ...outTargets].join(' ')); - outputChannel.appendLine(''); args.push(...targets); + // ensure that user provided flags are appended last (allow use of -args ...) + // ignore user provided -run flag if we are already using it + if (args.indexOf('-run') > -1) { + removeRunFlag(testconfig.flags); + } args.push(...testconfig.flags); + outTargets.push(...testconfig.flags); + outputChannel.appendLine(['Running tool:', goRuntimePath, ...outTargets].join(' ')); + outputChannel.appendLine(''); + const tp = cp.spawn(goRuntimePath, args, { env: testEnvVars, cwd: testconfig.dir }); const outBuf = new LineBuffer(); const errBuf = new LineBuffer(); @@ -405,3 +411,10 @@ function targetArgs(testconfig: TestConfig): Array { } return params; } + +function removeRunFlag(flags: string[]): void { + const index: number = flags.indexOf('-run'); + if (index !== -1) { + flags.splice(index, 2); + } +} diff --git a/src/util.ts b/src/util.ts index 741574536..995700ee4 100644 --- a/src/util.ts +++ b/src/util.ts @@ -15,6 +15,7 @@ import { outputChannel } from './goStatus'; import { NearestNeighborDict, Node } from './avlTree'; import { getCurrentPackage } from './goModules'; import { buildDiagnosticCollection, lintDiagnosticCollection, vetDiagnosticCollection } from './goMain'; +import { getTestFlags } from './testUtils'; const extensionId: string = 'ms-vscode.Go'; const extensionVersion: string = vscode.extensions.getExtension(extensionId).packageJSON.version;