Skip to content

Commit 7ff14e4

Browse files
authored
Merge pull request #1629 from matt9ucci/pester4cmpl
Add tab completion test for PowerShell
2 parents 7701ec1 + a93aab1 commit 7ff14e4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

appveyor.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ install:
4747
} else {
4848
Write-Host "MSYS2 not required" -ForegroundColor Green
4949
}
50+
- pwsh: |
51+
Install-Module Pester -Force
5052
5153
# Install rust, x86_64-pc-windows-msvc host
5254
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
@@ -81,6 +83,9 @@ test_script:
8183
- if defined BUILD_MSI pushd src\rustup-win-installer && cargo build --release --target %TARGET% & popd
8284
- if defined BUILD_MSI pushd src\rustup-win-installer\msi && powershell .\build.ps1 -Target %TARGET% & popd
8385
- cargo fmt --all -- --check
86+
- pwsh: |
87+
$pesterOutputFile = 'src\rustup-win-installer\msi\PesterTestsResults.xml'
88+
Invoke-Pester -OutputFormat NUnitXml -OutputFile $pesterOutputFile
8489
8590
notifications:
8691
- provider: Webhook
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if (Get-Command -Name rustup -ErrorAction Stop) {
2+
# Enable rustup tab completion
3+
rustup completions powershell | Out-String | Invoke-Expression
4+
}
5+
6+
function Get-Result([string]$Text, [int]$CursorPosition = $Text.Length, [hashtable]$Options) {
7+
[System.Management.Automation.CommandCompletion]::CompleteInput($Text, $CursorPosition, $Options).CompletionMatches
8+
}
9+
10+
Describe 'rustup flags and subcommands' {
11+
$result = Get-Result 'rustup '
12+
13+
# Keep it simple because over-specify testing might be risky
14+
$result.Count | Should -BeGreaterThan 10
15+
$result.CompletionText | Should -Contain 'completions'
16+
$result.CompletionText | Should -Contain 'install'
17+
$result.CompletionText | Should -Contain 'uninstall'
18+
$result.CompletionText | Should -Contain 'update'
19+
$result.CompletionText | Should -Contain '--help'
20+
$result.CompletionText | Should -Contain '--verbose'
21+
}

0 commit comments

Comments
 (0)