Skip to content
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

Bug fixes #1819

Merged
merged 5 commits into from
Jun 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"loc.group.displayName.agentConfiguration": "Agent Configuration",
"loc.group.displayName.advanced": "Advanced",
"loc.input.label.testMachineGroup": "Machines",
"loc.input.help.testMachineGroup": "Provide a comma separated list of machine IP addresses or FQDNs along with ports. Port is defaulted based on the selected protocol. `Eg: dbserver.fabrikam.com,dbserver_int.fabrikam.com:5986,192.168.12.34:5986` Or provide output variable of other tasks. `Eg: $(variableName)` Or provide a Machine Group Name.",
"loc.input.help.testMachineGroup": "Provide a comma separated list of machine IP addresses or FQDNs along with ports. Port is defaulted based on the selected protocol. Eg: `dbserver.fabrikam.com,dbserver_int.fabrikam.com:5986,192.168.12.34:5986` Or provide output variable of other tasks. Eg: `$(variableName)` Or provide a Machine Group Name.",
"loc.input.label.adminUserName": "Admin Login",
"loc.input.help.adminUserName": "Administrator login for the target machines.",
"loc.input.label.adminPassword": "Admin Password",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/DeployVisualStudioTestAgent/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 28
"Patch": 29
},
"demands": [

Expand Down Expand Up @@ -43,7 +43,7 @@
"label": "Machines",
"defaultValue": "",
"required": true,
"helpMarkDown": "Provide a comma separated list of machine IP addresses or FQDNs along with ports. Port is defaulted based on the selected protocol. `Eg: dbserver.fabrikam.com,dbserver_int.fabrikam.com:5986,192.168.12.34:5986` Or provide output variable of other tasks. `Eg: $(variableName)` Or provide a Machine Group Name.",
"helpMarkDown": "Provide a comma separated list of machine IP addresses or FQDNs along with ports. Port is defaulted based on the selected protocol. Eg: `dbserver.fabrikam.com,dbserver_int.fabrikam.com:5986,192.168.12.34:5986` Or provide output variable of other tasks. Eg: `$(variableName)` Or provide a Machine Group Name.",
"groupName": "testMachineGroups"
},
{
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DeployVisualStudioTestAgent/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 28
"Patch": 29
},
"demands": [],
"minimumAgentVersion": "1.97.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"loc.group.displayName.executionOptions": "Execution Options",
"loc.group.displayName.reportingOptions": "Reporting Options",
"loc.input.label.testMachineGroup": "Machines",
"loc.input.help.testMachineGroup": "Provide a comma separated list of machine IP addresses or FQDNs. `Eg: dbserver.fabrikam.com or 192.168.12.34` Or provide output variable of other tasks. `Eg: $(variableName)` Or provide a Machine Group Name",
"loc.input.help.testMachineGroup": "Provide a comma separated list of machine IP addresses or FQDNs. Eg: `dbserver.fabrikam.com or 192.168.12.34` Or provide output variable of other tasks. Eg: `$(variableName)` Or provide a Machine Group Name",
"loc.input.label.dropLocation": "Test Drop Location",
"loc.input.help.dropLocation": "Location where the test binaries have been dropped in the agent machine(s) as part of the 'Windows Machine File Copy' or 'Azure File Copy` task. System Environment Variables can also be used in location string. e.g., `%systemdrive%\\Tests`, `%temp%\\DropLocation` etc.",
"loc.input.help.dropLocation": "Location where the test binaries have been dropped in the agent machine(s) as part of the 'Windows Machine File Copy' or 'Azure File Copy' task. System Environment Variables can also be used in location string. e.g., `%systemdrive%\\Tests`, `%temp%\\DropLocation` etc.",
"loc.input.label.testSelection": "Test Selection",
"loc.input.help.testSelection": "Select the way you want to run tests : using Test Assemblies or using Test Plan.",
"loc.input.label.testPlan": "Test Plan",
Expand Down
6 changes: 3 additions & 3 deletions Tasks/RunDistributedTests/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 37
"Patch": 38
},
"demands": [
],
Expand Down Expand Up @@ -42,7 +42,7 @@
"label": "Machines",
"defaultValue": "",
"required": true,
"helpMarkDown": "Provide a comma separated list of machine IP addresses or FQDNs. `Eg: dbserver.fabrikam.com or 192.168.12.34` Or provide output variable of other tasks. `Eg: $(variableName)` Or provide a Machine Group Name",
"helpMarkDown": "Provide a comma separated list of machine IP addresses or FQDNs. Eg: `dbserver.fabrikam.com or 192.168.12.34` Or provide output variable of other tasks. Eg: `$(variableName)` Or provide a Machine Group Name",
"groupName": "setupOptions"
},
{
Expand All @@ -51,7 +51,7 @@
"label": "Test Drop Location",
"defaultValue": "",
"required": true,
"helpMarkDown": "Location where the test binaries have been dropped in the agent machine(s) as part of the 'Windows Machine File Copy' or 'Azure File Copy` task. System Environment Variables can also be used in location string. e.g., `%systemdrive%\\Tests`, `%temp%\\DropLocation` etc.",
"helpMarkDown": "Location where the test binaries have been dropped in the agent machine(s) as part of the 'Windows Machine File Copy' or 'Azure File Copy' task. System Environment Variables can also be used in location string. e.g., `%systemdrive%\\Tests`, `%temp%\\DropLocation` etc.",
"groupName": "setupOptions"
},
{
Expand Down
2 changes: 1 addition & 1 deletion Tasks/RunDistributedTests/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 37
"Patch": 38
},
"demands": [],
"minimumAgentVersion": "1.95.0",
Expand Down
50 changes: 50 additions & 0 deletions Tasks/VsTest/Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,53 @@ function Locate-VSVersion()
}
return $version
}

