diff --git a/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson b/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson index 6951f28e70d3..3b81a0e9ad5b 100644 --- a/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/VsTest/Strings/resources.resjson/en-US/resources.resjson @@ -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.", diff --git a/Tasks/VsTest/make.json b/Tasks/VsTest/make.json index 7e06ed3fdf04..8ab8418a5243 100644 --- a/Tasks/VsTest/make.json +++ b/Tasks/VsTest/make.json @@ -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": "./" } ] diff --git a/Tasks/VsTest/task.json b/Tasks/VsTest/task.json index ede852e5579a..558157430260 100644 --- a/Tasks/VsTest/task.json +++ b/Tasks/VsTest/task.json @@ -17,7 +17,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 10 + "Patch": 14 }, "demands": [ "vstest" @@ -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.", diff --git a/Tasks/VsTest/task.loc.json b/Tasks/VsTest/task.loc.json index 838977cced84..b3d3e04fbab2 100644 --- a/Tasks/VsTest/task.loc.json +++ b/Tasks/VsTest/task.loc.json @@ -17,7 +17,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 10 + "Patch": 14 }, "demands": [ "vstest" diff --git a/Tasks/VsTest/vstest.ts b/Tasks/VsTest/vstest.ts index 680a6493c0a4..718cce483ceb 100644 --- a/Tasks/VsTest/vstest.ts +++ b/Tasks/VsTest/vstest.ts @@ -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 { @@ -557,6 +562,14 @@ function getVstestTestsList(vsVersion: number): Q.Promise { } 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); @@ -813,17 +826,27 @@ function invokeVSTest(testResultsDirectory: string): Q.Promise { 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); @@ -1502,7 +1525,7 @@ function getLatestVSTestConsolePathFromRegistry(): Q.Promise { 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(); @@ -1526,21 +1549,27 @@ function getVSTestConsole15Path(): string { function locateVSVersion(version: string): Q.Promise { let deferred = Q.defer(); 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; } diff --git a/Tests-Legacy/L0/VsTest/vs2017.json b/Tests-Legacy/L0/VsTest/vs2017.json index 1e082b9edd55..ba8aedb8f69c 100644 --- a/Tests-Legacy/L0/VsTest/vs2017.json +++ b/Tests-Legacy/L0/VsTest/vs2017.json @@ -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": "\\vs2017\\installation\\folder" } diff --git a/Tests-Legacy/L0/VsTest/vstestGood.json b/Tests-Legacy/L0/VsTest/vstestGood.json index 5a9148ddb94e..4432fe8c1447 100644 --- a/Tests-Legacy/L0/VsTest/vstestGood.json +++ b/Tests-Legacy/L0/VsTest/vstestGood.json @@ -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": "\\vs2017\\installation\\folder" + }, + "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": { @@ -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 } } } \ No newline at end of file diff --git a/Tests-Legacy/L0/VsTest/vstestGoodSysDebugFalse.json b/Tests-Legacy/L0/VsTest/vstestGoodSysDebugFalse.json index 72ceffc7af74..d2e88e28df05 100644 --- a/Tests-Legacy/L0/VsTest/vstestGoodSysDebugFalse.json +++ b/Tests-Legacy/L0/VsTest/vstestGoodSysDebugFalse.json @@ -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": {