-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
detect vstest.console.exe15 #3158
Conversation
mutn3ja
commented
Nov 28, 2016
•
edited
Loading
edited
- able to detect vstest.console.exe15
- end to end validation done
- Machine with both VS2015 and VS2017 ('latest' selected in build definition)
- Machine with VS2015 only ('latest' selected in build definition)
- Machine with VS2017 only ('latest' selected in build definition)
- Machine with VS2017 only ('specify location' mode)
let powershellTool = tl.tool('powershell'); | ||
let powershellArgs = ['-file', path.join(__dirname, 'vs15Helper.ps1')] | ||
powershellTool.arg(powershellArgs); | ||
let xml = powershellTool.execSync().stdout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be aware that execSync will not get live output and it will buffer the output. Convenient for running quick clis.
Consider await tool exec.
|
||
function locateVSVersion(): Q.Promise<[number, string]> { | ||
var defer = Q.defer<[number, string]>(); | ||
let vsVersion: number = parseFloat(vsTestVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vsTestVersion [](start = 39, length = 13)
pass this as argument. no global variable usage
|
||
function locateVSVersion(): Q.Promise<[number, string]> { | ||
var defer = Q.defer<[number, string]>(); | ||
let vsVersion: number = parseFloat(vsTestVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let
return deferred.promise; | ||
} | ||
|
||
function getVSTestConsole15Path(): Q.Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getVSTestConsole15Path [](start = 9, length = 22)
use return on Q call why to use unnecessary defer variables
powershellTool.arg(powershellArgs); | ||
let xml = powershellTool.execSync().stdout; | ||
let deferred = Q.defer<string>(); | ||
Q.nfcall(xml2js.parseString, xml).then((data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and why it has to be async call?
} | ||
|
||
|
||
function locateVSVersion(): Q.Promise<[number, string]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not create VS version object something like that and use it instead of map
} | ||
|
||
|
||
function locateVSVersion(): Q.Promise<[number, string]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont see reason for these calls to be async
let selectedVersion = versions[versions.length - 1]; | ||
deferred.resolve([selectedVersion, getVSTestLocation(selectedVersion)]); | ||
return deferred.promise; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't you supposed to resolve something here? is this works?
Write-Host ([System.Management.Automation.PSSerializer]::Serialize($instance.Path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be an empty or null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Serialize works properly in case of null or empty.
@@ -20,6 +20,15 @@ const TITestSettingsNameTag = "testSettings-5d76a195-1e43-4b90-a6ce-4ec3de87ed25 | |||
const TITestSettingsIDTag = "5d76a195-1e43-4b90-a6ce-4ec3de87ed25"; | |||
const TITestSettingsXmlnsTag = "http://microsoft.com/schemas/VisualStudio/TeamTest/2010" | |||
|
|||
class VSTestConsoleInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface
vstestLocation = vstest[1]; | ||
locateVSVersion(vsTestVersion) | ||
.then(function(vsTestConsoleInfo) { | ||
let vsVersion = vsTestConsoleInfo.version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need intermediate vars
try { | ||
let vs15InstallDir = result['Objs']['S'][0]; | ||
vstestconsolePath = path.join(vs15InstallDir, 'Common7', 'IDE', 'CommonExtensions', 'Microsoft', 'TestWindow', 'vstest.console.exe'); | ||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont you want to log what's the exception?
var defer = Q.defer<[number, string]>(); | ||
let vsVersion: number = parseFloat(vsTestVersion); | ||
function locateVSVersion(version: string): Q.Promise<VSTestConsoleInfo> { | ||
let deferred = Q.defer<VSTestConsoleInfo>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get rid of these deferred vars. your promises can be chained, can be returned directly. code is cleaner and simpler
What is the testing done? list down test cases. LGTM |