Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back otherConsoleOptions with UTs #4065

Merged
merged 4 commits into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"loc.input.help.pathtoCustomTestAdapters": "Directory path to custom test adapters. Nuget restored adapters are automatically searched for.",
"loc.input.label.codeCoverageEnabled": "Code coverage enabled",
"loc.input.help.codeCoverageEnabled": "Collect code coverage information from the test run.",
"loc.input.label.otherConsoleOptions": "Other console options",
"loc.input.help.otherConsoleOptions": "Other Console options that can be passed to vstest.console.exe. Click on the help link below for more details.",
"loc.input.label.testRunTitle": "Test run title",
"loc.input.help.testRunTitle": "Provide a name for the test run.",
"loc.input.label.platform": "Build platform",
Expand Down Expand Up @@ -86,5 +88,6 @@
"loc.messages.tiaNotSupportedInDta": "Running only impacted tests is not supported when using the multi-agent phase setting. This option will be ignored.",
"loc.messages.overrideNotSupported": "Overriding test run parameters is supported only with runsettings file. This option will be ignored.",
"loc.messages.vs2013NotSupportedInDta": "Running tests using Visual Studio 2013 with multi-agent phase settings is not supported.",
"loc.messages.configureDtaAgentFailed": "Configuring the test agent with the server failed even after %d retries with error %s"
"loc.messages.configureDtaAgentFailed": "Configuring the test agent with the server failed even after %d retries with error %s",
"loc.messages.otherConsoleOptionsNotSupported": "Other console options is not supported when using the multi-agent phase setting. This option will be ignored."
}
8 changes: 4 additions & 4 deletions Tasks/VsTest/distributedtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class DistributedTest {
await this.startDtaExecutionHost(agentId);
await this.startDtaTestRun();
try {
if(this.dtaPid !== -1) {
if (this.dtaPid !== -1) {
tl.debug('Trying to kill the Modules/DTAExecutionHost.exe process with pid :' + this.dtaPid);
process.kill(this.dtaPid);
}
Expand Down Expand Up @@ -65,7 +65,7 @@ export class DistributedTest {

const exeInfo = await versionFinder.locateVSTestConsole(this.dtaTestConfig);
if (exeInfo) {
var exelocation = path.dirname(exeInfo)
const exelocation = path.dirname(exeInfo)
tl.debug('Adding env var DTA.TestWindow.Path = ' + exelocation);

// Split the TestWindow path out of full path - if we can't find it, will assume
Expand Down Expand Up @@ -120,7 +120,7 @@ export class DistributedTest {
}

//Modify settings file to enable configurations and data collectors.
var settingsFile = this.dtaTestConfig.settingsFile;
let settingsFile = this.dtaTestConfig.settingsFile;
try {
settingsFile = await settingsHelper.updateSettingsFileAsRequired(this.dtaTestConfig.settingsFile, this.dtaTestConfig.runInParallel, this.dtaTestConfig.tiaConfig, null, false, this.dtaTestConfig.overrideTestrunParameters);
//Reset override option so that it becomes a no-op in TaskExecutionHost
Expand Down Expand Up @@ -157,7 +157,7 @@ export class DistributedTest {

private async cleanUp(temporarySettingsFile: string) {
//cleanup the runsettings file
if (temporarySettingsFile && this.dtaTestConfig.settingsFile != temporarySettingsFile) {
if (temporarySettingsFile && this.dtaTestConfig.settingsFile !== temporarySettingsFile) {
try {
tl.rmRF(temporarySettingsFile, true);
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions Tasks/VsTest/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface TestConfigurations {
testplan: number;
testSuites: number[];
testPlanConfigId: number;
otherConsoleOptions: string;
}

export interface DtaTestConfigurations extends TestConfigurations {
Expand Down
28 changes: 8 additions & 20 deletions Tasks/VsTest/runvstest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import tl = require('vsts-task-lib/task');
import models = require('./models')
import taskInputParser = require('./taskinputparser')
import localTest = require('./vstest')
import path = require('path');
import distributedTest = require('./distributedtest')
import * as tl from 'vsts-task-lib/task';
import * as models from './models';
import * as taskInputParser from './taskinputparser';
import * as localTest from './vstest';
import * as path from 'path';
import * as distributedTest from './distributedtest';

try {
const parallelExecution = tl.getVariable('System.ParallelExecutionType');
Expand All @@ -16,8 +16,8 @@ try {
|| testType.toLowerCase() === 'testplan' || testType.toLowerCase() === 'testrun') {
tl.debug('Going to the DTA Flow..');
tl.debug('***********************');
var dtaTestConfig = taskInputParser.getDistributedTestConfigurations();

const dtaTestConfig = taskInputParser.getDistributedTestConfigurations();

const test = new distributedTest.DistributedTest(dtaTestConfig);
test.runDistributedTest();
Expand All @@ -31,15 +31,3 @@ try {
tl.setResult(tl.TaskResult.Failed, error);
}

function getDtaInstanceId(): number {
const taskInstanceIdString = tl.getVariable('DTA_INSTANCE_ID');
let taskInstanceId: number = 1;
if (taskInstanceIdString) {
const instanceId: number = Number(taskInstanceIdString);
if (!isNaN(instanceId)) {
taskInstanceId = instanceId + 1;
}
}
tl.setVariable('DTA_INSTANCE_ID', taskInstanceId.toString());
return taskInstanceId;
}
12 changes: 11 additions & 1 deletion Tasks/VsTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@
"helpMarkDown": "Collect code coverage information from the test run.",
"groupName": "executionOptions"
},
{
"name": "otherConsoleOptions",
"type": "string",
"label": "Other console options",
"defaultValue": "",
"required": false,
"helpMarkDown": "Other Console options that can be passed to vstest.console.exe. Click on the help link below for more details.",
"groupName": "executionOptions"
},
{
"name": "testRunTitle",
"type": "string",
Expand Down Expand Up @@ -367,6 +376,7 @@
"tiaNotSupportedInDta": "Running only impacted tests is not supported when using the multi-agent phase setting. This option will be ignored.",
"overrideNotSupported": "Overriding test run parameters is supported only with runsettings file. This option will be ignored.",
"vs2013NotSupportedInDta": "Running tests using Visual Studio 2013 with multi-agent phase settings is not supported.",
"configureDtaAgentFailed": "Configuring the test agent with the server failed even after %d retries with error %s"
"configureDtaAgentFailed": "Configuring the test agent with the server failed even after %d retries with error %s",
"otherConsoleOptionsNotSupported": "Other console options is not supported when using the multi-agent phase setting. This option will be ignored."
}
}
12 changes: 11 additions & 1 deletion Tasks/VsTest/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@
"helpMarkDown": "ms-resource:loc.input.help.codeCoverageEnabled",
"groupName": "executionOptions"
},
{
"name": "otherConsoleOptions",
"type": "string",
"label": "ms-resource:loc.input.label.otherConsoleOptions",
"defaultValue": "",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.otherConsoleOptions",
"groupName": "executionOptions"
},
{
"name": "testRunTitle",
"type": "string",
Expand Down Expand Up @@ -367,6 +376,7 @@
"tiaNotSupportedInDta": "ms-resource:loc.messages.tiaNotSupportedInDta",
"overrideNotSupported": "ms-resource:loc.messages.overrideNotSupported",
"vs2013NotSupportedInDta": "ms-resource:loc.messages.vs2013NotSupportedInDta",
"configureDtaAgentFailed": "ms-resource:loc.messages.configureDtaAgentFailed"
"configureDtaAgentFailed": "ms-resource:loc.messages.configureDtaAgentFailed",
"otherConsoleOptionsNotSupported": "ms-resource:loc.messages.otherConsoleOptionsNotSupported"
}
}
46 changes: 25 additions & 21 deletions Tasks/VsTest/taskinputparser.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import path = require('path');
import Q = require('q');
import tl = require('vsts-task-lib/task');
import tr = require('vsts-task-lib/toolrunner');
import models = require('./models');
import utils = require('./helpers');
import * as path from 'path';
import * as Q from 'q';
import * as tl from 'vsts-task-lib/task';
import * as tr from 'vsts-task-lib/toolrunner';
import * as models from './models';
import * as utils from './helpers';
import * as os from 'os';

let os = require('os');
let uuid = require('node-uuid');
const uuid = require('node-uuid');

export function getDistributedTestConfigurations(): models.DtaTestConfigurations {
tl.setResourcePath(path.join(__dirname, 'task.json'));
const dtaConfiguration = {} as models.DtaTestConfigurations;
initTestConfigurations(dtaConfiguration);

if(dtaConfiguration.vsTestLocationMethod === utils.Constants.vsTestVersionString && dtaConfiguration.vsTestVersion === '12.0') {
if (dtaConfiguration.vsTestLocationMethod === utils.Constants.vsTestVersionString && dtaConfiguration.vsTestVersion === '12.0') {
throw (tl.loc('vs2013NotSupportedInDta'));
}
if(dtaConfiguration.tiaConfig.tiaEnabled) {

if (dtaConfiguration.tiaConfig.tiaEnabled) {
tl.warning(tl.loc('tiaNotSupportedInDta'));
dtaConfiguration.tiaConfig.tiaEnabled = false;
}
if(dtaConfiguration.runTestsInIsolation) {
if (dtaConfiguration.runTestsInIsolation) {
tl.warning(tl.loc('runTestInIsolationNotSupported'));
}
if (dtaConfiguration.otherConsoleOptions) {
tl.warning(tl.loc('otherConsoleOptionsNotSupported'));
}

dtaConfiguration.numberOfAgentsInPhase = 0;
const totalJobsInPhase = parseInt(tl.getVariable('SYSTEM_TOTALJOBSINPHASE'));
if(!isNaN(totalJobsInPhase)) {
if (!isNaN(totalJobsInPhase)) {
dtaConfiguration.numberOfAgentsInPhase = totalJobsInPhase;
}

Expand Down Expand Up @@ -61,8 +64,8 @@ function initDtaEnvironment(): models.DtaEnvironment {
const taskInstanceId = getDtaInstanceId();
const parallelExecution = tl.getVariable('System.ParallelExecutionType');

if(releaseId) {
if(parallelExecution && parallelExecution.toLowerCase() === 'multiconfiguration') {
if (releaseId) {
if (parallelExecution && parallelExecution.toLowerCase() === 'multiconfiguration') {
const jobId = tl.getVariable('System.JobId');
dtaEnvironment.environmentUri = 'dta://env/' + projectName + '/_apis/release/' + releaseId + '/' + phaseId + '/' + jobId + '/' + taskInstanceId;
} else {
Expand Down Expand Up @@ -104,24 +107,25 @@ function initTestConfigurations(testConfiguration: models.TestConfigurations) {
testConfiguration.runTestsInIsolation = tl.getBoolInput('runTestsInIsolation');
testConfiguration.tiaConfig = getTiaConfiguration();
testConfiguration.testSelection = tl.getInput('testSelector');
testConfiguration.otherConsoleOptions = tl.getInput('otherConsoleOptions');

if(testConfiguration.testSelection.toLowerCase() === 'testplan') {
if (testConfiguration.testSelection.toLowerCase() === 'testplan') {
testConfiguration.testplan = parseInt(tl.getInput('testPlan'));
testConfiguration.testPlanConfigId = parseInt(tl.getInput('testConfiguration'));

var testSuiteStrings = tl.getDelimitedInput('testSuite', ',', true);
const testSuiteStrings = tl.getDelimitedInput('testSuite', ',', true);
testConfiguration.testSuites = new Array<number>();
testSuiteStrings.forEach(element => {
testConfiguration.testSuites.push(parseInt(element));
});
}

testConfiguration.vsTestLocationMethod = tl.getInput('vstestLocationMethod');
if(testConfiguration.vsTestLocationMethod === utils.Constants.vsTestVersionString) {
if (testConfiguration.vsTestLocationMethod === utils.Constants.vsTestVersionString) {
testConfiguration.vsTestVersion = tl.getInput('vsTestVersion');
if(utils.Helper.isNullEmptyOrUndefined(testConfiguration.vsTestVersion)) {
if (utils.Helper.isNullEmptyOrUndefined(testConfiguration.vsTestVersion)) {
tl._writeLine('vsTestVersion is null or empty');
throw new Error("vsTestVersion is null or empty");
throw new Error('vsTestVersion is null or empty');
}
} else {
testConfiguration.vsTestLocation = tl.getInput('vsTestLocation');
Expand All @@ -142,7 +146,7 @@ function getTiaConfiguration() : models.TiaConfiguration {
tiaConfiguration.tiaRebaseLimit = tl.getInput('runAllTestsAfterXBuilds');
tiaConfiguration.fileLevel = tl.getVariable('tia.filelevel');
tiaConfiguration.sourcesDir = tl.getVariable('build.sourcesdirectory');
tiaConfiguration.tiaFilterPaths = tl.getVariable("TIA_IncludePathFilters");
tiaConfiguration.tiaFilterPaths = tl.getVariable('TIA_IncludePathFilters');
tiaConfiguration.runIdFile = path.join(os.tmpdir(), uuid.v1() + '.txt');
tiaConfiguration.baseLineBuildIdFile = path.join(os.tmpdir(), uuid.v1() + '.txt');
tiaConfiguration.useNewCollector = false;
Expand Down
Loading