Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_pester path behavior changed to match Pester behavior #56677

Open
wants to merge 5 commits into
base: devel
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

get proper path

  • Loading branch information...
clcaldwell committed May 20, 2019
commit 6365fc1ec277967c9e68ddbabf2bff24b095a130
@@ -28,6 +28,15 @@ Catch {
$module.FailJson("Value '$version' for parameter 'version' is not a valid version format")
}

# Make sure path is a real path
Try {
$path = (Get-item -LiteralPath $path).FullName
Test-Path $path
}
Catch {
$module.FailJson("Cannot find file or directory: '$path' as it does not exist")
}

# Import Pester module if available
$Pester = 'Pester'

@@ -48,11 +57,6 @@ If ((-not (Get-Module -Name $Pester -ErrorAction SilentlyContinue | Where-Object
$module.FailJson("$Pester version is not greater or equal to $version")
}

# Testing if test file or directory exist
If (-not (Test-Path -LiteralPath $path)) {
$module.FailJson("Cannot find file or directory: '$path' as it does not exist")
}

#Prepare Invoke-Pester parameters depending of the Pester's version.
#Invoke-Pester output deactivation behave differently depending on the Pester's version
If ($module.result.pester_version -ge "4.0.0") {
@@ -67,35 +71,9 @@ If ($module.result.pester_version -ge "4.0.0") {
}
}

# Run Pester tests
if (Test-Path -LiteralPath $path -PathType Leaf) {
if ($check_mode) {
$module.result.output = "Run pester test in the file: $path"
} else {
try {
$module.result.output = Invoke-Pester $path @Parameters
} catch {
$module.FailJson($_.Exception)
}
}
} else {
# Run Pester tests against all the .ps1 file in the local folder
$files = Get-ChildItem -Path $path | Where-Object {$_.extension -eq ".ps1"}

if ($check_mode) {
$module.result.output = "Run pester test(s) who are in the folder: $path"
} else {
try {
$module.result.output = Invoke-Pester $files.FullName @Parameters
} catch {
$module.FailJson($_.Exception)
}
}
}

# Run Pester tests
if ($check_mode) {
$module.result.output = "Run pester tests: $path"
$module.result.output = "Run Pester test(s): $path"
} else {
try {
$module.result.output = Invoke-Pester $path @Parameters
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.