diff options
author | Jordan Borean <jborean93@gmail.com> | 2021-10-08 06:30:30 +1000 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2021-10-07 14:19:33 -0700 |
commit | 651e69064da49bf970e36df75d1cbaa1df100cc7 (patch) | |
tree | d4936cbbedfb020136a8e1bfe02dba2eff477420 | |
parent | 7fa59ed6746775d7c0fef62d6900f6dfd564ee75 (diff) | |
download | ansible-651e69064da49bf970e36df75d1cbaa1df100cc7.tar.gz |
ansible-test pslint - fix warning with nested objects (#75792)
* ansible-test pslint - fix warning with nested objects
(cherry picked from commit 7e19957afa02245f9ff791c7b6ad17700db4385b)
-rw-r--r-- | changelogs/fragments/pslint-sanity-warning.yml | 2 | ||||
-rwxr-xr-x | test/lib/ansible_test/_data/sanity/pslint/pslint.ps1 | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/changelogs/fragments/pslint-sanity-warning.yml b/changelogs/fragments/pslint-sanity-warning.yml new file mode 100644 index 0000000000..8c16b69669 --- /dev/null +++ b/changelogs/fragments/pslint-sanity-warning.yml @@ -0,0 +1,2 @@ +bugfixes: +- ansible-test pslint - Fix error when encountering validation results that are highly nested - https://github.com/ansible/ansible/issues/74151 diff --git a/test/lib/ansible_test/_data/sanity/pslint/pslint.ps1 b/test/lib/ansible_test/_data/sanity/pslint/pslint.ps1 index 1ef2743acd..21007db647 100755 --- a/test/lib/ansible_test/_data/sanity/pslint/pslint.ps1 +++ b/test/lib/ansible_test/_data/sanity/pslint/pslint.ps1 @@ -2,7 +2,6 @@ #Requires -Version 6 #Requires -Modules PSScriptAnalyzer, PSSA-PSCustomUseLiteralPath -Set-StrictMode -Version 2.0 $ErrorActionPreference = "Stop" $WarningPreference = "Stop" @@ -21,14 +20,12 @@ $PSSAParams = @{ Setting = (Join-Path -Path $PSScriptRoot -ChildPath "settings.psd1") } -$Results = @() - -ForEach ($Path in $Args) { +$Results = @(ForEach ($Path in $Args) { $Retries = 3 Do { Try { - $Results += Invoke-ScriptAnalyzer -Path $Path @PSSAParams 3> $null + Invoke-ScriptAnalyzer -Path $Path @PSSAParams 3> $null $Retries = 0 } Catch { @@ -38,6 +35,8 @@ ForEach ($Path in $Args) { } } Until ($Retries -le 0) -} +}) -ConvertTo-Json -InputObject $Results +# Since pwsh 7.1 results that exceed depth will produce a warning which fails the process. +# Ignore warnings only for this step. +ConvertTo-Json -InputObject $Results -Depth 1 -WarningAction SilentlyContinue |