Skip to content

Commit

Permalink
Introducing latest back (#4179)
Browse files Browse the repository at this point in the history
  • Loading branch information
RanjanarMS authored May 1, 2017
1 parent 545a6ad commit 2e27f43
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"loc.messages.VstestReturnCode": "Vstest exited with return code: %d.",
"loc.messages.NoMatchingTestAssemblies": "No test assemblies found matching the pattern: %s.",
"loc.messages.VstestNotFound": "Visual Studio %d is not found. Try again with a version that exists on your build agent machine.",
"loc.messages.NoVstestFound": "Test platform is not found. Try again after installing it on your build agent machine.",
"loc.messages.VstestFailed": "Vstest failed with error. Check logs for failures. There might be failed tests.",
"loc.messages.VstestTIANotSupported": "Install Visual Studio 2015 update 3 or Visual Studio 2017 RC or above to run Test Impact Analysis.",
"loc.messages.NoResultsToPublish": "No results found to publish.",
Expand Down Expand Up @@ -87,10 +88,10 @@
"loc.messages.runTestInIsolationNotSupported": "Running tests in isolation is not supported when using the multi-agent phase setting. This option will be ignored.",
"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.vstestVersionInvalid": "Given test platform version %s is not supported.",
"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.",
"loc.messages.distributedTestWorkflow": "In distributed testing flow....",
"loc.messages.distributedTestWorkflow": "In distributed testing flow",
"loc.messages.dtaNumberOfAgents": "Distributed test execution, number of agents in phase : %s",
"loc.messages.testSelectorInput": "Test selector : %s",
"loc.messages.searchFolderInput": "Search folder : %s",
Expand All @@ -106,7 +107,7 @@
"loc.messages.testSuiteSelected": "Test suite Id selected: %s",
"loc.messages.testAssemblyFilterInput": "Test assembly filter : %s",
"loc.messages.vsVersionSelected": "VisualStudio version selected for test execution : %s",
"loc.messages.runTestsLocally": "Run the tests locally using %s....",
"loc.messages.runTestsLocally": "Run the tests locally using %s",
"loc.messages.vstestLocationSpecified": "%s, specified location : %s",
"loc.messages.uitestsparallel": "Running UI tests in parallel on the same machine can lead to errors. Consider disabling the ‘run in parallel’ option or run UI tests using a separate task. To learn more, see https://aka.ms/paralleltestexecution "
}
34 changes: 13 additions & 21 deletions Tasks/VsTest/distributedtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,21 @@ export class DistributedTest {
utils.Helper.addToProcessEnvVars(envVars, 'DTA.LocalTestDropPath', this.dtaTestConfig.testDropLocation);
utils.Helper.addToProcessEnvVars(envVars, 'DTA.EnableConsoleLogs', 'true');

if (this.dtaTestConfig.vsTestLocationMethod === utils.Constants.vsTestVersionString) {
utils.Helper.addToProcessEnvVars(envVars, 'DTA.TestPlatformVersion', this.dtaTestConfig.vsTestVersion);
}

const exeInfo = await versionFinder.locateVSTestConsole(this.dtaTestConfig);
if (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
// that this is nuget/xcopyable package where the dlls are present in test window folder
const testWindowRelativeDir = 'CommonExtensions\\Microsoft\\TestWindow';
if (exelocation && exelocation.indexOf(testWindowRelativeDir) !== -1) {
const ideLocation = exelocation.split(testWindowRelativeDir)[0];
tl.debug('Adding env var DTA.VisualStudio.Path = ' + ideLocation);
utils.Helper.addToProcessEnvVars(envVars, 'DTA.VisualStudio.Path', ideLocation);
} else {
utils.Helper.addToProcessEnvVars(envVars, 'DTA.VisualStudio.Path', exelocation);
}
utils.Helper.addToProcessEnvVars(envVars, 'DTA.TestWindow.Path', exelocation);
// If we are setting the path version is not needed
const exelocation = path.dirname(this.dtaTestConfig.vsTestVersionDetais.vstestExeLocation);
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
// that this is nuget/xcopyable package where the dlls are present in test window folder
const testWindowRelativeDir = 'CommonExtensions\\Microsoft\\TestWindow';
if (exelocation && exelocation.indexOf(testWindowRelativeDir) !== -1) {
const ideLocation = exelocation.split(testWindowRelativeDir)[0];
tl.debug('Adding env var DTA.VisualStudio.Path = ' + ideLocation);
utils.Helper.addToProcessEnvVars(envVars, 'DTA.VisualStudio.Path', ideLocation);
} else {
tl.error(tl.loc('VstestNotFound', utils.Helper.getVSVersion(parseFloat(this.dtaTestConfig.vsTestVersion))));
utils.Helper.addToProcessEnvVars(envVars, 'DTA.VisualStudio.Path', exelocation);
}
utils.Helper.addToProcessEnvVars(envVars, 'DTA.TestWindow.Path', exelocation);

// We are logging everything to a DTAExecutionHost.exe.log file and reading it at the end and adding to the build task debug logs
// So we are not redirecting the IO streams from the DTAExecutionHost.exe process
Expand Down
7 changes: 5 additions & 2 deletions Tasks/VsTest/models.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as version from './vstestversion';

export interface TestConfigurations {
sourceFilter: string[];
testcaseFilter: string;
Expand All @@ -12,6 +14,7 @@ export interface TestConfigurations {
vsTestLocationMethod: string;
vsTestVersion: string;
vsTestLocation: string;
vsTestVersionDetais: version.VSTestVersion;
pathtoCustomTestAdapters: string;
tiaConfig: TiaConfiguration;
runInParallel: boolean;
Expand Down Expand Up @@ -41,9 +44,9 @@ export interface DtaEnvironment {
}

export interface VsTestConfigurations extends TestConfigurations {
publishRunAttachments: string;
publishRunAttachments: string;
vstestDiagFile: string;
ignoreVstestFailure: string;
ignoreVstestFailure: string;
}

export interface TiaConfiguration {
Expand Down
14 changes: 8 additions & 6 deletions Tasks/VsTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 0,
"Patch": 39
"Patch": 40
},
"demands": [
"vstest"
Expand Down Expand Up @@ -185,16 +185,17 @@
"location": "Specific location"
}
},
{
{
"name": "vsTestVersion",
"type": "pickList",
"label": "Test platform version",
"defaultValue": "15.0",
"defaultValue": "latest",
"required": false,
"helpMarkDown": "The version of Visual Studio test to use.",
"visibleRule": "vstestLocationMethod = version",
"groupName": "executionOptions",
"options": {
"latest": "Latest",
"15.0": "Visual Studio 2017",
"14.0": "Visual Studio 2015"
}
Expand Down Expand Up @@ -347,6 +348,7 @@
"VstestReturnCode": "Vstest exited with return code: %d.",
"NoMatchingTestAssemblies": "No test assemblies found matching the pattern: %s.",
"VstestNotFound": "Visual Studio %d is not found. Try again with a version that exists on your build agent machine.",
"NoVstestFound": "Test platform is not found. Try again after installing it on your build agent machine.",
"VstestFailed": "Vstest failed with error. Check logs for failures. There might be failed tests.",
"VstestTIANotSupported": "Install Visual Studio 2015 update 3 or Visual Studio 2017 RC or above to run Test Impact Analysis.",
"NoResultsToPublish": "No results found to publish.",
Expand Down Expand Up @@ -375,10 +377,10 @@
"runTestInIsolationNotSupported": "Running tests in isolation is not supported when using the multi-agent phase setting. This option will be ignored.",
"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.",
"vstestVersionInvalid": "Given test platform version %s is not supported.",
"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.",
"distributedTestWorkflow": "In distributed testing flow....",
"distributedTestWorkflow": "In distributed testing flow",
"dtaNumberOfAgents": "Distributed test execution, number of agents in phase : %s",
"testSelectorInput": "Test selector : %s",
"searchFolderInput": "Search folder : %s",
Expand All @@ -394,7 +396,7 @@
"testSuiteSelected": "Test suite Id selected: %s",
"testAssemblyFilterInput": "Test assembly filter : %s",
"vsVersionSelected": "VisualStudio version selected for test execution : %s",
"runTestsLocally": "Run the tests locally using %s....",
"runTestsLocally": "Run the tests locally using %s",
"vstestLocationSpecified": "%s, specified location : %s",
"uitestsparallel": "Running UI tests in parallel on the same machine can lead to errors. Consider disabling the ‘run in parallel’ option or run UI tests using a separate task. To learn more, see https://aka.ms/paralleltestexecution "

Expand Down
8 changes: 5 additions & 3 deletions Tasks/VsTest/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 0,
"Patch": 39
"Patch": 40
},
"demands": [
"vstest"
Expand Down Expand Up @@ -189,12 +189,13 @@
"name": "vsTestVersion",
"type": "pickList",
"label": "ms-resource:loc.input.label.vsTestVersion",
"defaultValue": "15.0",
"defaultValue": "latest",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.vsTestVersion",
"visibleRule": "vstestLocationMethod = version",
"groupName": "executionOptions",
"options": {
"latest": "Latest",
"15.0": "Visual Studio 2017",
"14.0": "Visual Studio 2015"
}
Expand Down Expand Up @@ -347,6 +348,7 @@
"VstestReturnCode": "ms-resource:loc.messages.VstestReturnCode",
"NoMatchingTestAssemblies": "ms-resource:loc.messages.NoMatchingTestAssemblies",
"VstestNotFound": "ms-resource:loc.messages.VstestNotFound",
"NoVstestFound": "ms-resource:loc.messages.NoVstestFound",
"VstestFailed": "ms-resource:loc.messages.VstestFailed",
"VstestTIANotSupported": "ms-resource:loc.messages.VstestTIANotSupported",
"NoResultsToPublish": "ms-resource:loc.messages.NoResultsToPublish",
Expand Down Expand Up @@ -375,7 +377,7 @@
"runTestInIsolationNotSupported": "ms-resource:loc.messages.runTestInIsolationNotSupported",
"tiaNotSupportedInDta": "ms-resource:loc.messages.tiaNotSupportedInDta",
"overrideNotSupported": "ms-resource:loc.messages.overrideNotSupported",
"vs2013NotSupportedInDta": "ms-resource:loc.messages.vs2013NotSupportedInDta",
"vstestVersionInvalid": "ms-resource:loc.messages.vstestVersionInvalid",
"configureDtaAgentFailed": "ms-resource:loc.messages.configureDtaAgentFailed",
"otherConsoleOptionsNotSupported": "ms-resource:loc.messages.otherConsoleOptionsNotSupported",
"distributedTestWorkflow": "ms-resource:loc.messages.distributedTestWorkflow",
Expand Down
17 changes: 11 additions & 6 deletions Tasks/VsTest/taskinputparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import * as tr from 'vsts-task-lib/toolrunner';
import * as models from './models';
import * as utils from './helpers';
import * as os from 'os';

import * as versionFinder from './versionfinder';
const uuid = require('node-uuid');

export function getDistributedTestConfigurations(): models.DtaTestConfigurations {
export function getDistributedTestConfigurations() {
tl.setResourcePath(path.join(__dirname, 'task.json'));
const dtaConfiguration = {} as models.DtaTestConfigurations;
initTestConfigurations(dtaConfiguration);
Expand Down Expand Up @@ -41,7 +41,7 @@ export function getDistributedTestConfigurations(): models.DtaTestConfigurations
return dtaConfiguration;
}

export function getvsTestConfigurations(): models.VsTestConfigurations {
export function getvsTestConfigurations() {
tl.setResourcePath(path.join(__dirname, 'task.json'));
const vsTestConfiguration = {} as models.VsTestConfigurations;
initTestConfigurations(vsTestConfiguration);
Expand Down Expand Up @@ -155,22 +155,27 @@ function initTestConfigurations(testConfiguration: models.TestConfigurations) {
tl._writeLine('vsTestVersion is null or empty');
throw new Error('vsTestVersion is null or empty');
}
if ((testConfiguration.vsTestVersion !== '15.0') && (testConfiguration.vsTestVersion !== '14.0')
&& (testConfiguration.vsTestVersion.toLowerCase() !== 'latest')) {
throw new Error(tl.loc('vstestVersionInvalid', testConfiguration.vsTestVersion));
}
tl._writeLine(tl.loc('vsVersionSelected', testConfiguration.vsTestVersion));
} else {
testConfiguration.vsTestLocation = tl.getInput('vsTestLocation');
tl._writeLine(tl.loc('vstestLocationSpecified', 'vstest.console.exe', testConfiguration.vsTestLocation));
}

if(tl.getBoolInput('uiTests') && testConfiguration.runInParallel)
{
if (tl.getBoolInput('uiTests') && testConfiguration.runInParallel) {
tl.warning(tl.loc('uitestsparallel'));
}

// only to facilitate the writing of unit tests
// only to facilitate the writing of unit tests
testConfiguration.vs15HelperPath = tl.getVariable('vs15Helper');
if (!testConfiguration.vs15HelperPath) {
testConfiguration.vs15HelperPath = path.join(__dirname, 'vs15Helper.ps1');
}

versionFinder.getVsTestRunnerDetails(testConfiguration);
}

function getTiaConfiguration() : models.TiaConfiguration {
Expand Down
Loading

0 comments on commit 2e27f43

Please sign in to comment.