Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Remove user supplied -run flags when running tests (#2285)
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptonist authored and ramya-rao-a committed Oct 7, 2019
1 parent 3d14fed commit 83b8fea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/goTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import path = require('path');
import vscode = require('vscode');

import { applyCodeCoverageToAllEditors } from './goCover';
import { isModSupported } from './goModules';
import {
Expand Down
19 changes: 16 additions & 3 deletions src/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,21 @@ export function goTest(testconfig: TestConfig): Thenable<boolean> {
outTargets.push('<long arguments omitted>');
} 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();
Expand Down Expand Up @@ -405,3 +411,10 @@ function targetArgs(testconfig: TestConfig): Array<string> {
}
return params;
}

function removeRunFlag(flags: string[]): void {
const index: number = flags.indexOf('-run');
if (index !== -1) {
flags.splice(index, 2);
}
}
1 change: 1 addition & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 83b8fea

Please sign in to comment.