function GetResultsLocation {
[cmdletbinding()]
[OutputType([System.String])]
param(
[string]$runSettingsFilePath
)

# If this is a runsettings file then try to get the custom results location from it

if(!(CheckIfDirectory $runSettingsFilePath) -And (CheckIfRunsettings $runSettingsFilePath))
{
$runSettingsForTestResults = [System.Xml.XmlDocument](Get-Content $runSettingsFilePath)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens in case of malformed XML?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the node we are looking for is not there, it will default to old behaviour. If the xml structure itself is wrong, it will fail as expected with appropriate error.

$resultsDirElement = $runSettingsForTestResults.SelectNodes("//RunSettings/RunConfiguration/ResultsDirectory")

if($resultsDirElement -And $resultsDirElement.Count -ne 0)
{
$customLocation = $runSettingsForTestResults.RunSettings.RunConfiguration.ResultsDirectory
if([io.path]::IsPathRooted($customLocation))
{
return $customLocation
}
else
{
# Resutls directory is relative to the location of runsettings
return [io.path]::GetFullPath([io.path]::Combine([io.path]::GetDirectoryName($runSettingsFilePath), $customLocation))
}
}
}

return $null
}

function CheckIfRunsettings($runSettingsFilePath)
{
if(([string]::Compare([io.path]::GetExtension($runSettingsFilePath), ".runsettings", $True) -eq 0) -Or ([string]::Compare([io.path]::GetExtension($runSettingsFilePath), ".tmp", $True) -eq 0))
{
return $true
}
return $false
}

function CheckIfDirectory($filePath)
{
if(Test-Path $filePath -pathtype container)
{
return $true
}
return $false
}
12 changes: 11 additions & 1 deletion Tasks/VsTest/VSTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ try
$artifactsDirectory = Get-TaskVariable -Context $distributedTaskContext -Name "System.ArtifactsDirectory" -Global $FALSE

$workingDirectory = $artifactsDirectory
$testResultsDirectory = $workingDirectory + [System.IO.Path]::DirectorySeparatorChar + "TestResults"

