mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
win_exec: refactor PS exec runner (#45334)
* win_exec: refactor PS exec runner * more changes for PSCore compatibility * made some changes based on the recent review * split up module exec scripts for smaller payload * removed C# module support to focus on just error msg improvement * cleaned up c# test classifier code
This commit is contained in:
committed by
Matt Davis
parent
aa2f3edb49
commit
e972287c35
@@ -1,4 +1,115 @@
|
||||
---
|
||||
- name: test normal module execution
|
||||
test_fail:
|
||||
register: normal
|
||||
|
||||
- name: assert test normal module execution
|
||||
assert:
|
||||
that:
|
||||
- not normal is failed
|
||||
|
||||
- name: test fail module execution
|
||||
test_fail:
|
||||
data: fail
|
||||
register: fail_module
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert test fail module execution
|
||||
assert:
|
||||
that:
|
||||
- fail_module is failed
|
||||
- fail_module.msg == "fail message"
|
||||
- not fail_module.exception is defined
|
||||
|
||||
- name: test module with exception thrown
|
||||
test_fail:
|
||||
data: throw
|
||||
register: throw_module
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert test module with exception thrown
|
||||
assert:
|
||||
that:
|
||||
- throw_module is failed
|
||||
- 'throw_module.msg == "Unhandled exception while executing module: module is thrown"'
|
||||
- '"throw [ArgumentException]\"module is thrown\"" in throw_module.exception'
|
||||
|
||||
- name: test module with error msg
|
||||
test_fail:
|
||||
data: error
|
||||
register: error_module
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert test module with error msg
|
||||
assert:
|
||||
that:
|
||||
- error_module is failed
|
||||
- 'error_module.msg == "Unhandled exception while executing module: error"'
|
||||
- '"Write-Error -Message $data" in error_module.exception'
|
||||
|
||||
- name: test module with cmdlet error
|
||||
test_fail:
|
||||
data: cmdlet_error
|
||||
register: cmdlet_error
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert test module with cmdlet error
|
||||
assert:
|
||||
that:
|
||||
- cmdlet_error is failed
|
||||
- 'cmdlet_error.msg == "Unhandled exception while executing module: Cannot find drive. A drive with the name ''fake'' does not exist."'
|
||||
- '"Get-Item -Path \"fake:\\path\"" in cmdlet_error.exception'
|
||||
|
||||
- name: test module with .NET exception
|
||||
test_fail:
|
||||
data: dotnet_exception
|
||||
register: dotnet_exception
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert test module with .NET exception
|
||||
assert:
|
||||
that:
|
||||
- dotnet_exception is failed
|
||||
- 'dotnet_exception.msg == "Unhandled exception while executing module: Exception calling \"GetFullPath\" with \"1\" argument(s): \"The path is not of a legal form.\""'
|
||||
- '"[System.IO.Path]::GetFullPath($null)" in dotnet_exception.exception'
|
||||
|
||||
- name: test module with function exception
|
||||
test_fail:
|
||||
data: function_throw
|
||||
register: function_exception
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert test module with function exception
|
||||
assert:
|
||||
that:
|
||||
- function_exception is failed
|
||||
- 'function_exception.msg == "Unhandled exception while executing module: exception in function"'
|
||||
- '"throw \"exception in function\"" in function_exception.exception'
|
||||
- '"at Test-ThrowException, <No file>: line" in function_exception.exception'
|
||||
|
||||
- name: test module with fail process but Exit-Json
|
||||
test_fail:
|
||||
data: proc_exit_fine
|
||||
register: proc_exit_fine
|
||||
|
||||
- name: assert test module with fail process but Exit-Json
|
||||
assert:
|
||||
that:
|
||||
- not proc_exit_fine is failed
|
||||
|
||||
- name: test module with fail process but Fail-Json
|
||||
test_fail:
|
||||
data: proc_exit_fail
|
||||
register: proc_exit_fail
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert test module with fail process but Fail-Json
|
||||
assert:
|
||||
that:
|
||||
- proc_exit_fail is failed
|
||||
- proc_exit_fail.msg == "proc_exit_fail"
|
||||
- not proc_exit_fail.exception is defined
|
||||
|
||||
- name: test out invalid options
|
||||
test_invalid_requires:
|
||||
register: invalid_options
|
||||
@@ -127,3 +238,13 @@
|
||||
args:
|
||||
executable: cmd.exe
|
||||
when: become_test_username in profile_dir_out.stdout_lines[0]
|
||||
|
||||
- name: test common functions in exec
|
||||
test_common_functions:
|
||||
register: common_functions_res
|
||||
|
||||
- name: assert test common functions in exec
|
||||
assert:
|
||||
that:
|
||||
- not common_functions_res is failed
|
||||
- common_functions_res.msg == "good"
|
||||
|
||||
Reference in New Issue
Block a user