diff --git a/Tasks/VsTest/Helpers.ps1 b/Tasks/VsTest/Helpers.ps1
index 52b278a55b17..e878115d6a4c 100644
--- a/Tasks/VsTest/Helpers.ps1
+++ b/Tasks/VsTest/Helpers.ps1
@@ -1,99 +1,107 @@
function CmdletHasMember {
- [cmdletbinding()]
- [OutputType([System.Boolean])]
- param(
- [string]$memberName
- )
-
- $publishParameters = (gcm Publish-TestResults).Parameters.Keys.Contains($memberName)
- return $publishParameters
+ [cmdletbinding()]
+ [OutputType([System.Boolean])]
+ param(
+ [string]$memberName
+ )
+
+ $publishParameters = (gcm Publish-TestResults).Parameters.Keys.Contains($memberName)
+ return $publishParameters
}
function SetRegistryKeyForParallel {
- [cmdletbinding()]
- param(
- [string]$vsTestVersion
- )
-
- $regkey = "HKCU\SOFTWARE\Microsoft\VisualStudio\" + $vsTestVersion + "_Config\FeatureFlags\TestingTools\UnitTesting\Taef"
- reg add $regkey /v Value /t REG_DWORD /d 1 /f /reg:32 > $null
+ [cmdletbinding()]
+ param(
+ [string]$vsTestVersion
+ )
+
+ $regkey = "HKCU\SOFTWARE\Microsoft\VisualStudio\" + $vsTestVersion + "_Config\FeatureFlags\TestingTools\UnitTesting\Taef"
+ reg add $regkey /v Value /t REG_DWORD /d 1 /f /reg:32 > $null
}
function IsVisualStudio2015Update1OrHigherInstalled {
- [cmdletbinding()]
- [OutputType([System.Boolean])]
- param(
- [string]$vsTestVersion
- )
-
- if ([string]::IsNullOrWhiteSpace($vsTestVersion)){
- $vsTestVersion = Locate-VSVersion
- }
-
- $version = [int]($vsTestVersion)
- if($version -ge 14)
- {
- # checking for dll introduced in vs2015 update1
- # since path of the dll will change in dev15+ using vstestversion>14 as a blanket yes
- if((Test-Path -Path "$env:VS140COMNTools\..\IDE\CommonExtensions\Microsoft\TestWindow\TE.TestModes.dll") -Or ($version -gt 14))
- {
- # ensure the registry is set otherwise you need to launch VSIDE
- SetRegistryKeyForParallel $vsTestVersion
-
- return $true
- }
- }
-
- return $false
+ [cmdletbinding()]
+ [OutputType([System.Boolean])]
+ param(
+ [string]$vsTestVersion
+ )
+
+ if ([string]::IsNullOrWhiteSpace($vsTestVersion)){
+ $vsTestVersion = Locate-VSVersion
+ }
+
+ $version = [int]($vsTestVersion)
+ if($version -ge 14)
+ {
+ # checking for dll introduced in vs2015 update1
+ # since path of the dll will change in dev15+ using vstestversion>14 as a blanket yes
+ if((Test-Path -Path "$env:VS140COMNTools\..\IDE\CommonExtensions\Microsoft\TestWindow\TE.TestModes.dll") -Or ($version -gt 14))
+ {
+ # ensure the registry is set otherwise you need to launch VSIDE
+ SetRegistryKeyForParallel $vsTestVersion
+
+ return $true
+ }
+ }
+
+ return $false
}
function SetupRunSettingsFileForParallel {
- [cmdletbinding()]
- [OutputType([System.String])]
- param(
- [string]$runInParallelFlag,
- [string]$runSettingsFilePath,
- [string]$defaultCpuCount
- )
+ [cmdletbinding()]
+ [OutputType([System.String])]
+ param(
+ [string]$runInParallelFlag,
+ [string]$runSettingsFilePath,
+ [string]$defaultCpuCount
+ )
- if($runInParallelFlag -eq "True")
- {
- $runSettingsForParallel = [xml]''
- if([System.String]::IsNullOrWhiteSpace($runSettingsFilePath) -Or ([string]::Compare([io.path]::GetExtension($runSettingsFilePath), ".runsettings", $True) -ne 0) -Or (Test-Path $runSettingsFilePath -pathtype container)) # no file provided so create one and use it for the run
- {
- Write-Verbose "No runsettings file provided"
- $runSettingsForParallel = [xml]'
-
-
- 0
-
-
-'
- }
- else
- {
- Write-Verbose "Adding maxcpucount element to runsettings file provided"
- $runSettingsForParallel = [System.Xml.XmlDocument](Get-Content $runSettingsFilePath)
- $runConfigurationElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration")
- if($runConfigurationElement.Count -eq 0)
- {
- $runConfigurationElement = $runSettingsForParallel.RunSettings.AppendChild($runSettingsForParallel.CreateElement("RunConfiguration"))
- }
+ if($runInParallelFlag -eq "True")
+ {
+ if([string]::Compare([io.path]::GetExtension($runSettingsFilePath), ".testsettings", $True) -eq 0)
+ {
+ Write-Warning "Run in Parallel is not supported with testsettings file."
+ }
+ else
+ {
+ $runSettingsForParallel = [xml]''
+ if([System.String]::IsNullOrWhiteSpace($runSettingsFilePath) -Or ([string]::Compare([io.path]::GetExtension($runSettingsFilePath), ".runsettings", $True) -ne 0) -Or (Test-Path $runSettingsFilePath -pathtype container)) # no file provided so create one and use it for the run
+ {
+ Write-Verbose "No runsettings file provided"
+ $runSettingsForParallel = [xml]'
+
+
+ 0
+
+
+ '
+ }
+ else
+ {
+ Write-Verbose "Adding maxcpucount element to runsettings file provided"
+ $runSettingsForParallel = [System.Xml.XmlDocument](Get-Content $runSettingsFilePath)
+ $runConfigurationElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration")
+ if($runConfigurationElement.Count -eq 0)
+ {
+ $runConfigurationElement = $runSettingsForParallel.RunSettings.AppendChild($runSettingsForParallel.CreateElement("RunConfiguration"))
+ }
- $maxCpuCountElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration/MaxCpuCount")
- if($maxCpuCountElement.Count -eq 0)
- {
- $newMaxCpuCountElement = $runConfigurationElement.AppendChild($runSettingsForParallel.CreateElement("MaxCpuCount"))
- }
- }
+ $maxCpuCountElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration/MaxCpuCount")
+ if($maxCpuCountElement.Count -eq 0)
+ {
+ $newMaxCpuCountElement = $runConfigurationElement.AppendChild($runSettingsForParallel.CreateElement("MaxCpuCount"))
+ }
+ }
- $runSettingsForParallel.RunSettings.RunConfiguration.MaxCpuCount = $defaultCpuCount
- $tempFile = [io.path]::GetTempFileName()
- $runSettingsForParallel.Save($tempFile)
- Write-Verbose "Temporary runsettings file created at $tempFile"
- return $tempFile
- }
- return $runSettingsFilePath
+ $runSettingsForParallel.RunSettings.RunConfiguration.MaxCpuCount = $defaultCpuCount
+ $tempFile = [io.path]::GetTempFileName()
+ $runSettingsForParallel.Save($tempFile)
+ Write-Verbose "Temporary runsettings file created at $tempFile"
+ return $tempFile
+ }
+ }
+
+ return $runSettingsFilePath
}
function Get-SubKeysInFloatFormat($keys)
diff --git a/Tasks/VsTest/task.json b/Tasks/VsTest/task.json
index 272eb6ae42d5..0726ca924b6a 100644
--- a/Tasks/VsTest/task.json
+++ b/Tasks/VsTest/task.json
@@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
- "Patch": 36
+ "Patch": 37
},
"demands": [
"vstest"
diff --git a/Tasks/VsTest/task.loc.json b/Tasks/VsTest/task.loc.json
index 3948fc794972..f1bbfce95511 100644
--- a/Tasks/VsTest/task.loc.json
+++ b/Tasks/VsTest/task.loc.json
@@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
- "Patch": 36
+ "Patch": 37
},
"demands": [
"vstest"
diff --git a/Tests/L0/VsTest/RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsFile.ps1 b/Tests/L0/VsTest/RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsNonTestSettingsFile.ps1
similarity index 97%
rename from Tests/L0/VsTest/RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsFile.ps1
rename to Tests/L0/VsTest/RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsNonTestSettingsFile.ps1
index 1053ac243a85..c007ac4629a4 100644
--- a/Tests/L0/VsTest/RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsFile.ps1
+++ b/Tests/L0/VsTest/RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsNonTestSettingsFile.ps1
@@ -9,7 +9,7 @@ Register-Mock Get-TaskVariable
. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1
$cpuCount="1"
-$temptestsettingsfile = [io.path]::ChangeExtension([io.path]::GetTempFileName(),"testsettings")
+$temptestsettingsfile = [io.path]::ChangeExtension([io.path]::GetTempFileName(),"xml")
$testsettings = @('
Empty testsettings
diff --git a/Tests/L0/VsTest/RunSettingsForParallel.ReturnsSameFileIfParallelIsTrueAndFileNameIsTestSettingsFile.ps1 b/Tests/L0/VsTest/RunSettingsForParallel.ReturnsSameFileIfParallelIsTrueAndFileNameIsTestSettingsFile.ps1
new file mode 100644
index 000000000000..295b366b20d3
--- /dev/null
+++ b/Tests/L0/VsTest/RunSettingsForParallel.ReturnsSameFileIfParallelIsTrueAndFileNameIsTestSettingsFile.ps1
@@ -0,0 +1,33 @@
+[cmdletbinding()]
+param()
+
+# Arrange.
+. $PSScriptRoot\..\..\lib\Initialize-Test.ps1
+Register-Mock Get-LocalizedString { $OFS = " " ; "$args" }
+Register-Mock Get-TaskVariable
+
+. $PSScriptRoot\..\..\..\Tasks\VsTest\Helpers.ps1
+
+$cpuCount="1"
+$temptestsettingsfile = [io.path]::ChangeExtension([io.path]::GetTempFileName(),"testsettings")
+$testsettings = @('
+
+ Empty testsettings
+
+')
+Set-Content -Value $testsettings -Path $temptestsettingsfile
+
+$returnedFilePath = SetupRunSettingsFileForParallel "true" $temptestsettingsfile $cpuCount
+
+$fileExists = Test-Path $returnedFilePath
+Assert-AreEqual $true $fileExists
+
+Assert-AreEqual $temptestsettingsfile $returnedFilePath
+
+#cleanup
+if($fileExists){
+ Remove-Item $returnedFilePath
+}
+if(Test-Path $temptestsettingsfile){
+ Remove-Item $temptestsettingsfile
+}
\ No newline at end of file
diff --git a/Tests/L0/VsTest/_suite.ts b/Tests/L0/VsTest/_suite.ts
index 98abb81ef797..a8870ff22ec3 100644
--- a/Tests/L0/VsTest/_suite.ts
+++ b/Tests/L0/VsTest/_suite.ts
@@ -67,14 +67,17 @@ describe('VsTest Suite', function () {
it('(RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsADirectory) returns new file if parallel flag is true and runsettings input is a directory', (done) => {
psr.run(path.join(__dirname, 'RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsADirectory.ps1'), done);
})
- it('(RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsFile) returns new file if parallel flag is true and runsettings input is not a runsettings file', (done) => {
- psr.run(path.join(__dirname, 'RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsFile.ps1'), done);
+ it('(RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsNonTestSettingsFile) returns new file if parallel flag is true and runsettings input is not a runsettings or testsettings file', (done) => {
+ psr.run(path.join(__dirname, 'RunSettingsForParallel.ReturnsNewFileIfParallelIsTrueAndFileNameIsANonRunsettingsNonTestSettingsFile.ps1'), done);
})
it('ValidateTestAssembliesAreSplit) tests if the input test assembiles are properly passed to cmdlet', (done) => {
psr.run(path.join(__dirname, 'ValidateTestAssembliesAreSplit.ps1'), done);
})
- it('ValidateTestAssembliesAreSplit) tests if the input test assembiles are properly passed to cmdlet', (done) => {
+ it('ValidateTestAssembliesAreSplit) tests if the input test assembiles are properly passed to cmdlet', (done) => {
psr.run(path.join(__dirname, 'ValidateTestAssembliesAreNotSplit.ps1'), done);
+ })
+ it('(RunSettingsForParallel.ReturnsSameFileIfParallelIsTrueAndFileNameIsTestSettingsFile) returns same file if parallel flag is true and runsettings input is a testsettings file', (done) => {
+ psr.run(path.join(__dirname, 'RunSettingsForParallel.ReturnsSameFileIfParallelIsTrueAndFileNameIsTestSettingsFile.ps1'), done);
})
}
});
\ No newline at end of file