diff --git a/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson b/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson
index 7c95ba69e1cf..5b8691b30b08 100644
--- a/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson
+++ b/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson
@@ -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, as documented here.
These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.
",
"loc.input.label.testRunTitle": "Test run title",
"loc.input.help.testRunTitle": "Provide a name for the test run.",
"loc.input.label.platform": "Build platform",
@@ -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."
}
\ No newline at end of file
diff --git a/Tasks/VsTest/distributedtest.ts b/Tasks/VsTest/distributedtest.ts
index 06c0ed0592f4..9f944eb6c5f3 100644
--- a/Tasks/VsTest/distributedtest.ts
+++ b/Tasks/VsTest/distributedtest.ts
@@ -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);
}
@@ -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
@@ -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
@@ -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) {
diff --git a/Tasks/VsTest/models.ts b/Tasks/VsTest/models.ts
index 1e7bcdfce07d..9d8c776be7e2 100644
--- a/Tasks/VsTest/models.ts
+++ b/Tasks/VsTest/models.ts
@@ -21,6 +21,7 @@ export interface TestConfigurations {
testplan: number;
testSuites: number[];
testPlanConfigId: number;
+ otherConsoleOptions: string;
}
export interface DtaTestConfigurations extends TestConfigurations {
diff --git a/Tasks/VsTest/runvstest.ts b/Tasks/VsTest/runvstest.ts
index 1b079a0b9433..dd51e2c050fb 100644
--- a/Tasks/VsTest/runvstest.ts
+++ b/Tasks/VsTest/runvstest.ts
@@ -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');
@@ -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();
@@ -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;
-}
diff --git a/Tasks/VsTest/task.json b/Tasks/VsTest/task.json
index b65bd3a7daab..caabdf8ea8f5 100644
--- a/Tasks/VsTest/task.json
+++ b/Tasks/VsTest/task.json
@@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 0,
- "Patch": 29
+ "Patch": 30
},
"demands": [
"vstest"
@@ -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, as documented here. These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.
",
+ "groupName": "executionOptions"
+ },
{
"name": "testRunTitle",
"type": "string",
@@ -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."
}
}
\ No newline at end of file
diff --git a/Tasks/VsTest/task.loc.json b/Tasks/VsTest/task.loc.json
index b1286f13b266..1328e4caf3cd 100644
--- a/Tasks/VsTest/task.loc.json
+++ b/Tasks/VsTest/task.loc.json
@@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 0,
- "Patch": 29
+ "Patch": 30
},
"demands": [
"vstest"
@@ -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",
@@ -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"
}
}
\ No newline at end of file
diff --git a/Tasks/VsTest/taskinputparser.ts b/Tasks/VsTest/taskinputparser.ts
index 7f6ce7acb77b..956d4a33a4bd 100644
--- a/Tasks/VsTest/taskinputparser.ts
+++ b/Tasks/VsTest/taskinputparser.ts
@@ -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;
}
@@ -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 {
@@ -104,12 +107,13 @@ 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();
testSuiteStrings.forEach(element => {
testConfiguration.testSuites.push(parseInt(element));
@@ -117,11 +121,11 @@ function initTestConfigurations(testConfiguration: models.TestConfigurations) {
}
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');
@@ -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;
diff --git a/Tasks/VsTest/vstest.ts b/Tasks/VsTest/vstest.ts
index f0f20b46b401..259355e4331c 100644
--- a/Tasks/VsTest/vstest.ts
+++ b/Tasks/VsTest/vstest.ts
@@ -13,11 +13,11 @@ var regedit = require('regedit');
var uuid = require('node-uuid');
var fs = require('fs');
var xml2js = require('xml2js');
-var perf = require("performance-now");
+var perf = require('performance-now');
var process = require('process');
-const runSettingsExt = ".runsettings";
-const testSettingsExt = ".testsettings";
+const runSettingsExt = '.runsettings';
+const testSettingsExt = '.testsettings';
let vstestConfig: models.VsTestConfigurations = undefined;
let tiaConfig: models.TiaConfiguration = undefined;
@@ -36,7 +36,7 @@ export async function startTest() {
//Try to find the results directory for clean up. This may change later if runsettings has results directory and location go runsettings file changes.
resultsDirectory = getTestResultsDirectory(vstestConfig.settingsFile, path.join(workingDirectory, 'TestResults'));
- tl.debug("TestRunResults Directory : " + resultsDirectory);
+ tl.debug('TestRunResults Directory : ' + resultsDirectory);
// clean up old testResults
tl.rmRF(resultsDirectory, true);
@@ -80,31 +80,31 @@ export async function startTest() {
function getTestAssemblies(): string[] {
if (isNullOrWhitespace(vstestConfig.testDropLocation)) {
vstestConfig.testDropLocation = systemDefaultWorkingDirectory;
- tl.debug("Search directory empty, defaulting to " + vstestConfig.testDropLocation);
+ tl.debug('Search directory empty, defaulting to ' + vstestConfig.testDropLocation);
}
- tl.debug("Searching for test assemblies in: " + vstestConfig.testDropLocation);
+ tl.debug('Searching for test assemblies in: ' + vstestConfig.testDropLocation);
return tl.findMatch(vstestConfig.testDropLocation, vstestConfig.sourceFilter);
}
function getVsTestRunnerDetails(vstestexeLocation: string): versionFinder.VSTestVersion {
- let vstestLocationEscaped = vstestexeLocation.replace(/\\/g, "\\\\");
- let wmicTool = tl.tool("wmic");
- let wmicArgs = ["datafile", "where", "name='".concat(vstestLocationEscaped, "'"), "get", "Version", "/Value"];
+ let vstestLocationEscaped = vstestexeLocation.replace(/\\/g, '\\\\');
+ let wmicTool = tl.tool('wmic');
+ let wmicArgs = ['datafile', 'where', 'name=\''.concat(vstestLocationEscaped, '\''), 'get', 'Version', '/Value'];
wmicTool.arg(wmicArgs);
let output = wmicTool.execSync();
- tl.debug("VSTest Version information: " + output.stdout);
+ tl.debug('VSTest Version information: ' + output.stdout);
- let verSplitArray = output.stdout.split("=");
+ let verSplitArray = output.stdout.split('=');
if (verSplitArray.length != 2) {
- tl.error(tl.loc("ErrorReadingVstestVersion"));
- throw new Error(tl.loc("ErrorReadingVstestVersion"));
+ tl.error(tl.loc('ErrorReadingVstestVersion'));
+ throw new Error(tl.loc('ErrorReadingVstestVersion'));
}
- let versionArray = verSplitArray[1].split(".");
+ let versionArray = verSplitArray[1].split('.');
if (versionArray.length != 4) {
- tl.warning(tl.loc("UnexpectedVersionString", output.stdout));
- throw new Error(tl.loc("UnexpectedVersionString", output.stdout));
+ tl.warning(tl.loc('UnexpectedVersionString', output.stdout));
+ throw new Error(tl.loc('UnexpectedVersionString', output.stdout));
}
let majorVersion = parseInt(versionArray[0]);
@@ -112,8 +112,8 @@ function getVsTestRunnerDetails(vstestexeLocation: string): versionFinder.VSTest
let patchNumber = parseInt(versionArray[2]);
if (isNaN(majorVersion) || isNaN(minorVersion) || isNaN(patchNumber)) {
- tl.warning(tl.loc("UnexpectedVersionNumber", verSplitArray[1]));
- throw new Error(tl.loc("UnexpectedVersionNumber", verSplitArray[1]));
+ tl.warning(tl.loc('UnexpectedVersionNumber', verSplitArray[1]));
+ throw new Error(tl.loc('UnexpectedVersionNumber', verSplitArray[1]));
}
switch (majorVersion) {
@@ -142,16 +142,16 @@ function getVstestArguments(settingsFile: string, tiaEnabled: boolean): string[]
});
if (vstestConfig.testcaseFilter) {
if (!tiaEnabled) {
- argsArray.push("/TestCaseFilter:" + vstestConfig.testcaseFilter);
+ argsArray.push('/TestCaseFilter:' + vstestConfig.testcaseFilter);
} else {
- tl.debug("Ignoring TestCaseFilter because Test Impact is enabled");
+ tl.debug('Ignoring TestCaseFilter because Test Impact is enabled');
}
}
if (settingsFile) {
if (pathExistsAsFile(settingsFile)) {
- argsArray.push("/Settings:" + settingsFile);
- utils.Helper.readFileContents(settingsFile, "utf-8").then(function (settings) {
- tl.debug("Running VsTest with settings : " + settings);
+ argsArray.push('/Settings:' + settingsFile);
+ utils.Helper.readFileContents(settingsFile, 'utf-8').then(function (settings) {
+ tl.debug('Running VsTest with settings : ' + settings);
});
}
else {
@@ -163,28 +163,28 @@ function getVstestArguments(settingsFile: string, tiaEnabled: boolean): string[]
}
if (vstestConfig.codeCoverageEnabled) {
- argsArray.push("/EnableCodeCoverage");
+ argsArray.push('/EnableCodeCoverage');
}
if (vstestConfig.runTestsInIsolation) {
- argsArray.push("/InIsolation");
+ argsArray.push('/InIsolation');
}
- argsArray.push("/logger:trx");
+ argsArray.push('/logger:trx');
if (vstestConfig.pathtoCustomTestAdapters) {
if (pathExistsAsDirectory(vstestConfig.pathtoCustomTestAdapters)) {
- argsArray.push("/TestAdapterPath:\"" + vstestConfig.pathtoCustomTestAdapters + "\"");
+ argsArray.push('/TestAdapterPath:\"' + vstestConfig.pathtoCustomTestAdapters + '\"');
} else {
- argsArray.push("/TestAdapterPath:\"" + path.dirname(vstestConfig.pathtoCustomTestAdapters) + "\"");
+ argsArray.push('/TestAdapterPath:\"' + path.dirname(vstestConfig.pathtoCustomTestAdapters) + '\"');
}
} else if (systemDefaultWorkingDirectory && isNugetRestoredAdapterPresent(systemDefaultWorkingDirectory)) {
- argsArray.push("/TestAdapterPath:\"" + systemDefaultWorkingDirectory + "\"");
+ argsArray.push('/TestAdapterPath:\"' + systemDefaultWorkingDirectory + '\"');
}
if (isDebugEnabled()) {
if (vstestRunnerDetails != null && vstestRunnerDetails.vstestDiagSupported()) {
- argsArray.push("/diag:" + vstestConfig.vstestDiagFile);
+ argsArray.push('/diag:' + vstestConfig.vstestDiagFile);
} else {
- tl.warning(tl.loc("VstestDiagNotSupported"));
+ tl.warning(tl.loc('VstestDiagNotSupported'));
}
}
@@ -192,17 +192,17 @@ function getVstestArguments(settingsFile: string, tiaEnabled: boolean): string[]
}
function isDebugEnabled(): boolean {
- let sysDebug = tl.getVariable("System.Debug");
- if (sysDebug == undefined) {
+ let sysDebug = tl.getVariable('System.Debug');
+ if (sysDebug === undefined) {
return false;
}
- return sysDebug.toLowerCase() === "true";
+ return sysDebug.toLowerCase() === 'true';
}
function addVstestArgs(argsArray: string[], vstest: any) {
- argsArray.forEach(function (arr) {
- vstest.arg(arr);
+ argsArray.forEach(function (arr: any) {
+ vstest.arg(arr);
});
}
@@ -210,7 +210,7 @@ function updateResponseFile(argsArray: string[], responseFile: string): Q.Promis
var defer = Q.defer();
argsArray.forEach(function (arr, i) {
if (!arr.startsWith('/')) {
- argsArray[i] = "\"" + arr + "\"";
+ argsArray[i] = '\"' + arr + '\"';
}
});
fs.appendFile(responseFile, os.EOL + argsArray.join(os.EOL), function (err) {
@@ -223,7 +223,7 @@ function updateResponseFile(argsArray: string[], responseFile: string): Q.Promis
}
function getTestSelectorLocation(): string {
- return path.join(__dirname, "TestSelector/TestSelector.exe");
+ return path.join(__dirname, 'TestSelector/TestSelector.exe');
}
function uploadTestResults(testResultsDirectory: string): Q.Promise {
@@ -236,16 +236,16 @@ function uploadTestResults(testResultsDirectory: string): Q.Promise {
var allFilesInResultsDirectory;
var resultFiles;
if (!isNullOrWhitespace(testResultsDirectory)) {
- resultFiles = tl.findMatch(testResultsDirectory, path.join(testResultsDirectory, "*.trx"));
+ resultFiles = tl.findMatch(testResultsDirectory, path.join(testResultsDirectory, '*.trx'));
}
var selectortool = tl.tool(getTestSelectorLocation());
- selectortool.arg("UpdateTestResults");
+ selectortool.arg('UpdateTestResults');
- if (tiaConfig.context === "CD") {
- definitionRunId = tl.getVariable("Release.ReleaseId");
+ if (tiaConfig.context === 'CD') {
+ definitionRunId = tl.getVariable('Release.ReleaseId');
} else {
- definitionRunId = tl.getVariable("Build.BuildId");
+ definitionRunId = tl.getVariable('Build.BuildId');
}
if (resultFiles && resultFiles[0]) {
@@ -255,13 +255,13 @@ function uploadTestResults(testResultsDirectory: string): Q.Promise {
selectortool.exec({
cwd: null,
env: {
- "collectionurl": tl.getVariable("System.TeamFoundationCollectionUri"),
- "projectid": tl.getVariable("System.TeamProject"),
- "definitionrunid": definitionRunId,
- "token": tl.getEndpointAuthorizationParameter("SystemVssConnection", "AccessToken", false),
- "resultfile": resultFile,
- "runidfile": tiaConfig.runIdFile,
- "context": tiaConfig.context,
+ 'collectionurl': tl.getVariable('System.TeamFoundationCollectionUri'),
+ 'projectid': tl.getVariable('System.TeamProject'),
+ 'definitionrunid': definitionRunId,
+ 'token': tl.getEndpointAuthorizationParameter('SystemVssConnection', 'AccessToken', false),
+ 'resultfile': resultFile,
+ 'runidfile': tiaConfig.runIdFile,
+ 'context': tiaConfig.context
},
silent: null,
failOnStdErr: null,
@@ -273,8 +273,8 @@ function uploadTestResults(testResultsDirectory: string): Q.Promise {
.then(function (code) {
endTime = perf();
elapsedTime = endTime - startTime;
- tl._writeLine("##vso[task.logissue type=warning;SubTaskName=UploadTestResults;SubTaskDuration=" + elapsedTime + "]");
- tl.debug(tl.loc("UploadTestResultsPerfTime", elapsedTime));
+ tl._writeLine('##vso[task.logissue type=warning;SubTaskName=UploadTestResults;SubTaskDuration=' + elapsedTime + ']');
+ tl.debug(tl.loc('UploadTestResultsPerfTime', elapsedTime));
defer.resolve(String(code));
})
.fail(function (err) {
@@ -284,63 +284,63 @@ function uploadTestResults(testResultsDirectory: string): Q.Promise {
}
function generateResponseFile(discoveredTests: string): Q.Promise {
- var startTime = perf();
- var endTime: number;
- var elapsedTime: number;
- var definitionRunId: string;
- var title: string;
- var platformInput: string;
- var configurationInput: string;
- var defer = Q.defer();
- var respFile = path.join(os.tmpdir(), uuid.v1() + ".txt");
- tl.debug("Response file will be generated at " + respFile);
- tl.debug("RunId file will be generated at " + tiaConfig.runIdFile);
- var selectortool = tl.tool(getTestSelectorLocation());
- selectortool.arg("GetImpactedtests");
-
- if (tiaConfig.context === "CD") {
+ const startTime = perf();
+ let endTime: number;
+ let elapsedTime: number;
+ let definitionRunId: string;
+ let title: string;
+ let platformInput: string;
+ let configurationInput: string;
+ const defer = Q.defer();
+ const respFile = path.join(os.tmpdir(), uuid.v1() + '.txt');
+ tl.debug('Response file will be generated at ' + respFile);
+ tl.debug('RunId file will be generated at ' + tiaConfig.runIdFile);
+ const selectortool = tl.tool(getTestSelectorLocation());
+ selectortool.arg('GetImpactedtests');
+
+ if (tiaConfig.context === 'CD') {
// Release context. Passing Release Id.
- definitionRunId = tl.getVariable("Release.ReleaseId");
+ definitionRunId = tl.getVariable('Release.ReleaseId');
} else {
// Build context. Passing build id.
- definitionRunId = tl.getVariable("Build.BuildId");
+ definitionRunId = tl.getVariable('Build.BuildId');
}
if (vstestConfig.buildPlatform) {
platformInput = vstestConfig.buildPlatform;
} else {
- platformInput = "";
+ platformInput = '';
}
if (vstestConfig.testRunTitle) {
title = vstestConfig.testRunTitle;
} else {
- title = "";
+ title = '';
}
if (vstestConfig.buildConfig) {
configurationInput = vstestConfig.buildConfig;
} else {
- configurationInput = "";
+ configurationInput = '';
}
selectortool.exec({
cwd: null,
env: {
- "collectionurl": tl.getVariable("System.TeamFoundationCollectionUri"),
- "projectid": tl.getVariable("System.TeamProject"),
- "definitionrunid": definitionRunId,
- "releaseuri": tl.getVariable("release.releaseUri"),
- "releaseenvuri": tl.getVariable("release.environmentUri"),
- "token": tl.getEndpointAuthorizationParameter("SystemVssConnection", "AccessToken", false),
- "responsefilepath": respFile,
- "discoveredtestspath": discoveredTests,
- "runidfilepath": tiaConfig.runIdFile,
- "testruntitle": title,
- "baselinebuildfilepath": tiaConfig.baseLineBuildIdFile,
- "context": tiaConfig.context,
- "platform": platformInput,
- "configuration": configurationInput
+ 'collectionurl': tl.getVariable('System.TeamFoundationCollectionUri'),
+ 'projectid': tl.getVariable('System.TeamProject'),
+ 'definitionrunid': definitionRunId,
+ 'releaseuri': tl.getVariable('release.releaseUri'),
+ 'releaseenvuri': tl.getVariable('release.environmentUri'),
+ 'token': tl.getEndpointAuthorizationParameter('SystemVssConnection', 'AccessToken', false),
+ 'responsefilepath': respFile,
+ 'discoveredtestspath': discoveredTests,
+ 'runidfilepath': tiaConfig.runIdFile,
+ 'testruntitle': title,
+ 'baselinebuildfilepath': tiaConfig.baseLineBuildIdFile,
+ 'context': tiaConfig.context,
+ 'platform': platformInput,
+ 'configuration': configurationInput
},
silent: null,
failOnStdErr: null,
@@ -352,7 +352,7 @@ function generateResponseFile(discoveredTests: string): Q.Promise {
.then(function (code) {
endTime = perf();
elapsedTime = endTime - startTime;
- tl.debug(tl.loc("GenerateResponseFilePerfTime", elapsedTime));
+ tl.debug(tl.loc('GenerateResponseFilePerfTime', elapsedTime));
defer.resolve(respFile);
})
.fail(function (err) {
@@ -363,72 +363,72 @@ function generateResponseFile(discoveredTests: string): Q.Promise {
}
function publishCodeChanges(): Q.Promise {
- var startTime = perf();
- var endTime: number;
- var elapsedTime: number;
- var pathFilters: string;
- var definitionRunId: string;
- var definitionId: string;
- var prFlow: string;
- var rebaseLimit: string;
- var sourcesDirectory: string;
- var defer = Q.defer();
-
- var newprovider = "true";
+ const startTime = perf();
+ let endTime: number;
+ let elapsedTime: number;
+ let pathFilters: string;
+ let definitionRunId: string;
+ let definitionId: string;
+ let prFlow: string;
+ let rebaseLimit: string;
+ let sourcesDirectory: string;
+ const defer = Q.defer();
+
+ let newprovider = 'true';
if (getTIALevel() === 'method') {
- newprovider = "false";
+ newprovider = 'false';
}
- var selectortool = tl.tool(getTestSelectorLocation());
- selectortool.arg("PublishCodeChanges");
+ const selectortool = tl.tool(getTestSelectorLocation());
+ selectortool.arg('PublishCodeChanges');
- if (tiaConfig.context === "CD") {
+ if (tiaConfig.context === 'CD') {
// Release context. Passing Release Id.
- definitionRunId = tl.getVariable("Release.ReleaseId");
- definitionId = tl.getVariable("release.DefinitionId");
+ definitionRunId = tl.getVariable('Release.ReleaseId');
+ definitionId = tl.getVariable('release.DefinitionId');
} else {
// Build context. Passing build id.
- definitionRunId = tl.getVariable("Build.BuildId");
- definitionId = tl.getVariable("System.DefinitionId");
+ definitionRunId = tl.getVariable('Build.BuildId');
+ definitionId = tl.getVariable('System.DefinitionId');
}
- if (tiaConfig.isPrFlow && tiaConfig.isPrFlow.toUpperCase() === "TRUE") {
- prFlow = "true";
+ if (tiaConfig.isPrFlow && tiaConfig.isPrFlow.toUpperCase() === 'TRUE') {
+ prFlow = 'true';
} else {
- prFlow = "false";
+ prFlow = 'false';
}
if (tiaConfig.tiaRebaseLimit) {
rebaseLimit = tiaConfig.tiaRebaseLimit;
}
- if (typeof tiaConfig.tiaFilterPaths != 'undefined') {
+ if (typeof tiaConfig.tiaFilterPaths !== 'undefined') {
pathFilters = tiaConfig.tiaFilterPaths.trim();
} else {
- pathFilters = "";
+ pathFilters = '';
}
- if (typeof tiaConfig.sourcesDir != 'undefined') {
+ if (typeof tiaConfig.sourcesDir !== 'undefined') {
sourcesDirectory = tiaConfig.sourcesDir.trim();
} else {
- sourcesDirectory = "";
+ sourcesDirectory = '';
}
selectortool.exec({
cwd: null,
env: {
- "collectionurl": tl.getVariable("System.TeamFoundationCollectionUri"),
- "projectid": tl.getVariable("System.TeamProject"),
- "definitionrunid": definitionRunId,
- "definitionid": definitionId,
- "token": tl.getEndpointAuthorizationParameter("SystemVssConnection", "AccessToken", false),
- "sourcesdir": sourcesDirectory,
- "newprovider": newprovider,
- "prflow": prFlow,
- "rebaselimit": rebaseLimit,
- "baselinefile": tiaConfig.baseLineBuildIdFile,
- "context": tiaConfig.context,
- "filter": pathFilters
+ 'collectionurl': tl.getVariable('System.TeamFoundationCollectionUri'),
+ 'projectid': tl.getVariable('System.TeamProject'),
+ 'definitionrunid': definitionRunId,
+ 'definitionid': definitionId,
+ 'token': tl.getEndpointAuthorizationParameter('SystemVssConnection', 'AccessToken', false),
+ 'sourcesdir': sourcesDirectory,
+ 'newprovider': newprovider,
+ 'prflow': prFlow,
+ 'rebaselimit': rebaseLimit,
+ 'baselinefile': tiaConfig.baseLineBuildIdFile,
+ 'context': tiaConfig.context,
+ 'filter': pathFilters
},
silent: null,
failOnStdErr: null,
@@ -440,7 +440,7 @@ function publishCodeChanges(): Q.Promise {
.then(function (code) {
endTime = perf();
elapsedTime = endTime - startTime;
- tl.debug(tl.loc("PublishCodeChangesPerfTime", elapsedTime));
+ tl.debug(tl.loc('PublishCodeChangesPerfTime', elapsedTime));
defer.resolve(String(code));
})
.fail(function (err) {
@@ -451,24 +451,31 @@ function publishCodeChanges(): Q.Promise {
}
function executeVstest(testResultsDirectory: string, parallelRunSettingsFile: string, vsVersion: number, argsArray: string[]): Q.Promise {
- var defer = Q.defer();
- var vstest = tl.tool(vstestRunnerDetails.vstestExeLocation);
+ const defer = Q.defer();
+ const vstest = tl.tool(vstestRunnerDetails.vstestExeLocation);
addVstestArgs(argsArray, vstest);
+ // Adding the other console options here
+ // => Because it should be added as ".line" inorder to pass multiple parameters
+ // => Parsing will be taken care by .line
+ // https://github.com/Microsoft/vsts-task-lib/blob/master/node/docs/vsts-task-lib.md#toolrunnerToolRunnerline
+ if (!utils.Helper.isNullEmptyOrUndefined(vstestConfig.otherConsoleOptions)) {
+ vstest.line(vstestConfig.otherConsoleOptions);
+ }
+
//Re-calculate the results directory based on final runsettings and clean up again if required.
resultsDirectory = getTestResultsDirectory(parallelRunSettingsFile, path.join(workingDirectory, 'TestResults'));
tl.rmRF(resultsDirectory, true);
tl.mkdirP(resultsDirectory);
tl.cd(workingDirectory);
- var ignoreTestFailures = vstestConfig.ignoreVstestFailure && vstestConfig.ignoreVstestFailure.toLowerCase() === "true";
+ const ignoreTestFailures = vstestConfig.ignoreVstestFailure && vstestConfig.ignoreVstestFailure.toLowerCase() === 'true';
vstest.exec({ ignoreReturnCode: ignoreTestFailures, failOnStdErr: false })
.then(function (code) {
cleanUp(parallelRunSettingsFile);
if (ignoreTestFailures === true) {
defer.resolve(0); // ignore failures.
- }
- else {
+ } else {
defer.resolve(code);
}
})
@@ -487,15 +494,15 @@ function executeVstest(testResultsDirectory: string, parallelRunSettingsFile: st
}
function getVstestTestsList(vsVersion: number): Q.Promise {
- var defer = Q.defer();
- var tempFile = path.join(os.tmpdir(), uuid.v1() + ".txt");
- tl.debug("Discovered tests listed at: " + tempFile);
- var argsArray: string[] = [];
+ let defer = Q.defer();
+ let tempFile = path.join(os.tmpdir(), uuid.v1() + '.txt');
+ tl.debug('Discovered tests listed at: ' + tempFile);
+ let argsArray: string[] = [];
testAssemblyFiles.forEach(function (testAssembly) {
- var testAssemblyPath = testAssembly;
+ let testAssemblyPath = testAssembly;
if (systemDefaultWorkingDirectory && !pathExistsAsFile(testAssembly)) {
- var expandedPath = path.join(systemDefaultWorkingDirectory, testAssembly);
+ const expandedPath = path.join(systemDefaultWorkingDirectory, testAssembly);
if (pathExistsAsFile(expandedPath)) {
testAssemblyPath = expandedPath;
}
@@ -503,32 +510,32 @@ function getVstestTestsList(vsVersion: number): Q.Promise {
argsArray.push(testAssemblyPath);
});
- tl.debug("The list of discovered tests is generated at " + tempFile);
+ tl.debug('The list of discovered tests is generated at ' + tempFile);
- argsArray.push("/ListFullyQualifiedTests");
- argsArray.push("/ListTestsTargetPath:" + tempFile);
+ argsArray.push('/ListFullyQualifiedTests');
+ argsArray.push('/ListTestsTargetPath:' + tempFile);
if (vstestConfig.testcaseFilter) {
- argsArray.push("/TestCaseFilter:" + vstestConfig.testcaseFilter);
+ argsArray.push('/TestCaseFilter:' + vstestConfig.testcaseFilter);
}
if (vstestConfig.pathtoCustomTestAdapters) {
if (pathExistsAsDirectory(vstestConfig.pathtoCustomTestAdapters)) {
- argsArray.push("/TestAdapterPath:\"" + vstestConfig.pathtoCustomTestAdapters + "\"");
+ argsArray.push('/TestAdapterPath:\"' + vstestConfig.pathtoCustomTestAdapters + '\"');
} else {
- argsArray.push("/TestAdapterPath:\"" + path.dirname(vstestConfig.pathtoCustomTestAdapters) + "\"");
+ argsArray.push('/TestAdapterPath:\"' + path.dirname(vstestConfig.pathtoCustomTestAdapters) + '\"');
}
} else if (systemDefaultWorkingDirectory && isNugetRestoredAdapterPresent(systemDefaultWorkingDirectory)) {
- argsArray.push("/TestAdapterPath:\"" + systemDefaultWorkingDirectory + "\"");
+ argsArray.push('/TestAdapterPath:\"' + systemDefaultWorkingDirectory + '\"');
}
- if (vstestConfig.pathtoCustomTestAdapters && vstestConfig.pathtoCustomTestAdapters.toLowerCase().indexOf("usevsixextensions:true") != -1) {
- argsArray.push("/UseVsixExtensions:true");
+ if (vstestConfig.pathtoCustomTestAdapters && vstestConfig.pathtoCustomTestAdapters.toLowerCase().indexOf('usevsixextensions:true') !== -1) {
+ argsArray.push('/UseVsixExtensions:true');
}
let vstest = tl.tool(vstestRunnerDetails.vstestExeLocation);
if (vsVersion === 14.0) {
- tl.debug("Visual studio 2015 selected. Selecting vstest.console.exe in task ");
- let vsTestPath = path.join(__dirname, "TestSelector/14.0/vstest.console.exe") // Use private vstest as the changes to discover tests are not there in update3
+ tl.debug('Visual studio 2015 selected. Selecting vstest.console.exe in task ');
+ const vsTestPath = path.join(__dirname, 'TestSelector/14.0/vstest.console.exe') // Use private vstest as the changes to discover tests are not there in update3
vstest = tl.tool(vsTestPath);
}
addVstestArgs(argsArray, vstest);
@@ -539,7 +546,7 @@ function getVstestTestsList(vsVersion: number): Q.Promise {
defer.resolve(tempFile);
})
.fail(function (err) {
- tl.debug("Listing tests from VsTest failed.");
+ tl.debug('Listing tests from VsTest failed.');
tl.error(err);
defer.resolve(err);
});
@@ -547,23 +554,23 @@ function getVstestTestsList(vsVersion: number): Q.Promise {
}
function cleanFiles(responseFile: string, listFile: string): void {
- tl.debug("Deleting the response file " + responseFile);
+ tl.debug('Deleting the response file ' + responseFile);
tl.rmRF(responseFile, true);
- tl.debug("Deleting the discovered tests file " + listFile);
+ tl.debug('Deleting the discovered tests file ' + listFile);
tl.rmRF(listFile, true);
- tl.debug("Deleting the baseline build id file " + tiaConfig.baseLineBuildIdFile);
+ tl.debug('Deleting the baseline build id file ' + tiaConfig.baseLineBuildIdFile);
tl.rmRF(tiaConfig.baseLineBuildIdFile, true);
}
function deleteVstestDiagFile(): void {
if (pathExistsAsFile(vstestConfig.vstestDiagFile)) {
- tl.debug("Deleting vstest diag file " + vstestConfig.vstestDiagFile);
+ tl.debug('Deleting vstest diag file ' + vstestConfig.vstestDiagFile);
tl.rmRF(vstestConfig.vstestDiagFile, true);
}
}
function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion: number): Q.Promise {
- var defer = Q.defer();
+ const defer = Q.defer();
if (isTiaAllowed()) {
publishCodeChanges()
.then(function (status) {
@@ -572,26 +579,26 @@ function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion
generateResponseFile(listFile)
.then(function (responseFile) {
if (isEmptyResponseFile(responseFile)) {
- tl.debug("Empty response file detected. All tests will be executed.");
+ tl.debug('Empty response file detected. All tests will be executed.');
executeVstest(testResultsDirectory, settingsFile, vsVersion, getVstestArguments(settingsFile, false))
.then(function (vscode) {
uploadTestResults(testResultsDirectory)
.then(function (code) {
- if (!isNaN(+code) && +code != 0) {
+ if (!isNaN(+code) && +code !== 0) {
defer.resolve(+code);
- } else if (vscode != 0) {
+ } else if (vscode !== 0) {
defer.resolve(vscode);
}
defer.resolve(0);
})
.fail(function (code) {
- tl.debug("Test Run Updation failed!");
+ tl.debug('Test Run Updation failed!');
defer.resolve(1);
})
.finally(function () {
cleanFiles(responseFile, listFile);
- tl.debug("Deleting the run id file" + tiaConfig.runIdFile);
+ tl.debug('Deleting the run id file' + tiaConfig.runIdFile);
tl.rmRF(tiaConfig.runIdFile, true);
});
})
@@ -605,45 +612,45 @@ function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion
responseContainsNoTests(responseFile)
.then(function (noTestsAvailable) {
if (noTestsAvailable) {
- tl.debug("No tests impacted. Not running any tests.");
- uploadTestResults("")
+ tl.debug('No tests impacted. Not running any tests.');
+ uploadTestResults('')
.then(function (code) {
- if (!isNaN(+code) && +code != 0) {
+ if (!isNaN(+code) && +code !== 0) {
defer.resolve(+code);
}
defer.resolve(0);
})
.fail(function (code) {
- tl.debug("Test Run Updation failed!");
+ tl.debug('Test Run Updation failed!');
defer.resolve(1);
})
.finally(function () {
cleanFiles(responseFile, listFile);
- tl.debug("Deleting the run id file" + tiaConfig.runIdFile);
+ tl.debug('Deleting the run id file' + tiaConfig.runIdFile);
tl.rmRF(tiaConfig.runIdFile, true);
});
} else {
updateResponseFile(getVstestArguments(settingsFile, true), responseFile)
.then(function (updatedFile) {
- executeVstest(testResultsDirectory, settingsFile, vsVersion, ["@" + updatedFile])
+ executeVstest(testResultsDirectory, settingsFile, vsVersion, ['@' + updatedFile])
.then(function (vscode) {
uploadTestResults(testResultsDirectory)
.then(function (code) {
- if (!isNaN(+code) && +code != 0) {
+ if (!isNaN(+code) && +code !== 0) {
defer.resolve(+code);
- } else if (vscode != 0) {
+ } else if (vscode !== 0) {
defer.resolve(vscode);
}
defer.resolve(0);
})
.fail(function (code) {
- tl.debug("Test Run Updation failed!");
+ tl.debug('Test Run Updation failed!');
defer.resolve(1);
})
.finally(function () {
cleanFiles(responseFile, listFile);
- tl.debug("Deleting the run id file" + tiaConfig.runIdFile);
+ tl.debug('Deleting the run id file' + tiaConfig.runIdFile);
tl.rmRF(tiaConfig.runIdFile, true);
});
})
@@ -661,21 +668,21 @@ function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion
.then(function (vscode) {
uploadTestResults(testResultsDirectory)
.then(function (code) {
- if (!isNaN(+code) && +code != 0) {
+ if (!isNaN(+code) && +code !== 0) {
defer.resolve(+code);
- } else if (vscode != 0) {
+ } else if (vscode !== 0) {
defer.resolve(vscode);
}
defer.resolve(0);
})
.fail(function (code) {
- tl.debug("Test Run Updation failed!");
+ tl.debug('Test Run Updation failed!');
defer.resolve(1);
})
.finally(function () {
cleanFiles(responseFile, listFile);
- tl.debug("Deleting the run id file" + tiaConfig.runIdFile);
+ tl.debug('Deleting the run id file' + tiaConfig.runIdFile);
tl.rmRF(tiaConfig.runIdFile, true);
});
})
@@ -704,20 +711,20 @@ function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion
.then(function (vscode) {
uploadTestResults(testResultsDirectory)
.then(function (code) {
- if (!isNaN(+code) && +code != 0) {
+ if (!isNaN(+code) && +code !== 0) {
defer.resolve(+code);
- } else if (vscode != 0) {
+ } else if (vscode !== 0) {
defer.resolve(vscode);
}
defer.resolve(0);
})
.fail(function (code) {
- tl.debug("Test Run Updation failed!");
+ tl.debug('Test Run Updation failed!');
defer.resolve(1);
})
.finally(function () {
- tl.debug("Deleting the discovered tests file" + listFile);
+ tl.debug('Deleting the discovered tests file' + listFile);
tl.rmRF(listFile, true);
});
})
@@ -749,7 +756,7 @@ function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion
});
});
} else {
- tl.debug("Non TIA mode of test execution");
+ tl.debug('Non TIA mode of test execution');
executeVstest(testResultsDirectory, settingsFile, vsVersion, getVstestArguments(settingsFile, false))
.then(function (code) {
defer.resolve(code);
@@ -762,19 +769,19 @@ function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion
}
function invokeVSTest(testResultsDirectory: string): Q.Promise {
- var defer = Q.defer();
- if (vstestConfig.vsTestVersion && vstestConfig.vsTestVersion.toLowerCase() === "latest") {
+ let defer = Q.defer();
+ if (vstestConfig.vsTestVersion && vstestConfig.vsTestVersion.toLowerCase() === 'latest') {
vstestConfig.vsTestVersion = null;
}
try {
- let disableTIA = tl.getVariable("DisableTestImpactAnalysis");
- if (disableTIA !== undefined && disableTIA.toLowerCase() === "true") {
+ const disableTIA = tl.getVariable('DisableTestImpactAnalysis');
+ if (disableTIA !== undefined && disableTIA.toLowerCase() === 'true') {
tiaConfig.tiaEnabled = false;
}
if (tiaConfig.tiaEnabled && (vstestRunnerDetails === null || !vstestRunnerDetails.isTestImpactSupported())) {
- tl.warning(tl.loc("VstestTIANotSupported"));
+ tl.warning(tl.loc('VstestTIANotSupported'));
tiaConfig.tiaEnabled = false;
}
} catch (e) {
@@ -789,9 +796,10 @@ function invokeVSTest(testResultsDirectory: string): Q.Promise {
}
setRunInParallellIfApplicable();
- var newSettingsFile = vstestConfig.settingsFile;
- var vsVersion = vstestRunnerDetails.majorVersion;
+ let newSettingsFile = vstestConfig.settingsFile;
+ const vsVersion = vstestRunnerDetails.majorVersion;
+
if (newSettingsFile) {
if (!pathExistsAsFile(newSettingsFile)) {
if (!tl.exist(newSettingsFile)) { // because this is filepath input build puts default path in the input. To avoid that we are checking this.
@@ -830,13 +838,13 @@ function invokeVSTest(testResultsDirectory: string): Q.Promise {
function publishTestResults(testResultsDirectory: string) {
if (testResultsDirectory) {
- let resultFiles = tl.findMatch(testResultsDirectory, path.join(testResultsDirectory, "*.trx"));
+ let resultFiles = tl.findMatch(testResultsDirectory, path.join(testResultsDirectory, '*.trx'));
- if (resultFiles && resultFiles.length != 0) {
- var tp = new tl.TestPublisher("VSTest");
- tp.publish(resultFiles, "false", vstestConfig.buildPlatform, vstestConfig.buildConfig, vstestConfig.testRunTitle, vstestConfig.publishRunAttachments);
+ if (resultFiles && resultFiles.length !== 0) {
+ const tp = new tl.TestPublisher('VSTest');
+ tp.publish(resultFiles, 'false', vstestConfig.buildPlatform, vstestConfig.buildConfig, vstestConfig.testRunTitle, vstestConfig.publishRunAttachments);
} else {
- tl._writeLine("##vso[task.logissue type=warning;code=002003;]");
+ tl._writeLine('##vso[task.logissue type=warning;code=002003;]');
tl.warning(tl.loc('NoResultsToPublish'));
}
}
@@ -844,7 +852,7 @@ function publishTestResults(testResultsDirectory: string) {
function cleanUp(temporarySettingsFile: string) {
//cleanup the runsettings file
- if (temporarySettingsFile && vstestConfig.settingsFile != temporarySettingsFile) {
+ if (temporarySettingsFile && vstestConfig.settingsFile !== temporarySettingsFile) {
try {
tl.rmRF(temporarySettingsFile, true);
} catch (error) {
@@ -854,17 +862,17 @@ function cleanUp(temporarySettingsFile: string) {
}
function isNugetRestoredAdapterPresent(rootDirectory: string): boolean {
- var allFiles = tl.find(rootDirectory);
- var adapterFiles = tl.match(allFiles, "**\\packages\\**\\*TestAdapter.dll", { matchBase: true, nocase: true });
-
- if (adapterFiles && adapterFiles.length != 0) {
- for (var i = 0; i < adapterFiles.length; i++) {
- var adapterFile = adapterFiles[i];
- var packageIndex = adapterFile.indexOf('packages') + 7;
- var packageFolder = adapterFile.substr(0, packageIndex);
- var parentFolder = path.dirname(packageFolder);
- var solutionFiles = tl.match(allFiles, path.join(parentFolder, "*.sln"), { matchBase: true, nocase: true });
- if (solutionFiles && solutionFiles.length != 0) {
+ let allFiles = tl.find(rootDirectory);
+ let adapterFiles = tl.match(allFiles, '**\\packages\\**\\*TestAdapter.dll', { matchBase: true, nocase: true });
+
+ if (adapterFiles && adapterFiles.length !== 0) {
+ for (let i = 0; i < adapterFiles.length; i++) {
+ const adapterFile = adapterFiles[i];
+ const packageIndex = adapterFile.indexOf('packages') + 7;
+ const packageFolder = adapterFile.substr(0, packageIndex);
+ const parentFolder = path.dirname(packageFolder);
+ const solutionFiles = tl.match(allFiles, path.join(parentFolder, '*.sln'), { matchBase: true, nocase: true });
+ if (solutionFiles && solutionFiles.length !== 0) {
return true;
}
}
@@ -880,7 +888,7 @@ function getTestResultsDirectory(settingsFile: string, defaultResultsDirectory:
}
try {
- const xmlContents = utils.Helper.readFileContentsSync(settingsFile, "utf-8");
+ const xmlContents = utils.Helper.readFileContentsSync(settingsFile, 'utf-8');
const parser = new xml2js.Parser();
parser.parseString(xmlContents, function (err, result) {
@@ -939,15 +947,15 @@ function isTiaAllowed(): boolean {
}
function getTIALevel() {
- if (tiaConfig.fileLevel && tiaConfig.fileLevel.toUpperCase() === "FALSE") {
- return "method";
+ if (tiaConfig.fileLevel && tiaConfig.fileLevel.toUpperCase() === 'FALSE') {
+ return 'method';
}
- return "file";
+ return 'file';
}
function responseContainsNoTests(filePath: string): Q.Promise {
- return utils.Helper.readFileContents(filePath, "utf-8").then(function (resp) {
- if (resp === "/Tests:") {
+ return utils.Helper.readFileContents(filePath, 'utf-8').then(function (resp) {
+ if (resp === '/Tests:') {
return true;
}
else {
diff --git a/Tests-Legacy/L0/VsTest/_suite.ts b/Tests-Legacy/L0/VsTest/_suite.ts
index 62f1771f5ae1..62ea85242359 100644
--- a/Tests-Legacy/L0/VsTest/_suite.ts
+++ b/Tests-Legacy/L0/VsTest/_suite.ts
@@ -14,8 +14,8 @@ import shell = require('shelljs');
var ps = shell.which('powershell.exe');
var psr = null;
-const sysVstestLocation = "\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe";
-const sysVstest15Location = "\\vs2017\\installation\\folder\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe";
+const sysVstestLocation = '\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe';
+const sysVstest15Location = '\\vs2017\\installation\\folder\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe';
function setResponseFile(name: string) {
process.env['MOCK_RESPONSES'] = path.join(__dirname, name);
@@ -135,7 +135,7 @@ describe('VsTest Suite', function () {
}
if (!os.type().match(/^Win/)) {
- console.log("Skipping vstest tests. Vstest tests run only on windows.")
+ console.log('Skipping vstest tests. Vstest tests run only on windows.')
return;
}
@@ -157,7 +157,7 @@ describe('VsTest Suite', function () {
})
it('Vstest task with test results files filter', (done) => {
- let vstestCmd = [sysVstestLocation, "/source/dir/someFile2 /source/dir/someFile1", "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile2 /source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -169,7 +169,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -182,7 +182,7 @@ describe('VsTest Suite', function () {
it('VSTest task with VS2017 installed on build agent and latest option is selected in definition', (done) => {
- let vstestCmd = ["\\vs2017\\installation\\folder\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe", "/path/to/test.dll", "/logger:trx"].join(" ");
+ let vstestCmd = ['\\vs2017\\installation\\folder\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe', '/path/to/test.dll', '/logger:trx'].join(' ');
setResponseFile('vs2017.json');
let tr = new trm.TaskRunner('VSTest');
@@ -193,7 +193,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result' + tr.stderr + tr.stdout);
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr + tr.stdout);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr + tr.stdout);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest' + tr.stdout + tr.stderr);
done();
@@ -205,7 +205,7 @@ describe('VsTest Suite', function () {
it('Vstest task with test results files filter and exclude filter', (done) => {
- let vstestCmd = [sysVstestLocation, "/source/dir/someFile1", "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -217,7 +217,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -230,7 +230,7 @@ describe('VsTest Suite', function () {
it('Vstest task with test results files as path', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -242,7 +242,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -255,7 +255,7 @@ describe('VsTest Suite', function () {
it('Vstest task when vstest fails', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile2 /source/dir/someFile1', "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile2 /source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestFails.json');
let tr = new trm.TaskRunner('VSTest');
@@ -280,7 +280,7 @@ describe('VsTest Suite', function () {
it('Vstest task when vstest is set to ignore test failures', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile2 /source/dir/someFile1', "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile2 /source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestSucceedsOnIgnoreFailure.json');
let tr = new trm.TaskRunner('VSTest');
@@ -292,7 +292,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should have not written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should have not written to stderr. error: ' + tr.stderr);
assert(!tr.failed, 'task should not have failed');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish/) < 0, 'should not have published test results.');
@@ -305,7 +305,7 @@ describe('VsTest Suite', function () {
it('Vstest task with test case filter', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/TestCaseFilter:testFilter", "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/TestCaseFilter:testFilter', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -318,7 +318,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -331,7 +331,7 @@ describe('VsTest Suite', function () {
it('Vstest task with enable code coverage', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/EnableCodeCoverage", "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/EnableCodeCoverage', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -344,7 +344,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -357,7 +357,7 @@ describe('VsTest Suite', function () {
it('Vstest task with settings file', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/Settings:settings.runsettings", "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/Settings:settings.runsettings', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -365,12 +365,12 @@ describe('VsTest Suite', function () {
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
tr.setInput('vsTestVersion', '14.0');
- tr.setInput('runSettingsFile', "settings.runsettings");
+ tr.setInput('runSettingsFile', 'settings.runsettings');
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -383,7 +383,7 @@ describe('VsTest Suite', function () {
it('Vstest task with invalid settings file', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -391,7 +391,7 @@ describe('VsTest Suite', function () {
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
tr.setInput('vsTestVersion', '14.0');
- tr.setInput('runSettingsFile', "random.runsettings");
+ tr.setInput('runSettingsFile', 'random.runsettings');
tr.run()
.then(() => {
@@ -408,7 +408,7 @@ describe('VsTest Suite', function () {
it('Vstest task with run in parallel and vs 2013', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -421,7 +421,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -435,7 +435,7 @@ describe('VsTest Suite', function () {
it('Vstest task with run in parallel and vs 2015 below update1', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -448,7 +448,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -463,8 +463,8 @@ describe('VsTest Suite', function () {
it('Vstest task with run in parallel and vs 2017', (done) => {
setResponseFile('vstestGoodRunInParallel.json');
-
let tr = new trm.TaskRunner('VSTest', false, true, true); // normalize slash, ignore temp path, enable regex match
+
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -474,7 +474,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
assert(tr.stdout.search(/Install Visual Studio 2015 Update 3 or higher on your build agent machine to run the tests in parallel./) < 0, 'should not have given a warning for update3 or higher requirement');
@@ -500,7 +500,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
assert(tr.stdout.search(/Install Visual Studio 2015 Update 3 or higher on your build agent machine to run the tests in parallel./) < 0, 'should not have given a warning for update3 or higher requirement.');
@@ -513,7 +513,7 @@ describe('VsTest Suite', function () {
it('Vstest task with custom adapter path', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx", "/TestAdapterPath:path/to/customadapters"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx', '/TestAdapterPath:path/to/customadapters'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -521,12 +521,12 @@ describe('VsTest Suite', function () {
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
tr.setInput('vsTestVersion', '14.0');
- tr.setInput('pathtoCustomTestAdapters', "path/to/customadapters");
+ tr.setInput('pathtoCustomTestAdapters', 'path/to/customadapters');
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -540,7 +540,7 @@ describe('VsTest Suite', function () {
it('Vstest task with Nuget restored adapter path', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx", "/TestAdapterPath:/source/dir"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx', '/TestAdapterPath:/source/dir'].join(' ');
setResponseFile('vstestGoodwithNugetAdapter.json');
let tr = new trm.TaskRunner('VSTest');
@@ -552,7 +552,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
@@ -566,7 +566,7 @@ describe('VsTest Suite', function () {
it('Vstest task with runsettings file and tia.enabled set to false', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/Settings:settings.runsettings", "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/Settings:settings.runsettings', '/logger:trx'].join(' ');
setResponseFile('vstestGoodWithTiaDisabled.json');
let tr = new trm.TaskRunner('VSTest');
@@ -574,15 +574,15 @@ describe('VsTest Suite', function () {
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
tr.setInput('vsTestVersion', '14.0');
- tr.setInput('runSettingsFile', "settings.runsettings");
+ tr.setInput('runSettingsFile', 'settings.runsettings');
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
- var result = (tr.stdout.search(/No settings file provided or the provided settings file does not exist. Creating run settings file for enabling test impact data collector/) < 0);
+ let result = (tr.stdout.search(/No settings file provided or the provided settings file does not exist. Creating run settings file for enabling test impact data collector/) < 0);
assert(result, 'should add not test impact collector to runsettings file.');
done();
})
@@ -593,7 +593,7 @@ describe('VsTest Suite', function () {
it('Vstest task with runsettings file and tia.enabled undefined', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/Settings:settings.runsettings", "/logger:trx"].join(" ");
+ let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/Settings:settings.runsettings', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
let tr = new trm.TaskRunner('VSTest');
@@ -601,15 +601,15 @@ describe('VsTest Suite', function () {
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
tr.setInput('vsTestVersion', '14.0');
- tr.setInput('runSettingsFile', "settings.runsettings");
+ tr.setInput('runSettingsFile', 'settings.runsettings');
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
- var result = (tr.stdout.search(/No settings file provided or the provided settings file does not exist. Creating run settings file for enabling test impact data collector/) < 0);
+ let result = (tr.stdout.search(/No settings file provided or the provided settings file does not exist. Creating run settings file for enabling test impact data collector/) < 0);
assert(result, 'should add not test impact collector to runsettings file.');
done();
})
@@ -622,19 +622,19 @@ describe('VsTest Suite', function () {
it('Vstest task with results directory as absolute path in run settings file', (done) => {
let settingsFilePath = path.join(__dirname, 'data', 'ResultsDirectoryWithAbsolutePath.runsettings');
- var resultsDirectory = 'C:\\test'; // settings file has this result directory.
+ let resultsDirectory = 'C:\\test'; // settings file has this result directory.
- var responseJsonFilePath: string = path.join(__dirname, 'vstestGood.json');
- var responseJsonContent = JSON.parse(fs.readFileSync(responseJsonFilePath, 'utf-8'));
+ let responseJsonFilePath: string = path.join(__dirname, 'vstestGood.json');
+ let responseJsonContent = JSON.parse(fs.readFileSync(responseJsonFilePath, 'utf-8'));
responseJsonContent = mockHelper.setupMockResponsesForPaths(responseJsonContent, [settingsFilePath, resultsDirectory]);
- var newResponseFilePath: string = path.join(__dirname, 'newresponse.json');
+ let newResponseFilePath: string = path.join(__dirname, 'newresponse.json');
fs.writeFileSync(newResponseFilePath, JSON.stringify(responseJsonContent));
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile(path.basename(newResponseFilePath));
- let tr = new trm.TaskRunner('VSTest');
+ const tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -643,7 +643,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
- assert(tr.stdout.indexOf("creating path: " + resultsDirectory) >= 0, 'should have created results directory.');
+ assert(tr.stdout.indexOf('creating path: ' + resultsDirectory) >= 0, 'should have created results directory.');
done();
})
.fail((err) => {
@@ -653,19 +653,19 @@ describe('VsTest Suite', function () {
it('Vstest task with results directory as relative path in run settings file', (done) => {
- let settingsFilePath = path.join(__dirname, 'data', 'ResultsDirectoryWithRelativePath.runsettings');
- let resultsDirectory = path.join(__dirname, 'data', 'result'); // settings file has this result directory.
+ const settingsFilePath = path.join(__dirname, 'data', 'ResultsDirectoryWithRelativePath.runsettings');
+ const resultsDirectory = path.join(__dirname, 'data', 'result'); // settings file has this result directory.
- let responseJsonFilePath: string = path.join(__dirname, 'vstestGood.json');
+ const responseJsonFilePath: string = path.join(__dirname, 'vstestGood.json');
let responseJsonContent = JSON.parse(fs.readFileSync(responseJsonFilePath, 'utf-8'));
responseJsonContent = mockHelper.setupMockResponsesForPaths(responseJsonContent, [settingsFilePath, resultsDirectory]);
- let newResponseFilePath: string = path.join(__dirname, 'newresponse.json');
+ const newResponseFilePath: string = path.join(__dirname, 'newresponse.json');
fs.writeFileSync(newResponseFilePath, JSON.stringify(responseJsonContent));
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile(path.basename(newResponseFilePath));
- let tr = new trm.TaskRunner('VSTest');
+ const tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -675,7 +675,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
//vstest task reads result directory from settings file and creates it.
- assert(tr.stdout.indexOf("creating path: " + resultsDirectory) >= 0, 'should have created results directory.');
+ assert(tr.stdout.indexOf('creating path: ' + resultsDirectory) >= 0, 'should have created results directory.');
done();
})
.fail((err) => {
@@ -685,19 +685,19 @@ describe('VsTest Suite', function () {
it('Vstest task with results directory empty in run settings file', (done) => {
- let settingsFilePath = path.join(__dirname, 'data', 'RunSettingsWithoutResultsDirectory.runsettings');
- let resultsDirectory = '\\source\\dir\\TestResults'; // when results directory is empty in settings file, default result directory should be considered.
+ const settingsFilePath = path.join(__dirname, 'data', 'RunSettingsWithoutResultsDirectory.runsettings');
+ const resultsDirectory = '\\source\\dir\\TestResults'; // when results directory is empty in settings file, default result directory should be considered.
- let responseJsonFilePath: string = path.join(__dirname, 'vstestGood.json');
+ const responseJsonFilePath: string = path.join(__dirname, 'vstestGood.json');
let responseJsonContent = JSON.parse(fs.readFileSync(responseJsonFilePath, 'utf-8'));
responseJsonContent = mockHelper.setupMockResponsesForPaths(responseJsonContent, [settingsFilePath, resultsDirectory]);
- let newResponseFilePath: string = path.join(__dirname, 'newresponse.json');
+ const newResponseFilePath: string = path.join(__dirname, 'newresponse.json');
fs.writeFileSync(newResponseFilePath, JSON.stringify(responseJsonContent));
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile(path.basename(newResponseFilePath));
- let tr = new trm.TaskRunner('VSTest');
+ const tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -707,7 +707,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
//vstest task reads result directory from settings file and creates it.
- assert(tr.stdout.indexOf("creating path: " + resultsDirectory) >= 0, 'should have created results directory.');
+ assert(tr.stdout.indexOf('creating path: ' + resultsDirectory) >= 0, 'should have created results directory.');
done();
})
.fail((err) => {
@@ -717,10 +717,10 @@ describe('VsTest Suite', function () {
it('Vstest task should not use diag option when system.debug is not set', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
- let tr = new trm.TaskRunner('VSTest');
+ const tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -728,7 +728,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
console.log(tr.stderr.length);
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.indexOf('/diag') < 0, '/diag option should not be used for vstest.console.exe');
@@ -741,10 +741,10 @@ describe('VsTest Suite', function () {
it('Vstest task should not use diag option when system.debug is set to false', (done) => {
- let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx"].join(" ");
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGoodSysDebugFalse.json');
- let tr = new trm.TaskRunner('VSTest');
+ const tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -752,7 +752,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
console.log('The errors are..........' + tr.stderr);
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.indexOf('/diag') < 0, '/diag option should not be used for vstest.console.exe');
@@ -765,10 +765,10 @@ describe('VsTest Suite', function () {
it('Vstest task verify test results are dropped at correct location in case of release', (done) => {
- let vstestCmd = [sysVstestLocation, '/artifacts/dir/someFile1', "/logger:trx"].join(" ");
+ const vstestCmd = [sysVstestLocation, '/artifacts/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestRM.json');
- let tr = new trm.TaskRunner('VSTest');
+ const tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/artifacts/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -777,7 +777,7 @@ describe('VsTest Suite', function () {
tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=\\artifacts\\dir\\TestResults\\a.trx;\]/) >= 0, 'should publish test results.');
@@ -792,10 +792,10 @@ describe('VsTest Suite', function () {
it('Vstest task with serach directory input', (done) => {
- let vstestCmd = [sysVstestLocation, '/search/dir/someFile1', "/logger:trx"].join(" ");
+ const vstestCmd = [sysVstestLocation, '/search/dir/someFile1', '/logger:trx'].join(' ');
setResponseFile('vstestGood.json');
- let tr = new trm.TaskRunner('VSTest');
+ const tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/search/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
@@ -803,7 +803,7 @@ describe('VsTest Suite', function () {
tr.setInput('searchDirectory', '/search/dir')
tr.run()
.then(() => {
- assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.indexOf('/diag') < 0, '/diag option should not be used for vstest.console.exe');
@@ -813,4 +813,87 @@ describe('VsTest Suite', function () {
done(err);
});
});
+
+ it('Vstest task with single otherConsoleOptions', (done) => {
+
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx', '/UseVsixExtensions'].join(' ');
+ setResponseFile('vstestOtherConsoleOptions.json');
+
+ const tr = new trm.TaskRunner('VSTest');
+ tr.setInput('testSelector', 'testAssemblies');
+ tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
+ tr.setInput('vstestLocationMethod', 'version');
+ tr.setInput('vsTestVersion', '14.0');
+ tr.setInput('otherConsoleOptions', '/UseVsixExtensions');
+
+ tr.run()
+ .then(() => {
+ assert(tr.resultWasSet, 'task should have set a result');
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.succeeded, 'task should have succeeded');
+ assert(tr.ran(vstestCmd), 'should have run vstest');
+ assert(tr.stdout.indexOf('running vstest with other console params single..') >= 0, 'should have proper console output.');
+ done();
+ })
+ .fail((err) => {
+ console.log(tr.stdout);
+ done(err);
+ });
+ });
+
+ it('Vstest task with multiple otherConsoleOptions', (done) => {
+
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/logger:trx', '/UseVsixExtensions', '/Enablecodecoverage'].join(' ');
+ setResponseFile('vstestOtherConsoleOptions.json');
+
+ const tr = new trm.TaskRunner('VSTest');
+ tr.setInput('testSelector', 'testAssemblies');
+ tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
+ tr.setInput('vstestLocationMethod', 'version');
+ tr.setInput('vsTestVersion', '14.0');
+ tr.setInput('otherConsoleOptions', '/UseVsixExtensions /Enablecodecoverage');
+
+ tr.run()
+ .then(() => {
+ assert(tr.resultWasSet, 'task should have set a result');
+ assert(tr.stderr.length === 0, 'should not have written to stderr. error: ' + tr.stderr);
+ assert(tr.succeeded, 'task should have succeeded');
+ assert(tr.ran(vstestCmd), 'should have run vstest');
+ assert(tr.stdout.indexOf('running vstest with other console params multiple..') >= 0, 'should have proper console output.');
+ done();
+ })
+ .fail((err) => {
+ console.log(tr.stdout);
+ done(err);
+ });
+ });
+
+ it('Vstest task with /Enablecodecoverage as otherConsoleOptions as well as Code Coverage enabled in UI', (done) => {
+
+ const vstestCmd = [sysVstestLocation, '/source/dir/someFile1', '/EnableCodeCoverage', '/logger:trx', '/Enablecodecoverage'].join(' ');
+ setResponseFile('vstestOtherConsoleOptions.json');
+
+ const tr = new trm.TaskRunner('VSTest');
+ tr.setInput('testSelector', 'testAssemblies');
+ tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
+ tr.setInput('vstestLocationMethod', 'version');
+ tr.setInput('vsTestVersion', '14.0');
+ tr.setInput('otherConsoleOptions', '/Enablecodecoverage');
+ tr.setInput('codeCoverageEnabled', 'true');
+
+ tr.run()
+ .then(() => {
+ assert(tr.resultWasSet, 'task should have set a result');
+ assert(tr.failed, 'task should have succeeded');
+ assert(tr.ran(vstestCmd), 'should have run vstest');
+ assert(tr.stdout.indexOf('running vstest with other console duplicate params..') >= 0, 'should have proper console output.');
+ assert(tr.stdout.indexOf('The parameter \"/EnableCodeCoverage\" should be provided only once.') >= 0, 'should have code coverage duplicate issue.');
+ assert(tr.stdout.indexOf('##vso[task.issue type=error;]Error: \\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe failed with return code: 1') >= 0, 'should have proper error message.');
+ done();
+ })
+ .fail((err) => {
+ console.log(tr.stdout);
+ done(err);
+ });
+ })
});
\ No newline at end of file
diff --git a/Tests-Legacy/L0/VsTest/vstestOtherConsoleOptions.json b/Tests-Legacy/L0/VsTest/vstestOtherConsoleOptions.json
new file mode 100644
index 000000000000..69644eb0e553
--- /dev/null
+++ b/Tests-Legacy/L0/VsTest/vstestOtherConsoleOptions.json
@@ -0,0 +1,45 @@
+{
+ "getVariable": {
+ "System.DefaultWorkingDirectory": "/source/dir",
+ "build.sourcesdirectory": "/source/dir",
+ "VS140COMNTools": "/vs/path",
+ "VSTest_14.0": "/vs/IDE/CommonExtensions/Microsoft/TestWindow"
+ },
+ "match": {
+ "**\\packages\\**\\*TestAdapter.dll": []
+ },
+ "findMatch": {
+ "/source/dir/some/*pattern": [
+ "/source/dir/someFile2",
+ "/source/dir/someFile1"
+ ],
+ "/source/dir/someFile1": [
+ "/source/dir/someFile1"
+ ]
+ },
+ "exec": {
+ "\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx /UseVsixExtensions": {
+ "code": 0,
+ "stdout": "running vstest with other console params single.."
+ },
+ "\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx /UseVsixExtensions /Enablecodecoverage": {
+ "code": 0,
+ "stdout": "running vstest with other console params multiple.."
+ },
+ "\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /EnableCodeCoverage /logger:trx /Enablecodecoverage": {
+ "code": 1,
+ "stdout": "running vstest with other console duplicate params..",
+ "stderr": "The parameter \"/EnableCodeCoverage\" should be provided only once."
+ },
+ "wmic datafile where name='\\\\vs\\\\IDE\\\\CommonExtensions\\\\Microsoft\\\\TestWindow\\\\vstest.console.exe' get Version /Value": {
+ "code": 0,
+ "stdout" : "version=14.0.0.0"
+ }
+ },
+ "rmRF": {
+ "\\source\\dir\\TestResults": {
+ "success": true,
+ "message": "success"
+ }
+ }
+}
\ No newline at end of file