fix pester tests

This commit is contained in:
Aleksandr Chebotov
2020-09-23 10:41:23 +03:00
parent 2148a2bd2f
commit ed62416e84
3 changed files with 19 additions and 14 deletions

View File

@@ -6,14 +6,18 @@ New-Item -Path $shellPath -ItemType Directory | Out-Null
New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null
New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" | Out-Null
# winbash <--> C:\Windows\System32\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null
# WSL is available on Windows Server 2019
if (Test-IsWin19)
{
# winbash <--> C:\Windows\System32\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null
}
# git4bash <--> C:\Program Files\Git\bin\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null
# MSYS2 <--> C:\msys64\usr\bin\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null
New-Item -ItemType SymbolicLink -Path "$shellPath\msys2bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null
# Add shells to PATH
Add-MachinePathItem $shellPath

View File

@@ -12,15 +12,12 @@ $dash = "-" * 40
# Downloading msys2
$msys2Release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest"
$msys2Uri = ((Invoke-RestMethod $msys2Release).assets | Where-Object {
$_.name -match "x86_64" -and $_.name.EndsWith("tar.xz") }).browser_download_url
$_.name -match "x86_64" -and $_.name.EndsWith("sfx.exe") }).browser_download_url
$msys2File = Start-DownloadWithRetry -Url $msys2Uri
# extract tar.xz to C:\
# extract sfx.exe to C:\
Write-Host "Starting msys2 extraction"
$tempPath = Join-Path $env:Temp msys
Extract-7Zip -Path $msys2File -DestinationPath $tempPath
$tarPath = Resolve-Path $tempPath\msys*.tar
Extract-7Zip -Path $tarPath -DestinationPath C:\
& $msys2File -y -oC:\
Write-Host "Finished extraction"
# Add msys2 bin tools folders to PATH temporary
@@ -83,7 +80,4 @@ $pathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path'
$pathValue += ";C:\msys64\mingw64\bin;C:\msys64\usr\bin"
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $pathValue
# Rename python
Rename-Item "C:\msys64\usr\bin\python.exe" -NewName "_python.exe"
Invoke-PesterTests -TestFile "MSYS2"

View File

@@ -2,9 +2,8 @@ Describe "Shell" {
$shellTestCases = @(
@{Name = "C:\shells\bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"},
@{Name = "C:\shells\sh.exe"; Target = "C:\msys64\usr\bin\sh.exe"},
@{Name = "C:\shells\winbash.exe"; Target = "$env:SystemRoot\System32\bash.exe"},
@{Name = "C:\shells\git4bash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"},
@{Name = "C:\shells\msys2.exe"; Target = "C:\msys64\usr\bin\bash.exe"}
@{Name = "C:\shells\msys2bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"}
)
$pathTestCases = @(
@@ -13,6 +12,8 @@ Describe "Shell" {
@{Path = "C:\msys64\usr\bin"}
)
$IsWin16 = Test-IsWin16
It "Default bash.exe from MSYS2" {
(Get-Command bash).Path | Should -BeExactly "C:\shells\bash.exe"
}
@@ -33,6 +34,12 @@ Describe "Shell" {
$path.IndexOf("c:\msys64\usr\bin") | Should -BeGreaterThan $indexOfSystem32
}
It "C:\shells\winbash.exe target to $env:SystemRoot\System32\bash.exe" -Skip:$IsWin16 {
$Name = "C:\shells\winbash.exe"
$Target = "$env:SystemRoot\System32\bash.exe"
(Get-Item $Name).Target | Should -BeExactly $Target
}
It "<Name> target to <Target>" -TestCases $shellTestCases {
(Get-Item $Name).Target | Should -BeExactly $Target
}