mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Used method from PR comments to find powershell
replaced dir with get-childitem used appropriate path when importing pester verified failure count was 0 split test case verification into individual it's so we get all the info.
This commit is contained in:
@@ -16,53 +16,73 @@ Describe 'SDK Send Greeting Sample Tests' -Tag CI {
|
||||
$testResultPath = Join-Path $TestDrive 'sendgreetingresults.xml'
|
||||
$sampleCopy = Join-Path $TestDrive 'sendgreeting'
|
||||
$fullSampleCopyPath = Join-Path $sampleCopy 'cmdlet-example'
|
||||
$powershell = (Get-Process -id $PID).MainModule.FileName
|
||||
if(!(Test-Path $sampleCopy))
|
||||
{
|
||||
New-Item -ItemType Directory -Path $sampleCopy
|
||||
}
|
||||
|
||||
Copy-Item -Recurse -Path $docLocation -Destination $sampleCopy -Force
|
||||
dir -Recurse $sampleCopy | %{ Write-Verbose "sc: $($_.FullName)"}
|
||||
Get-ChildItem -Recurse $sampleCopy | %{ Write-Verbose "sc: $($_.FullName)"}
|
||||
|
||||
$pesterCommand = "Invoke-Pester $sampleCopy -PassThru"
|
||||
if($global:__PesterTags)
|
||||
{
|
||||
$pesterCommand += " -Tag $(@($global:__PesterTags) -join ',')"
|
||||
}
|
||||
$pesterCommand = "Invoke-Pester $sampleCopy -PassThru"
|
||||
if($global:__PesterTags)
|
||||
{
|
||||
$pesterCommand += " -Tag $(@($global:__PesterTags) -join ',')"
|
||||
}
|
||||
|
||||
if($global:__PesterExcludeTags)
|
||||
{
|
||||
$pesterCommand += " -ExcludeTag $(@($global:__PesterExcludeTags) -join ',')"
|
||||
}
|
||||
if($global:__PesterExcludeTags)
|
||||
{
|
||||
$pesterCommand += " -ExcludeTag $(@($global:__PesterExcludeTags) -join ',')"
|
||||
}
|
||||
|
||||
$importPesterCommand = 'Import-module Pester'
|
||||
if($isCore)
|
||||
{
|
||||
$importPesterCommand = "Import-Module $(Join-Path -path $PSHOME -child '/Modules/Pester')"
|
||||
}
|
||||
|
||||
$command = @"
|
||||
Push-Location -Path $fullSampleCopyPath
|
||||
Import-module $(Join-path $env:PSModulePath pester)
|
||||
$importPesterCommand
|
||||
$pesterCommand | Export-Clixml -Path $testResultPath
|
||||
"@
|
||||
|
||||
Write-Verbose -Message "command: '$command'" -Verbose
|
||||
Write-Verbose -Message "command: '$command'"
|
||||
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
|
||||
$encodedCommand = [Convert]::ToBase64String($bytes)
|
||||
&"$PSHOME/powershell" -encodedCommand $encodedCommand
|
||||
&$powershell -encodedCommand $encodedCommand
|
||||
|
||||
it "Should have test results file" {
|
||||
$testResultPath | should exist
|
||||
$script:results = Import-Clixml $testResultPath
|
||||
}
|
||||
#$host.EnterNestedPrompt();
|
||||
|
||||
it "Should have test results" {
|
||||
$script:results | should not be BeNullOrEmpty
|
||||
$script:results.TotalCount | should not BeNullOrEmpty
|
||||
$script:results.TestResult.Count | should not BeNullOrEmpty
|
||||
}
|
||||
|
||||
it "Should have no failures" {
|
||||
$script:results.FailedCount | should be 0
|
||||
}
|
||||
|
||||
foreach($testResult in $script:results.TestResult){
|
||||
it "Test $($testResult.Name) should not fail" {
|
||||
$testResult.FailureMessage + $testResult.StackTrace | should BeNullOrEmpty
|
||||
$testResult.ErrorRecord | should BeNullOrEmpty
|
||||
Write-Verbose "Result: $($testResult.Result)"
|
||||
$testResult.Result | should not be Failed
|
||||
Context "Test $($testResult.Name)" {
|
||||
it "should have no failure message" {
|
||||
$testResult.FailureMessage | should BeNullOrEmpty
|
||||
}
|
||||
it "should have no stack trace" {
|
||||
$testResult.StackTrace | should BeNullOrEmpty
|
||||
}
|
||||
it "should have no error record" {
|
||||
$testResult.ErrorRecord | should BeNullOrEmpty
|
||||
}
|
||||
it "should have not failed" {
|
||||
Write-Verbose "Result: $($testResult.Result)"
|
||||
$testResult.Result | should not be Failed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user