|
1 | 1 | function CmdletHasMember { |
2 | | - [cmdletbinding()] |
3 | | - [OutputType([System.Boolean])] |
4 | | - param( |
5 | | - [string]$memberName |
6 | | - ) |
7 | | - |
8 | | - $publishParameters = (gcm Publish-TestResults).Parameters.Keys.Contains($memberName) |
9 | | - return $publishParameters |
| 2 | + [cmdletbinding()] |
| 3 | + [OutputType([System.Boolean])] |
| 4 | + param( |
| 5 | + [string]$memberName |
| 6 | + ) |
| 7 | + |
| 8 | + $publishParameters = (gcm Publish-TestResults).Parameters.Keys.Contains($memberName) |
| 9 | + return $publishParameters |
10 | 10 | } |
11 | 11 |
|
12 | 12 | function SetRegistryKeyForParallel { |
13 | | - [cmdletbinding()] |
14 | | - param( |
15 | | - [string]$vsTestVersion |
16 | | - ) |
17 | | - |
18 | | - $regkey = "HKCU\SOFTWARE\Microsoft\VisualStudio\" + $vsTestVersion + "_Config\FeatureFlags\TestingTools\UnitTesting\Taef" |
19 | | - reg add $regkey /v Value /t REG_DWORD /d 1 /f /reg:32 > $null |
| 13 | + [cmdletbinding()] |
| 14 | + param( |
| 15 | + [string]$vsTestVersion |
| 16 | + ) |
| 17 | + |
| 18 | + $regkey = "HKCU\SOFTWARE\Microsoft\VisualStudio\" + $vsTestVersion + "_Config\FeatureFlags\TestingTools\UnitTesting\Taef" |
| 19 | + reg add $regkey /v Value /t REG_DWORD /d 1 /f /reg:32 > $null |
20 | 20 | } |
21 | 21 |
|
22 | 22 | function IsVisualStudio2015Update1OrHigherInstalled { |
23 | | - [cmdletbinding()] |
24 | | - [OutputType([System.Boolean])] |
25 | | - param( |
26 | | - [string]$vsTestVersion |
27 | | - ) |
28 | | - |
29 | | - if ([string]::IsNullOrWhiteSpace($vsTestVersion)){ |
30 | | - $vsTestVersion = Locate-VSVersion |
31 | | - } |
32 | | - |
33 | | - $version = [int]($vsTestVersion) |
34 | | - if($version -ge 14) |
35 | | - { |
36 | | - # checking for dll introduced in vs2015 update1 |
37 | | - # since path of the dll will change in dev15+ using vstestversion>14 as a blanket yes |
38 | | - if((Test-Path -Path "$env:VS140COMNTools\..\IDE\CommonExtensions\Microsoft\TestWindow\TE.TestModes.dll") -Or ($version -gt 14)) |
39 | | - { |
40 | | - # ensure the registry is set otherwise you need to launch VSIDE |
41 | | - SetRegistryKeyForParallel $vsTestVersion |
42 | | - |
43 | | - return $true |
44 | | - } |
45 | | - } |
46 | | - |
47 | | - return $false |
| 23 | + [cmdletbinding()] |
| 24 | + [OutputType([System.Boolean])] |
| 25 | + param( |
| 26 | + [string]$vsTestVersion |
| 27 | + ) |
| 28 | + |
| 29 | + if ([string]::IsNullOrWhiteSpace($vsTestVersion)){ |
| 30 | + $vsTestVersion = Locate-VSVersion |
| 31 | + } |
| 32 | + |
| 33 | + $version = [int]($vsTestVersion) |
| 34 | + if($version -ge 14) |
| 35 | + { |
| 36 | + # checking for dll introduced in vs2015 update1 |
| 37 | + # since path of the dll will change in dev15+ using vstestversion>14 as a blanket yes |
| 38 | + if((Test-Path -Path "$env:VS140COMNTools\..\IDE\CommonExtensions\Microsoft\TestWindow\TE.TestModes.dll") -Or ($version -gt 14)) |
| 39 | + { |
| 40 | + # ensure the registry is set otherwise you need to launch VSIDE |
| 41 | + SetRegistryKeyForParallel $vsTestVersion |
| 42 | + |
| 43 | + return $true |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + return $false |
48 | 48 | } |
49 | 49 |
|
50 | 50 | function SetupRunSettingsFileForParallel { |
51 | | - [cmdletbinding()] |
52 | | - [OutputType([System.String])] |
53 | | - param( |
54 | | - [string]$runInParallelFlag, |
55 | | - [string]$runSettingsFilePath, |
56 | | - [string]$defaultCpuCount |
57 | | - ) |
| 51 | + [cmdletbinding()] |
| 52 | + [OutputType([System.String])] |
| 53 | + param( |
| 54 | + [string]$runInParallelFlag, |
| 55 | + [string]$runSettingsFilePath, |
| 56 | + [string]$defaultCpuCount |
| 57 | + ) |
58 | 58 |
|
59 | | - if($runInParallelFlag -eq "True") |
60 | | - { |
61 | | - $runSettingsForParallel = [xml]'<?xml version="1.0" encoding="utf-8"?>' |
62 | | - 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 |
63 | | - { |
64 | | - Write-Verbose "No runsettings file provided" |
65 | | - $runSettingsForParallel = [xml]'<?xml version="1.0" encoding="utf-8"?> |
66 | | -<RunSettings> |
67 | | - <RunConfiguration> |
68 | | - <MaxCpuCount>0</MaxCpuCount> |
69 | | - </RunConfiguration> |
70 | | -</RunSettings> |
71 | | -' |
72 | | - } |
73 | | - else |
74 | | - { |
75 | | - Write-Verbose "Adding maxcpucount element to runsettings file provided" |
76 | | - $runSettingsForParallel = [System.Xml.XmlDocument](Get-Content $runSettingsFilePath) |
77 | | - $runConfigurationElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration") |
78 | | - if($runConfigurationElement.Count -eq 0) |
79 | | - { |
80 | | - $runConfigurationElement = $runSettingsForParallel.RunSettings.AppendChild($runSettingsForParallel.CreateElement("RunConfiguration")) |
81 | | - } |
| 59 | + if($runInParallelFlag -eq "True") |
| 60 | + { |
| 61 | + if([string]::Compare([io.path]::GetExtension($runSettingsFilePath), ".testsettings", $True) -eq 0) |
| 62 | + { |
| 63 | + Write-Warning "Run in Parallel is not supported with testsettings file." |
| 64 | + } |
| 65 | + else |
| 66 | + { |
| 67 | + $runSettingsForParallel = [xml]'<?xml version="1.0" encoding="utf-8"?>' |
| 68 | + 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 |
| 69 | + { |
| 70 | + Write-Verbose "No runsettings file provided" |
| 71 | + $runSettingsForParallel = [xml]'<?xml version="1.0" encoding="utf-8"?> |
| 72 | + <RunSettings> |
| 73 | + <RunConfiguration> |
| 74 | + <MaxCpuCount>0</MaxCpuCount> |
| 75 | + </RunConfiguration> |
| 76 | + </RunSettings> |
| 77 | + ' |
| 78 | + } |
| 79 | + else |
| 80 | + { |
| 81 | + Write-Verbose "Adding maxcpucount element to runsettings file provided" |
| 82 | + $runSettingsForParallel = [System.Xml.XmlDocument](Get-Content $runSettingsFilePath) |
| 83 | + $runConfigurationElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration") |
| 84 | + if($runConfigurationElement.Count -eq 0) |
| 85 | + { |
| 86 | + $runConfigurationElement = $runSettingsForParallel.RunSettings.AppendChild($runSettingsForParallel.CreateElement("RunConfiguration")) |
| 87 | + } |
82 | 88 |
|
83 | | - $maxCpuCountElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration/MaxCpuCount") |
84 | | - if($maxCpuCountElement.Count -eq 0) |
85 | | - { |
86 | | - $newMaxCpuCountElement = $runConfigurationElement.AppendChild($runSettingsForParallel.CreateElement("MaxCpuCount")) |
87 | | - } |
88 | | - } |
| 89 | + $maxCpuCountElement = $runSettingsForParallel.SelectNodes("//RunSettings/RunConfiguration/MaxCpuCount") |
| 90 | + if($maxCpuCountElement.Count -eq 0) |
| 91 | + { |
| 92 | + $newMaxCpuCountElement = $runConfigurationElement.AppendChild($runSettingsForParallel.CreateElement("MaxCpuCount")) |
| 93 | + } |
| 94 | + } |
89 | 95 |
|
90 | | - $runSettingsForParallel.RunSettings.RunConfiguration.MaxCpuCount = $defaultCpuCount |
91 | | - $tempFile = [io.path]::GetTempFileName() |
92 | | - $runSettingsForParallel.Save($tempFile) |
93 | | - Write-Verbose "Temporary runsettings file created at $tempFile" |
94 | | - return $tempFile |
95 | | - } |
96 | | - return $runSettingsFilePath |
| 96 | + $runSettingsForParallel.RunSettings.RunConfiguration.MaxCpuCount = $defaultCpuCount |
| 97 | + $tempFile = [io.path]::GetTempFileName() |
| 98 | + $runSettingsForParallel.Save($tempFile) |
| 99 | + Write-Verbose "Temporary runsettings file created at $tempFile" |
| 100 | + return $tempFile |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + return $runSettingsFilePath |
97 | 105 | } |
98 | 106 |
|
99 | 107 | function Get-SubKeysInFloatFormat($keys) |
|
0 commit comments