From af6a1c4753a6ef5fb6a0d46d526e40df59005d78 Mon Sep 17 00:00:00 2001 From: annaOpareva Date: Thu, 16 Sep 2021 09:05:15 +0300 Subject: [PATCH 1/6] add test --- Tasks/VSBuildV1/Get-VSPath.ps1 | 10 ++- Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 | 24 ++++++ Tasks/VSBuildV1/Tests/L0.ts | 91 +++++++++++----------- Tasks/VSBuildV1/task.loc.json | 2 +- 4 files changed, 78 insertions(+), 49 deletions(-) create mode 100644 Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 diff --git a/Tasks/VSBuildV1/Get-VSPath.ps1 b/Tasks/VSBuildV1/Get-VSPath.ps1 index 3606b6512d55..ceaf2559ebe4 100644 --- a/Tasks/VSBuildV1/Get-VSPath.ps1 +++ b/Tasks/VSBuildV1/Get-VSPath.ps1 @@ -14,10 +14,11 @@ function Get-VSPath { $VersionNumber = [int]$Version.Remove(2) # Search for more than 15.0 Willow instance. if ($VersionNumber -ge 15) { - if (($instance = Get-VisualStudio $VersionNumber) -and - $instance.installationPath) { + $instance = Get-VisualStudio $VersionNumber + Write-Verbose intutochki + Write-Verbose $instance return $instance.installationPath - } + } # Fallback to searching for an older install. if ($path = (Get-ItemProperty -LiteralPath "HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\$Version" -Name 'ShellFolder' -ErrorAction Ignore).ShellFolder) { @@ -25,6 +26,7 @@ function Get-VSPath { } } } finally { - Trace-VstsLeavingInvocation $MyInvocation + Write-Verbose finallyfinally + Trace-VstsLeavingInvocation $MyInvocationS } } \ No newline at end of file diff --git a/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 b/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 new file mode 100644 index 000000000000..3bf44b2503c8 --- /dev/null +++ b/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 @@ -0,0 +1,24 @@ +[CmdletBinding()] +param() + +# Arrange. +. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 +# . $PSScriptRoot\..\Select-VSVersion.ps1 +. $PSScriptRoot\..\Get-VSPath.ps1 +$instance = New-Object Object +Add-Member -NotePropertyName installationPath -NotePropertyValue blablabla -inputObject $instance + +Register-Mock Get-VisualStudio { $instance } -- -Version '17.0' +Write-Verbose "-------------" +Write-Verbose $instance.installationPath +Write-Verbose "-------------" +# Act. + +$pathddd = Get-VSPath -Version '17.0' + +Write-Verbose '+++++++++++' +Write-Verbose $pathddd +Write-Verbose '+++++++++++' + +# Assert. +Assert-AreEqual 'D:\agent\vsts-agent-mauta-1\_work\_tasks\VSBuild126_71a9a2d3-a98a-4caa-96ab-affca126ecda\1.192.1\ps_modules\MSBuildHelpers\vswhere.exe' $pathddd diff --git a/Tasks/VSBuildV1/Tests/L0.ts b/Tasks/VSBuildV1/Tests/L0.ts index 924f1a1328d3..a7751d57570c 100644 --- a/Tasks/VSBuildV1/Tests/L0.ts +++ b/Tasks/VSBuildV1/Tests/L0.ts @@ -27,50 +27,53 @@ describe('VSBuild Suite', function () { }); if (psm.testSupported()) { - it('(Select-VSVersion) falls back from 14', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom14.ps1'), done); - }) - it('(Select-VSVersion) falls back from 15', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom15.ps1'), done); - }) - it('(Select-VSVersion) falls back from 16', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom16.ps1'), done); - }) - it('(Select-VSVersion) falls back from 17', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom17.ps1'), done); - }) - it('(Select-VSVersion) falls forward from 12', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom12.ps1'), done); - }) - it('(Select-VSVersion) falls forward from 14', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom14.ps1'), done); - }) - it('(Select-VSVersion) falls forward from 15', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom15.ps1'), done); - }) - it('(Select-VSVersion) falls forward from 16', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom16.ps1'), done); - }) - it('(Select-VSVersion) finds latest', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FindsLatest.ps1'), done); - }) - it('(Select-VSVersion) finds preferred', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.FindsPreferred.ps1'), done); - }) - it('(Select-VSVersion) warns if not found', (done) => { - psr.run(path.join(__dirname, 'Select-VSVersion.WarnsIfNotFound.ps1'), done); - }) - it('maps vs versions', (done) => { - psr.run(path.join(__dirname, 'MapsVSVersions.ps1'), done); - }) - it('passes arguments', (done) => { - psr.run(path.join(__dirname, 'PassesArguments.ps1'), done); - }) - it('throws if unknown vs version', (done) => { - psr.run(path.join(__dirname, 'ThrowsIfUnknownVSVersion.ps1'), done); - }) - it('warns if deprecated input specified', (done) => { - psr.run(path.join(__dirname, 'WarnsIfDeprecatedInputSpecified.ps1'), done); + it('Check-VSVersion', (done) => { + psr.run(path.join(__dirname, 'Check-VSVersions.ps1'), done); }) + // it('(Select-VSVersion) falls back from 14', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom14.ps1'), done); + // }) + // it('(Select-VSVersion) falls back from 15', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom15.ps1'), done); + // }) + // it('(Select-VSVersion) falls back from 16', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom16.ps1'), done); + // }) + // it('(Select-VSVersion) falls back from 17', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom17.ps1'), done); + // }) + // it('(Select-VSVersion) falls forward from 12', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom12.ps1'), done); + // }) + // it('(Select-VSVersion) falls forward from 14', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom14.ps1'), done); + // }) + // it('(Select-VSVersion) falls forward from 15', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom15.ps1'), done); + // }) + // it('(Select-VSVersion) falls forward from 16', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom16.ps1'), done); + // }) + // it('(Select-VSVersion) finds latest', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FindsLatest.ps1'), done); + // }) + // it('(Select-VSVersion) finds preferred', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.FindsPreferred.ps1'), done); + // }) + // it('(Select-VSVersion) warns if not found', (done) => { + // psr.run(path.join(__dirname, 'Select-VSVersion.WarnsIfNotFound.ps1'), done); + // }) + // it('maps vs versions', (done) => { + // psr.run(path.join(__dirname, 'MapsVSVersions.ps1'), done); + // }) + // it('passes arguments', (done) => { + // psr.run(path.join(__dirname, 'PassesArguments.ps1'), done); + // }) + // it('throws if unknown vs version', (done) => { + // psr.run(path.join(__dirname, 'ThrowsIfUnknownVSVersion.ps1'), done); + // }) + // it('warns if deprecated input specified', (done) => { + // psr.run(path.join(__dirname, 'WarnsIfDeprecatedInputSpecified.ps1'), done); + // }) } }); \ No newline at end of file diff --git a/Tasks/VSBuildV1/task.loc.json b/Tasks/VSBuildV1/task.loc.json index dce786c90bb8..cb80d685d92f 100644 --- a/Tasks/VSBuildV1/task.loc.json +++ b/Tasks/VSBuildV1/task.loc.json @@ -186,4 +186,4 @@ "VSVersion0NotFoundFallbackVersion1": "ms-resource:loc.messages.VSVersion0NotFoundFallbackVersion1", "VSVersion15NotFound": "ms-resource:loc.messages.VSVersion15NotFound" } -} +} \ No newline at end of file From 74f815161d046058b431dee478359cfe6426f700 Mon Sep 17 00:00:00 2001 From: annaOpareva Date: Thu, 16 Sep 2021 16:33:21 +0300 Subject: [PATCH 2/6] draft test --- Tasks/VSBuildV1/Get-VSPath.ps1 | 10 +++--- Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 | 37 +++++++++++++++------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Tasks/VSBuildV1/Get-VSPath.ps1 b/Tasks/VSBuildV1/Get-VSPath.ps1 index ceaf2559ebe4..3606b6512d55 100644 --- a/Tasks/VSBuildV1/Get-VSPath.ps1 +++ b/Tasks/VSBuildV1/Get-VSPath.ps1 @@ -14,11 +14,10 @@ function Get-VSPath { $VersionNumber = [int]$Version.Remove(2) # Search for more than 15.0 Willow instance. if ($VersionNumber -ge 15) { - $instance = Get-VisualStudio $VersionNumber - Write-Verbose intutochki - Write-Verbose $instance + if (($instance = Get-VisualStudio $VersionNumber) -and + $instance.installationPath) { return $instance.installationPath - + } } # Fallback to searching for an older install. if ($path = (Get-ItemProperty -LiteralPath "HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\$Version" -Name 'ShellFolder' -ErrorAction Ignore).ShellFolder) { @@ -26,7 +25,6 @@ function Get-VSPath { } } } finally { - Write-Verbose finallyfinally - Trace-VstsLeavingInvocation $MyInvocationS + Trace-VstsLeavingInvocation $MyInvocation } } \ No newline at end of file diff --git a/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 b/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 index 3bf44b2503c8..8c586b4bb87b 100644 --- a/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 +++ b/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 @@ -3,22 +3,35 @@ param() # Arrange. . $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 -# . $PSScriptRoot\..\Select-VSVersion.ps1 . $PSScriptRoot\..\Get-VSPath.ps1 + $instance = New-Object Object -Add-Member -NotePropertyName installationPath -NotePropertyValue blablabla -inputObject $instance +Add-Member -NotePropertyName installationPath -NotePropertyValue 'use_vswhere' -inputObject $instance + +$GVSVersions = @('17', '16', '15') + +foreach ($GSVersion in $GVSVersions) { + Register-Mock Get-VisualStudio { $instance } -- $GSVersion +} + +$VSVersionsUseRegister = @('14.0', '12.0', '11.0', '10.0') -Register-Mock Get-VisualStudio { $instance } -- -Version '17.0' -Write-Verbose "-------------" -Write-Verbose $instance.installationPath -Write-Verbose "-------------" -# Act. +foreach ($VSVersion in $VSVersionsUseRegister) { + Register-Mock Get-ItemProperty { @{ShellFolder = 'use_register'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\$VSVersion -Name ShellFolder -ErrorAction Ignore -$pathddd = Get-VSPath -Version '17.0' +} -Write-Verbose '+++++++++++' -Write-Verbose $pathddd -Write-Verbose '+++++++++++' +$VSVersionsUseVswhere = @('17.0', '16.0', '15.0') # Assert. -Assert-AreEqual 'D:\agent\vsts-agent-mauta-1\_work\_tasks\VSBuild126_71a9a2d3-a98a-4caa-96ab-affca126ecda\1.192.1\ps_modules\MSBuildHelpers\vswhere.exe' $pathddd + +foreach ($VSVersion in $VSVersionsUseVswhere ) { + $path = Get-VSPath $VSVersion + Assert-AreEqual 'use_vswhere' $path +} + +foreach ($VSVersion in $VSVersionsUseRegister) { + $path = Get-VSPath $VSVersion + Assert-AreEqual 'use_register' $path +} + From 304be56be29742eb967d505bea340cfeb0e708dd Mon Sep 17 00:00:00 2001 From: Anna Opareva Date: Fri, 17 Sep 2021 08:47:35 +0300 Subject: [PATCH 3/6] add tests --- Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 | 1 - .../VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 | 24 +++++ .../Tests/Get-VSPath-Use-VsWhere.ps1 | 23 +++++ Tasks/VSBuildV1/Tests/L0.ts | 96 ++++++++++--------- 4 files changed, 98 insertions(+), 46 deletions(-) create mode 100644 Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 create mode 100644 Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 diff --git a/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 b/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 index 8c586b4bb87b..b3c5cb42011f 100644 --- a/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 +++ b/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 @@ -34,4 +34,3 @@ foreach ($VSVersion in $VSVersionsUseRegister) { $path = Get-VSPath $VSVersion Assert-AreEqual 'use_register' $path } - diff --git a/Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 new file mode 100644 index 000000000000..54803a390845 --- /dev/null +++ b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 @@ -0,0 +1,24 @@ +[CmdletBinding()] +param() + +# Arrange. +. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 +. $PSScriptRoot\..\Get-VSPath.ps1 + +Register-Mock Get-ItemProperty { @{ShellFolder = 'use_reg_key'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0 -Name ShellFolder -ErrorAction Ignore +Register-Mock Get-ItemProperty { @{ShellFolder = 'use_reg_key'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\12.0 -Name ShellFolder -ErrorAction Ignore +Register-Mock Get-ItemProperty { @{ShellFolder = 'use_reg_key'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\11.0 -Name ShellFolder -ErrorAction Ignore +Register-Mock Get-ItemProperty { @{ShellFolder = 'use_reg_key'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0 -Name ShellFolder -ErrorAction Ignore + + +# Assert. + +$path_14 = Get-VSPath '14.0' +$path_12 = Get-VSPath '12.0' +$path_11 = Get-VSPath '11.0' +$path_10 = Get-VSPath '10.0' + +Assert-AreEqual 'use_reg_key' $path_14 +Assert-AreEqual 'use_reg_key' $path_12 +Assert-AreEqual 'use_reg_key' $path_11 +Assert-AreEqual 'use_reg_key' $path_10 diff --git a/Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 new file mode 100644 index 000000000000..a7d429a09124 --- /dev/null +++ b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 @@ -0,0 +1,23 @@ +[CmdletBinding()] +param() + +# Arrange. +. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 +. $PSScriptRoot\..\Get-VSPath.ps1 + +$instance = New-Object Object +Add-Member -NotePropertyName installationPath -NotePropertyValue 'use_vswhere' -inputObject $instance + +Register-Mock Get-VisualStudio { $instance } -- '17' +Register-Mock Get-VisualStudio { $instance } -- '16' +Register-Mock Get-VisualStudio { $instance } -- '15' + +# Assert. + +$path_17 = Get-VSPath '17.0' +$path_16 = Get-VSPath '16.0' +$path_15 = Get-VSPath '15.0' + +Assert-AreEqual 'use_vswhere' $path_17 +Assert-AreEqual 'use_vswhere' $path_16 +Assert-AreEqual 'use_vswhere' $path_15 diff --git a/Tasks/VSBuildV1/Tests/L0.ts b/Tasks/VSBuildV1/Tests/L0.ts index a7751d57570c..9e4fce92cbeb 100644 --- a/Tasks/VSBuildV1/Tests/L0.ts +++ b/Tasks/VSBuildV1/Tests/L0.ts @@ -30,50 +30,56 @@ describe('VSBuild Suite', function () { it('Check-VSVersion', (done) => { psr.run(path.join(__dirname, 'Check-VSVersions.ps1'), done); }) - // it('(Select-VSVersion) falls back from 14', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom14.ps1'), done); - // }) - // it('(Select-VSVersion) falls back from 15', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom15.ps1'), done); - // }) - // it('(Select-VSVersion) falls back from 16', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom16.ps1'), done); - // }) - // it('(Select-VSVersion) falls back from 17', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom17.ps1'), done); - // }) - // it('(Select-VSVersion) falls forward from 12', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom12.ps1'), done); - // }) - // it('(Select-VSVersion) falls forward from 14', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom14.ps1'), done); - // }) - // it('(Select-VSVersion) falls forward from 15', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom15.ps1'), done); - // }) - // it('(Select-VSVersion) falls forward from 16', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom16.ps1'), done); - // }) - // it('(Select-VSVersion) finds latest', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FindsLatest.ps1'), done); - // }) - // it('(Select-VSVersion) finds preferred', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.FindsPreferred.ps1'), done); - // }) - // it('(Select-VSVersion) warns if not found', (done) => { - // psr.run(path.join(__dirname, 'Select-VSVersion.WarnsIfNotFound.ps1'), done); - // }) - // it('maps vs versions', (done) => { - // psr.run(path.join(__dirname, 'MapsVSVersions.ps1'), done); - // }) - // it('passes arguments', (done) => { - // psr.run(path.join(__dirname, 'PassesArguments.ps1'), done); - // }) - // it('throws if unknown vs version', (done) => { - // psr.run(path.join(__dirname, 'ThrowsIfUnknownVSVersion.ps1'), done); - // }) - // it('warns if deprecated input specified', (done) => { - // psr.run(path.join(__dirname, 'WarnsIfDeprecatedInputSpecified.ps1'), done); - // }) + it('Get-VSPath use Reg Key', (done) => { + psr.run(path.join(__dirname, 'Get-VSPath-Use-RegKey.ps1'), done); + }) + it('Get-VSPath use wswhere', (done) => { + psr.run(path.join(__dirname, 'Get-VSPath-Use-VsWhere.ps1'), done); + }) + it('(Select-VSVersion) falls back from 14', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom14.ps1'), done); + }) + it('(Select-VSVersion) falls back from 15', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom15.ps1'), done); + }) + it('(Select-VSVersion) falls back from 16', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom16.ps1'), done); + }) + it('(Select-VSVersion) falls back from 17', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom17.ps1'), done); + }) + it('(Select-VSVersion) falls forward from 12', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom12.ps1'), done); + }) + it('(Select-VSVersion) falls forward from 14', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom14.ps1'), done); + }) + it('(Select-VSVersion) falls forward from 15', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom15.ps1'), done); + }) + it('(Select-VSVersion) falls forward from 16', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom16.ps1'), done); + }) + it('(Select-VSVersion) finds latest', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FindsLatest.ps1'), done); + }) + it('(Select-VSVersion) finds preferred', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.FindsPreferred.ps1'), done); + }) + it('(Select-VSVersion) warns if not found', (done) => { + psr.run(path.join(__dirname, 'Select-VSVersion.WarnsIfNotFound.ps1'), done); + }) + it('maps vs versions', (done) => { + psr.run(path.join(__dirname, 'MapsVSVersions.ps1'), done); + }) + it('passes arguments', (done) => { + psr.run(path.join(__dirname, 'PassesArguments.ps1'), done); + }) + it('throws if unknown vs version', (done) => { + psr.run(path.join(__dirname, 'ThrowsIfUnknownVSVersion.ps1'), done); + }) + it('warns if deprecated input specified', (done) => { + psr.run(path.join(__dirname, 'WarnsIfDeprecatedInputSpecified.ps1'), done); + }) } }); \ No newline at end of file From 92c111ad98c438fec4805c3ffef3760edf518c56 Mon Sep 17 00:00:00 2001 From: Anna Opareva Date: Fri, 17 Sep 2021 10:41:04 +0300 Subject: [PATCH 4/6] fix empty line --- Tasks/VSBuildV1/task.loc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/VSBuildV1/task.loc.json b/Tasks/VSBuildV1/task.loc.json index cb80d685d92f..dce786c90bb8 100644 --- a/Tasks/VSBuildV1/task.loc.json +++ b/Tasks/VSBuildV1/task.loc.json @@ -186,4 +186,4 @@ "VSVersion0NotFoundFallbackVersion1": "ms-resource:loc.messages.VSVersion0NotFoundFallbackVersion1", "VSVersion15NotFound": "ms-resource:loc.messages.VSVersion15NotFound" } -} \ No newline at end of file +} From 87ed1131f2c5e6e747f1c8e600863b83b94e5676 Mon Sep 17 00:00:00 2001 From: annaOpareva Date: Fri, 17 Sep 2021 14:08:15 +0300 Subject: [PATCH 5/6] del extra tests --- Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 | 36 ---------------------- Tasks/VSBuildV1/Tests/L0.ts | 5 +-- 2 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 diff --git a/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 b/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 deleted file mode 100644 index b3c5cb42011f..000000000000 --- a/Tasks/VSBuildV1/Tests/Check-VSVersions.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -[CmdletBinding()] -param() - -# Arrange. -. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 -. $PSScriptRoot\..\Get-VSPath.ps1 - -$instance = New-Object Object -Add-Member -NotePropertyName installationPath -NotePropertyValue 'use_vswhere' -inputObject $instance - -$GVSVersions = @('17', '16', '15') - -foreach ($GSVersion in $GVSVersions) { - Register-Mock Get-VisualStudio { $instance } -- $GSVersion -} - -$VSVersionsUseRegister = @('14.0', '12.0', '11.0', '10.0') - -foreach ($VSVersion in $VSVersionsUseRegister) { - Register-Mock Get-ItemProperty { @{ShellFolder = 'use_register'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\$VSVersion -Name ShellFolder -ErrorAction Ignore - -} - -$VSVersionsUseVswhere = @('17.0', '16.0', '15.0') - -# Assert. - -foreach ($VSVersion in $VSVersionsUseVswhere ) { - $path = Get-VSPath $VSVersion - Assert-AreEqual 'use_vswhere' $path -} - -foreach ($VSVersion in $VSVersionsUseRegister) { - $path = Get-VSPath $VSVersion - Assert-AreEqual 'use_register' $path -} diff --git a/Tasks/VSBuildV1/Tests/L0.ts b/Tasks/VSBuildV1/Tests/L0.ts index 9e4fce92cbeb..85619e957ba4 100644 --- a/Tasks/VSBuildV1/Tests/L0.ts +++ b/Tasks/VSBuildV1/Tests/L0.ts @@ -27,13 +27,10 @@ describe('VSBuild Suite', function () { }); if (psm.testSupported()) { - it('Check-VSVersion', (done) => { - psr.run(path.join(__dirname, 'Check-VSVersions.ps1'), done); - }) it('Get-VSPath use Reg Key', (done) => { psr.run(path.join(__dirname, 'Get-VSPath-Use-RegKey.ps1'), done); }) - it('Get-VSPath use wswhere', (done) => { + it('Get-VSPath use vswhere', (done) => { psr.run(path.join(__dirname, 'Get-VSPath-Use-VsWhere.ps1'), done); }) it('(Select-VSVersion) falls back from 14', (done) => { From 65f5cf0e2e86c6bca38c73d62a4ae0b6746fe012 Mon Sep 17 00:00:00 2001 From: annaOpareva Date: Fri, 17 Sep 2021 15:21:45 +0300 Subject: [PATCH 6/6] add act --- Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 | 5 ++--- Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 index 54803a390845..c56142782815 100644 --- a/Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 +++ b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-RegKey.ps1 @@ -10,14 +10,13 @@ Register-Mock Get-ItemProperty { @{ShellFolder = 'use_reg_key'} } -- -LiteralPat Register-Mock Get-ItemProperty { @{ShellFolder = 'use_reg_key'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\11.0 -Name ShellFolder -ErrorAction Ignore Register-Mock Get-ItemProperty { @{ShellFolder = 'use_reg_key'} } -- -LiteralPath HKLM:\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0 -Name ShellFolder -ErrorAction Ignore - -# Assert. - +# Aсt. $path_14 = Get-VSPath '14.0' $path_12 = Get-VSPath '12.0' $path_11 = Get-VSPath '11.0' $path_10 = Get-VSPath '10.0' +# Assert. Assert-AreEqual 'use_reg_key' $path_14 Assert-AreEqual 'use_reg_key' $path_12 Assert-AreEqual 'use_reg_key' $path_11 diff --git a/Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 index a7d429a09124..66c6edf70297 100644 --- a/Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 +++ b/Tasks/VSBuildV1/Tests/Get-VSPath-Use-VsWhere.ps1 @@ -12,12 +12,12 @@ Register-Mock Get-VisualStudio { $instance } -- '17' Register-Mock Get-VisualStudio { $instance } -- '16' Register-Mock Get-VisualStudio { $instance } -- '15' -# Assert. - +# Act. $path_17 = Get-VSPath '17.0' $path_16 = Get-VSPath '16.0' $path_15 = Get-VSPath '15.0' +# Assert. Assert-AreEqual 'use_vswhere' $path_17 Assert-AreEqual 'use_vswhere' $path_16 Assert-AreEqual 'use_vswhere' $path_15