summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2023-01-11 08:05:50 +1000
committerMatt Clay <matt@mystile.com>2023-01-11 10:13:41 -0800
commit865b457a6e7c5d14ceda53b7248603d3d44c7c4f (patch)
tree94b098bef48703be95ae7d37491201671777fba3
parent489b83fa3084c6194baa2974ba45526cb86970f9 (diff)
downloadansible-865b457a6e7c5d14ceda53b7248603d3d44c7c4f.tar.gz
ansible-test - fix ps argspec check inside cmdlet (#79699)
* ansible-test - fix ps argspec check inside cmdlet * Added error condition test * Fix sanity problem (cherry picked from commit ee33be9484b2240aa7b6b3bfdb30b452b6048e85)
-rw-r--r--changelogs/fragments/validate-module-ps-cmdlet.yml2
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/ps_argspec.ps114
2 files changed, 13 insertions, 3 deletions
diff --git a/changelogs/fragments/validate-module-ps-cmdlet.yml b/changelogs/fragments/validate-module-ps-cmdlet.yml
new file mode 100644
index 0000000000..5ae24bc569
--- /dev/null
+++ b/changelogs/fragments/validate-module-ps-cmdlet.yml
@@ -0,0 +1,2 @@
+bugfixes:
+- ansible-test - Fix validate-modules error when retrieving PowerShell argspec when retrieved inside a Cmdlet
diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/ps_argspec.ps1 b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/ps_argspec.ps1
index fb4a61740a..adad692a7d 100644
--- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/ps_argspec.ps1
+++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/ps_argspec.ps1
@@ -97,13 +97,21 @@ Add-CSharpType -References @(Get-Content -LiteralPath $manifest.ansible_basic -R
$powershell.AddScript($module_code) > $null
$powershell.Invoke() > $null
+$arg_spec = $powershell.Runspace.SessionStateProxy.GetVariable('ansibleTestArgSpec')
+
+if (-not $arg_spec) {
+ $err = $powershell.Streams.Error
+ if ($err) {
+ $err
+ }
+ else {
+ "Unknown error trying to get PowerShell arg spec"
+ }
-if ($powershell.HadErrors) {
- $powershell.Streams.Error
exit 1
}
-$arg_spec = $powershell.Runspace.SessionStateProxy.GetVariable('ansibleTestArgSpec')
+
Resolve-CircularReference -Hash $arg_spec
ConvertTo-Json -InputObject $arg_spec -Compress -Depth 99