if($runInParallel -eq "True")
{
Expand All @@ -108,6 +107,17 @@ try

$defaultCpuCount = "0"
$runSettingsFileWithParallel = [string](SetupRunSettingsFileForParallel $runInParallel $runSettingsFile $defaultCpuCount)

#If there is settings file and no override parameters, try to get the custom resutls location
if(![System.String]::IsNullOrWhiteSpace($runSettingsFileWithParallel) -and !$overrideTestrunParameters)
{
$testResultsDirectory = GetResultsLocation $runSettingsFileWithParallel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log in this case

}
if(!$testResultsDirectory)
{
$testResultsDirectory = $workingDirectory + [System.IO.Path]::DirectorySeparatorChar + "TestResults"
}
Write-Verbose "Test results directory: $testResultsDirectory"

Invoke-VSTest -TestAssemblies $testAssemblyFiles -VSTestVersion $vsTestVersion -TestFiltercriteria $testFiltercriteria -RunSettingsFile $runSettingsFileWithParallel -PathtoCustomTestAdapters $pathtoCustomTestAdapters -CodeCoverageEnabled $codeCoverage -OverrideTestrunParameters $overrideTestrunParameters -OtherConsoleOptions $otherConsoleOptions -WorkingFolder $workingDirectory -TestResultsFolder $testResultsDirectory -SourcesDirectory $sourcesDirectory

Expand Down
2 changes: 1 addition & 1 deletion Tasks/VsTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 37
"Patch": 38
},
"demands": [
"vstest"
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 @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 37
"Patch": 38
},
"demands": [
"vstest"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

Register-Mock Get-TaskVariable { "c:\testSource" }
Register-Mock Convert-String { $true }
Register-Mock Find-Files { $true }
Register-Mock CmdletHasMember { $true }
Register-Mock Publish-TestResults { $true }
Register-Mock Invoke-VSTest { $true }


$input = @{
'vsTestVersion'='14.0'
'testAssembly'='asd.dll'
'testFiltercriteria'=''
'runSettingsFile'='asd'
'codeCoverageEnabled'='false'
'pathtoCustomTestAdapters'=''
'overrideTestrunParameters'='asd'
'otherConsoleOptions'=''
'testRunTitle'=''
'platform'=''
'configuration'=''
'publishRunAttachments'='true'
'runInParallel'='false'
}
& $PSScriptRoot\..\..\..\Tasks\VsTest\VSTest.ps1 @input

Assert-WasCalled Invoke-VSTest -ParametersEvaluator {
$TestResultsFolder -eq 'c:\testSource\TestResults'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

Register-Mock Get-TaskVariable { "c:\testSource" }
Register-Mock Convert-String { $true }
Register-Mock Find-Files { $true }
Register-Mock CmdletHasMember { $true }
Register-Mock Publish-TestResults { $true }
Register-Mock Invoke-VSTest { $true }


$input = @{
'vsTestVersion'='14.0'
'testAssembly'='asd.dll'
'testFiltercriteria'=''
'runSettingsFile'=''
'codeCoverageEnabled'='false'
'pathtoCustomTestAdapters'=''
'overrideTestrunParameters'='asd'
'otherConsoleOptions'=''
'testRunTitle'=''
'platform'=''
'configuration'=''
'publishRunAttachments'='true'
'runInParallel'='false'
}
& $PSScriptRoot\..\..\..\Tasks\VsTest\VSTest.ps1 @input

Assert-WasCalled Invoke-VSTest -ParametersEvaluator {
$TestResultsFolder -eq 'c:\testSource\TestResults'
}
12 changes: 12 additions & 0 deletions Tests/L0/VsTest/GetResultsLocationReturnsNullForDirectory.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

$tempDirName = [System.Guid]::NewGuid().ToString() + '.runsettings'
$tempDir = New-Item -Type Directory -Name $tempDirName

$resultsLocation = GetResultsLocation $tempDirName

Assert-AreEqual $null $resultsLocation
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

$temprunsettingsfile = [io.path]::ChangeExtension([io.path]::GetTempFileName(),"runsettings")
$runsettings = @('<RunSettings><RunConfiguration>
</RunConfiguration></RunSettings>
')
Set-Content -Value $runsettings -Path $temprunsettingsfile

$resultsLocation = GetResultsLocation $temprunsettingsfile

Assert-AreEqual $null $resultsLocation


if(Test-Path $temprunsettingsfile){
Remove-Item $temprunsettingsfile
}
21 changes: 21 additions & 0 deletions Tests/L0/VsTest/GetResultsLocationReturnsPathForTmpFile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

$temprunsettingsfile = [io.path]::GetTempFileName()
$runsettings = @('<RunSettings><RunConfiguration>
<ResultsDirectory>C:\myResultsFolder</ResultsDirectory>
</RunConfiguration></RunSettings>
')
Set-Content -Value $runsettings -Path $temprunsettingsfile

$resultsLocation = GetResultsLocation $temprunsettingsfile

Assert-AreEqual 'C:\myResultsFolder' $resultsLocation


if(Test-Path $temprunsettingsfile){
Remove-Item $temprunsettingsfile
}
21 changes: 21 additions & 0 deletions Tests/L0/VsTest/GetResultsLocationReturnsPathFromRunsettings.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

$temprunsettingsfile = [io.path]::ChangeExtension([io.path]::GetTempFileName(),"runsettings")
$runsettings = @('<RunSettings><RunConfiguration>
<ResultsDirectory>C:\myResultsFolder</ResultsDirectory>
</RunConfiguration></RunSettings>
')
Set-Content -Value $runsettings -Path $temprunsettingsfile

$resultsLocation = GetResultsLocation $temprunsettingsfile

Assert-AreEqual 'C:\myResultsFolder' $resultsLocation


if(Test-Path $temprunsettingsfile){
Remove-Item $temprunsettingsfile
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

$tempsettingsfile = [io.path]::ChangeExtension([io.path]::GetTempFileName(),"runsettings")
$runsettings = @('<RunSettings><RunConfiguration>
<ResultsDirectory>.\myResultsFolder</ResultsDirectory>
</RunConfiguration></RunSettings>
')
Set-Content -Value $runsettings -Path $tempsettingsfile

$resultsLocation = GetResultsLocation $tempsettingsfile

$expectedLocation = [io.path]::Combine([io.path]::GetDirectoryName($tempsettingsfile), "myResultsFolder")
Assert-AreEqual $expectedLocation $resultsLocation


if(Test-Path $tempsettingsfile){
Remove-Item $tempsettingsfile
}
9 changes: 9 additions & 0 deletions Tests/L0/VsTest/GetResultsReturnsNullForTestsettings.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[cmdletbinding()]
param()

. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1

$resultsLocation = GetResultsLocation "C:\asdf.testsettings"

Assert-AreEqual $null $resultsLocation
Loading