Skip to content

Commit

Permalink
Merge pull request #3586 from Microsoft/users/siddhap/port2015
Browse files Browse the repository at this point in the history
Porting fix for TIA support for VS2015
  • Loading branch information
acesiddhu authored Feb 13, 2017
2 parents c03cefd + 1adb154 commit fe52003
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"loc.messages.NoMatchingTestAssemblies": "No test assemblies found matching the pattern: %s.",
"loc.messages.VstestNotFound": "Vstest of version %d is not found. Try again with a visual studio version that exists 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 version 15.0.25807 or higher to run Test Impact Analysis.",
"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.",
"loc.messages.ErrorWhileReadingRunSettings": "Error occured while reading run settings file. Error : %s.",
"loc.messages.ErrorWhileReadingTestSettings": "Error occured while reading test settings file. Error : %s.",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/VsTest/make.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"externals": {
"archivePackages": [
{
"url": "https://testselector.blob.core.windows.net/testselector/3570841/TestSelector.zip",
"url": "https://testselector.blob.core.windows.net/testselector/3614206/TestSelector.zip",
"dest": "./"
}
]
Expand Down
4 changes: 2 additions & 2 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": 10
"Patch": 14
},
"demands": [
"vstest"
Expand Down Expand Up @@ -238,7 +238,7 @@
"NoMatchingTestAssemblies": "No test assemblies found matching the pattern: %s.",
"VstestNotFound": "Vstest of version %d is not found. Try again with a visual studio version that exists on your build agent machine.",
"VstestFailed": "Vstest failed with error. Check logs for failures. There might be failed tests.",
"VstestTIANotSupported": "Install Visual Studio version 15.0.25807 or higher to run Test Impact Analysis.",
"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.",
"ErrorWhileReadingRunSettings": "Error occured while reading run settings file. Error : %s.",
"ErrorWhileReadingTestSettings": "Error occured while reading test settings file. Error : %s.",
Expand Down
2 changes: 1 addition & 1 deletion 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": 10
"Patch": 14
},
"demands": [
"vstest"
Expand Down
77 changes: 53 additions & 24 deletions Tasks/VsTest/vstest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ function getTestSelectorLocation(): string {
}

function getTraceCollectorUri(): string {
return "file://" + path.join(__dirname, "TestSelector/Microsoft.VisualStudio.TraceCollector.dll");
if(vsTestVersionForTIA[0] === 15) {
return "file://" + path.join(__dirname, "TestSelector/Microsoft.VisualStudio.TraceCollector.dll");
}
else {
return "file://" + path.join(__dirname, "TestSelector/14.0/Microsoft.VisualStudio.TraceCollector.dll");
}
}

function uploadTestResults(testResultsDirectory: string): Q.Promise<string> {
Expand Down Expand Up @@ -557,6 +562,14 @@ function getVstestTestsList(vsVersion: number): Q.Promise<string> {
}

let vstest = tl.tool(vstestLocation);

if(vsVersion === 14.0) {

tl.debug("Visual studio 2015 selected. Selecting vstest.console.exe bundled in the 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
vstest = tl.tool(vsTestPath);
}

addVstestArgs(argsArray, vstest);

tl.cd(workingDirectory);
Expand Down Expand Up @@ -813,17 +826,27 @@ function invokeVSTest(testResultsDirectory: string): Q.Promise<number> {
let sysDebug = tl.getVariable("System.Debug");
if ((sysDebug !== undefined && sysDebug.toLowerCase() === "true") || tiaEnabled) {
vsTestVersionForTIA = getVsTestVersion();

if (tiaEnabled && (vsTestVersionForTIA === null || (vsTestVersionForTIA[0] < 15 || (vsTestVersionForTIA[0] === 15 && vsTestVersionForTIA[1] === 0 && vsTestVersionForTIA[2] < 25727)))) {
tl.warning(tl.loc("VstestTIANotSupported"));
tiaEnabled = false;
}
if (tiaEnabled &&
(vsTestVersionForTIA === null ||
(vsTestVersionForTIA[0] < 14 ||
(vsTestVersionForTIA[0] === 15 && vsTestVersionForTIA[1] === 0 && vsTestVersionForTIA[2] < 25727) ||
// VS 2015 U3
(vsTestVersionForTIA[0] === 14 && vsTestVersionForTIA[1] === 0 && vsTestVersionForTIA[2] < 25420)))) {
tl.warning(tl.loc("VstestTIANotSupported"));
tiaEnabled = false;
}
} catch (e) {
tl.error(e.message);
defer.resolve(1);
return defer.promise;
}
} catch (e) {
tl.error(e.message);
defer.resolve(1);
return defer.promise;
}

// We need to use private data collector dll bundled in task
if(tiaEnabled === true && vsTestVersionForTIA[0] === 14) {
useNewCollector = true;
}

setupSettingsFileForTestImpact(vsVersion, overriddenSettingsFile)
.then(function(runSettingswithTestImpact) {
setRunInParallellIfApplicable(vsVersion);
Expand Down Expand Up @@ -1502,7 +1525,7 @@ function getLatestVSTestConsolePathFromRegistry(): Q.Promise<ExecutabaleInfo> {

function getVSTestConsole15Path(): string {
let powershellTool = tl.tool('powershell');
let powershellArgs = ['-file', vs15HelperPath]
let powershellArgs = ['-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-file', vs15HelperPath]
powershellTool.arg(powershellArgs);
let xml = powershellTool.execSync().stdout;
let deferred = Q.defer<string>();
Expand All @@ -1526,21 +1549,27 @@ function getVSTestConsole15Path(): string {
function locateVSVersion(version: string): Q.Promise<ExecutabaleInfo> {
let deferred = Q.defer<ExecutabaleInfo>();
let vsVersion: number = parseFloat(version);

if (isNaN(vsVersion) || vsVersion == 15) {
// latest
tl.debug('Searching for latest Visual Studio');
let vstestconsole15Path = getVSTestConsole15Path();
if (vstestconsole15Path) {
deferred.resolve({version: 15, location: vstestconsole15Path});

if(vstestLocationMethod.toLowerCase() !== 'location') {
if (isNaN(vsVersion) || vsVersion == 15) {
// latest
tl.debug('Searching for latest Visual Studio');
let vstestconsole15Path = getVSTestConsole15Path();
if (vstestconsole15Path) {
deferred.resolve({version: 15, location: vstestconsole15Path});
} else {
// fallback
tl.debug('Unable to find an instance of Visual Studio 2017');
return getLatestVSTestConsolePathFromRegistry();
}
} else {
// fallback
tl.debug('Unable to find an instance of Visual Studio 2017');
return getLatestVSTestConsolePathFromRegistry();
tl.debug('Searching for Visual Studio ' + vsVersion.toString());
deferred.resolve({version: vsVersion, location: getVSTestLocation(vsVersion)});
}
} else {
tl.debug('Searching for Visual Studio ' + vsVersion.toString());
deferred.resolve({version: vsVersion, location: getVSTestLocation(vsVersion)});
}
else {
vstestLocation = getVSTestLocation(vsVersion); // returns location if user has given path
deferred.resolve({ version: getVsTestVersion()[0], location: vstestLocation });
}
return deferred.promise;
}
Expand Down
2 changes: 1 addition & 1 deletion Tests-Legacy/L0/VsTest/vs2017.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"code": 0,
"stdout": "vstest"
},
"powershell -file /path/to/vs15Helper.ps1": {
"powershell -NonInteractive -ExecutionPolicy Unrestricted -file /path/to/vs15Helper.ps1": {
"code": 0,
"stdout": "<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S>\\vs2017\\installation\\folder</S></Objs>"
}
Expand Down
30 changes: 29 additions & 1 deletion Tests-Legacy/L0/VsTest/vstestGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,31 @@
"code": 0,
"stdout": "vstest"
},
"powershell -file /path/to/vs15Helper.ps1": {
"powershell -NonInteractive -ExecutionPolicy Unrestricted -file /path/to/vs15Helper.ps1": {
"code": 0,
"stdout": "<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S>\\vs2017\\installation\\folder</S></Objs>"
},
"wmic datafile": {
"code": 0,
"stdout": "Version=15.0.26206.0"
},
"wmic datafile where name='some\\\\path\\\\to\\\\vstest.console.exe' get Version /Value": {
"code": 0,
"stdout": "Version=15.0.26206.0"
},
"wmic datafile where name='\\\\path\\\\to\\\\vstest\\\\directory\\\\vstest.console.exe' get Version /Value": {
"code": 0,
"stdout": "Version=15.0.26206.0"
}
},
"execSync": {
"wmic datafile where name='some\\path\\to\\vstest.console.exe' get Version /Value": {
"code": 0,
"stdout": "Version=15.0.26206.0"
},
"wmic datafile where name='\\path\\to\\vstest\\directory\\vstest.console.exe' get Version /Value": {
"code": 0,
"stdout": "Version=15.0.26206.0"
}
},
"rmRF": {
Expand All @@ -100,11 +122,17 @@
"some\\path\\to\\vstest.console.exe": {
"isFile": true
},
"\\path\\to\\vstest\\directory\\vstest.console.exe": {
"isFile": true
},
"path/to/customadapters": {
"isDirectory": true
},
"\\path\\to\\vstest\\directory": {
"isDirectory": true
},
"some\\path\\to": {
"isDirectory": true
}
}
}
4 changes: 4 additions & 0 deletions Tests-Legacy/L0/VsTest/vstestGoodSysDebugFalse.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"\\path\\to\\vstest\\directory\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"wmic datafile where name='\\\\path\\\\to\\\\vstest\\\\directory\\\\vstest.console.exe' get Version /Value": {
"code": 0,
"stdout": "Version=14.0.25423.0"
}
},
"rmRF": {
Expand Down

0 comments on commit fe52003

Please sign in to comment.