Skip to content

Commit b961505

Browse files
committed
Add tab completion test for PowerShell
Using Pester and AppVeyor.
1 parent b697df1 commit b961505

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
$result.Count | Should Be 23
13+
$result[00].CompletionText | Should Be 'completions'
14+
$result[01].CompletionText | Should Be 'component'
15+
$result[02].CompletionText | Should Be 'default'
16+
$result[03].CompletionText | Should Be 'doc'
17+
$result[04].CompletionText | Should Be '-h'
18+
$result[05].CompletionText | Should Be 'help'
19+
$result[06].CompletionText | Should Be '--help'
20+
$result[07].CompletionText | Should Be 'install'
21+
$result[08].CompletionText | Should Be 'override'
22+
$result[09].CompletionText | Should Be 'run'
23+
$result[10].CompletionText | Should Be 'self'
24+
$result[11].CompletionText | Should Be 'set'
25+
$result[12].CompletionText | Should Be 'show'
26+
$result[13].CompletionText | Should Be 'target'
27+
$result[14].CompletionText | Should Be 'telemetry'
28+
$result[15].CompletionText | Should Be 'toolchain'
29+
$result[16].CompletionText | Should Be 'uninstall'
30+
$result[17].CompletionText | Should Be 'update'
31+
$result[18].CompletionText | Should Be '-V'
32+
$result[19].CompletionText | Should Be '-v'
33+
$result[20].CompletionText | Should Be '--verbose'
34+
$result[21].CompletionText | Should Be '--version'
35+
$result[22].CompletionText | Should Be 'which'
36+
}

0 commit comments

Comments
 (0)