diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..f4a67ea31 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: Test Posh-Git + +on: [push, pull_request] + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: ['windows-latest', 'macos-latest', 'ubuntu-latest'] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: install dependencies + shell: pwsh + run: | + "Git version: $(git --version)" + "PSVersion: $($PSVersionTable.PSVersion)" + "Host name: $($Host.Name)" + + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + Install-Module Pester -MinimumVersion 5.0.0 -MaximumVersion 5.99.99 -Scope CurrentUser -Force + - name: run tests + shell: pwsh + run: | + Import-Module Pester -PassThru + $ErrorActionPreference = 'Continue' + $res = Invoke-Pester -Path test -Output Detailed -PassThru -ErrorAction SilentlyContinue + if (!$res -or ($res.FailedCount -gt 0)) { + $Error | Format-List * -Force + exit 1 + } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index baf9c4bf4..000000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: generic - -branches: - only: - - master - -stages: -- name: linux -- name: osx - if: type != pull_request OR head_branch =~ osx - -jobs: - include: - - stage: linux - os: linux - dist: xenial - sudo: false - addons: - apt: - sources: - - sourceline: deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main - key_url: https://packages.microsoft.com/keys/microsoft.asc - packages: - - powershell - before_install: - - pwsh -c 'Set-PSRepository -Name PSGallery -InstallationPolicy Trusted' - - pwsh -c 'Install-Module Pester -AllowPrerelease -MinimumVersion 5.0.0 -MaximumVersion 5.99.99 -Scope CurrentUser -Force | Out-Null' - - stage: osx - os: osx - before_install: - - brew update - - brew install --cask powershell - - pwsh -c 'Set-PSRepository -Name PSGallery -InstallationPolicy Trusted' - - pwsh -c 'Install-Module Pester -MinimumVersion 5.0.0 -MaximumVersion 5.99.99 -Scope CurrentUser -Force | Out-Null' - -script: - - pwsh -c 'Import-Module Pester -PassThru; $res = Invoke-Pester -Path test -Output Detailed -PassThru -ErrorAction SilentlyContinue; if (!$res -or ($res.FailedCount -gt 0)) { $Error | Format-List * -Force; exit 1 }' diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 41c1c4b6d..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,64 +0,0 @@ -os: - - "WMF 5" - -environment: - CA_KEY: - secure: JQtUaB+zduPID8bzI5nfHRc2V6xYJiJp4mTHkE4W6broH8rznT1ypvn5orQ6YcGn - -branches: - only: - - master - - v0 - -init: - - git config --global core.autocrlf true - -install: - - ps: | - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null - Install-Module Pester -MinimumVersion 5.0.0 -MaximumVersion 5.99.99 -Scope CurrentUser -Force | Out-Null - "Git version: $(git.exe --version)" - "PSVersion: $($PSVersionTable.PSVersion), build: $($PSVersionTable.BuildVersion), clr version: $($PSVersionTable.ClrVersion)" - "Host name: $($Host.Name)" - -build: false - -before_test: - - ps: Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - - ps: Install-Module Coveralls -MinimumVersion 1.0.5 -Scope CurrentUser - - ps: Import-Module Coveralls - -test_script: - - ps: | - $testResultsFile = Join-Path $Env:APPVEYOR_BUILD_FOLDER TestResults.xml - - Import-Module Pester -PassThru - - $configuration = [PesterConfiguration]::Default - $configuration.Run.Path = "$Env:APPVEYOR_BUILD_FOLDER\test" - $configuration.Run.PassThru = $true - $configuration.Output.Verbosity = "Detailed" - $configuration.TestResult.Enabled = $true - $configuration.TestResult.OutputFormat = "NUnit2.5" - $configuration.TestResult.OutputPath = $testResultsFile - $configuration.CodeCoverage.Enabled = $true - $configuration.CodeCoverage.Path = (gci .\src\* -include *.ps1,*.psm1) - - $res = Invoke-Pester -Configuration $configuration -ErrorAction SilentlyContinue - if (Test-Path $testResultsFile) { - (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $testResultsFile) - } - if (!$res -or ($res.FailedCount -gt 0)) { - # Terminate the script to fail the build - $Error | Format-List * -Force - exit 1; - } - $ErrorActionPreference = 'Stop' - if (!(Test-Path Env:CA_KEY)) { - Write-Host 'CA_KEY not set! (Expected on PR builds.)' - return; - } - Write-Host 'Skipping coverage; anyone know how to fix?' - Write-Host '"Please provide pester results with code coverage using the -CodeCoverage parameter"' - # $coverageResult = Format-Coverage -PesterResults $res -CoverallsApiToken $ENV:CA_KEY -BranchName $ENV:APPVEYOR_REPO_BRANCH - # Publish-Coverage -Coverage $coverageResult diff --git a/test/DefaultPrompt.Tests.ps1 b/test/DefaultPrompt.Tests.ps1 index d7f2ab647..9344455d5 100644 --- a/test/DefaultPrompt.Tests.ps1 +++ b/test/DefaultPrompt.Tests.ps1 @@ -540,7 +540,7 @@ M test/Baz.Tests.ps1 $title | Should -match '^Windows PowerShell|:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe$' } else { - $title | Should -match '^(Windows )?PowerShell' + $title | Should -match '^(Administrator: )?(Windows )?PowerShell' } } } diff --git a/test/GitProxyFunctionExpansion.Tests.ps1 b/test/GitProxyFunctionExpansion.Tests.ps1 index 9ef606db7..9b253b17c 100644 --- a/test/GitProxyFunctionExpansion.Tests.ps1 +++ b/test/GitProxyFunctionExpansion.Tests.ps1 @@ -28,34 +28,34 @@ Describe 'Proxy Function Expansion Tests' { } } It 'Expands a proxy function with parameters' { - function script:Invoke-GitFunction { git checkout $args } + function global:Invoke-GitFunction { git checkout $args } $result = & $module Expand-GitProxyFunction 'Invoke-GitFunction -b newbranch' $result | Should -Be 'git checkout -b newbranch' $result | Should -Be (& $module Expand-GitProxyFunction 'igf -b newbranch') } It 'Expands a multiline proxy function' { - function script:Invoke-GitFunction { git checkout $args } + function global:Invoke-GitFunction { git checkout $args } $result = & $module Expand-GitProxyFunction "Invoke-GitFunction ```r`n-b ```r`nnewbranch" $result | Should -Be 'git checkout -b newbranch' $result | Should -Be (& $module Expand-GitProxyFunction "igf ```r`n-b ```r`nnewbranch") } It 'Does not expand the proxy function name if there is no preceding whitespace before backtick newlines' { - function script:Invoke-GitFunction { git checkout $args } + function global:Invoke-GitFunction { git checkout $args } & $module Expand-GitProxyFunction "Invoke-GitFunction```r`n-b```r`nnewbranch" | Should -Be "Invoke-GitFunction```r`n-b```r`nnewbranch" & $module Expand-GitProxyFunction "igf```r`n-b```r`nnewbranch" | Should -Be "igf```r`n-b```r`nnewbranch" } It 'Does not expand the proxy function name if there is no preceding non-newline whitespace before any backtick newlines' { - function script:Invoke-GitFunction { git checkout $args } + function global:Invoke-GitFunction { git checkout $args } & $module Expand-GitProxyFunction "Invoke-GitFunction ```r`n-b```r`nnewbranch" | Should -Be "Invoke-GitFunction ```r`n-b```r`nnewbranch" & $module Expand-GitProxyFunction "igf ```r`n-b```r`nnewbranch" | Should -Be "igf ```r`n-b```r`nnewbranch" } It 'Does not expand the proxy function name if the preceding whitespace before backtick newlines are newlines' { - function script:Invoke-GitFunction { git checkout $args } + function global:Invoke-GitFunction { git checkout $args } & $module Expand-GitProxyFunction "Invoke-GitFunction`r`n```r`n-b`r`n```r`nnewbranch" | Should -Be "Invoke-GitFunction`r`n```r`n-b`r`n```r`nnewbranch" & $module Expand-GitProxyFunction "igf`r`n```r`n-b`r`n```r`nnewbranch" | Should -Be "igf`r`n```r`n-b`r`n```r`nnewbranch" } It 'Does not expand the proxy function if there is no trailing space' { - function script:Invoke-GitFunction { git checkout $args } + function global:Invoke-GitFunction { git checkout $args } & $module Expand-GitProxyFunction 'Invoke-GitFunction' | Should -Be 'Invoke-GitFunction' & $module Expand-GitProxyFunction 'igf' | Should -Be 'igf' } @@ -85,7 +85,7 @@ Describe 'Proxy Function Expansion Tests' { } } It 'Expands a single line function' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git checkout $args } $result = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' @@ -93,7 +93,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands a single line function with short parameter' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git checkout -b $args } $result = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' @@ -101,7 +101,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands a single line function with long parameter' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git checkout --detach $args } $result = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' @@ -109,7 +109,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands a single line with piped function suffix' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git checkout --detach $args | Write-Host } $result = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' @@ -117,7 +117,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands the first line in function' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git checkout $args $a = 5 Write-Host $null @@ -127,7 +127,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands the middle line in function' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5 git checkout $args Write-Host $null @@ -137,7 +137,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands the last line in function' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5 Write-Host $null git checkout $args @@ -147,7 +147,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands semicolon delimited functions' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5; git checkout $args; Write-Host $null; } $result = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' @@ -155,7 +155,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands mixed semicolon delimited and newline functions' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5; Write-Host $null git checkout $args; Write-Host $null; } @@ -164,7 +164,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands mixed semicolon delimited and newline multiline functions' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5; Write-Host $null git ` checkout ` @@ -175,7 +175,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands simultaneously semicolon delimited and newline functions' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5; Write-Host $null; git checkout $args; @@ -186,7 +186,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands multiline function' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git ` checkout ` $args @@ -196,7 +196,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands multiline function that terminates with semicolon on new line' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git ` checkout ` $args ` @@ -207,7 +207,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands multiline function with short parameter' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git ` checkout ` -b ` @@ -218,7 +218,7 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Expands multiline function with long parameter' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git ` checkout ` --detach ` @@ -229,21 +229,21 @@ Describe 'Proxy Function Expansion Tests' { $result | Should -Be (& $module Expand-GitProxyFunction 'igf ' ) } It 'Does not expand a single line with piped function prefix' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { "master" | git checkout --detach $args } & $module Expand-GitProxyFunction 'Invoke-GitFunction ' | Should -Be 'Invoke-GitFunction ' & $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf ' } It 'Does not expand function if $args is not present' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { git checkout } & $module Expand-GitProxyFunction 'Invoke-GitFunction ' | Should -Be 'Invoke-GitFunction ' & $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf ' } It 'Does not expand function if $args is not attached to the git function' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5 git checkout Write-Host $args @@ -252,7 +252,7 @@ Describe 'Proxy Function Expansion Tests' { & $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf ' } It 'Does not expand multiline function if $args is not attached to the git function' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5 git ` checkout @@ -262,7 +262,7 @@ Describe 'Proxy Function Expansion Tests' { & $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf ' } It 'Does not expand multiline function backtick newlines are not preceded with whitespace' { - function script:Invoke-GitFunction { + function global:Invoke-GitFunction { $a = 5 git` checkout` @@ -278,7 +278,7 @@ Describe 'Proxy Function Expansion Tests' { if(Test-Path -Path Function:\Invoke-GitFunction) { Rename-Item -Path Function:\Invoke-GitFunction -NewName Invoke-GitFunctionBackup } - function script:Invoke-GitFunction { git checkout $args } + function global:Invoke-GitFunction { git checkout $args } } AfterEach { if(Test-Path -Path Function:\Invoke-GitFunction) { @@ -320,14 +320,14 @@ Describe 'Proxy Function Expansion Tests' { } } It 'Tab completes without subcommands' { - function script:Invoke-GitFunction { git whatever $args } + function global:Invoke-GitFunction { git whatever $args } $functionText = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' $result = & $module GitTabExpansionInternal $functionText $result | Should -Be @() } It 'Tab completes bisect subcommands' { - function script:Invoke-GitFunction { git bisect $args } + function global:Invoke-GitFunction { git bisect $args } $functionText = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' $result = & $module GitTabExpansionInternal $functionText @@ -342,7 +342,7 @@ Describe 'Proxy Function Expansion Tests' { $result2 -contains 'skip' | Should -Be $true } It 'Tab completes remote subcommands' { - function script:Invoke-GitFunction { git remote $args } + function global:Invoke-GitFunction { git remote $args } $functionText = & $module Expand-GitProxyFunction 'Invoke-GitFunction ' $result = & $module GitTabExpansionInternal $functionText