summaryrefslogtreecommitdiff
path: root/test/integration/targets/filter_core
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2020-07-10 18:49:57 -0400
committerGitHub <noreply@github.com>2020-07-10 18:49:57 -0400
commitcf89ca8a03a8a84302ad27cb1fc7aa9120b743ca (patch)
tree5664afe655648eb955ef42cecb15b9df5909247d /test/integration/targets/filter_core
parent24dcaf8974f27bb16577975cf46a36334f37784b (diff)
downloadansible-cf89ca8a03a8a84302ad27cb1fc7aa9120b743ca.tar.gz
Make filter type errors 'loop friendly' (#70417)
- ensure we preserve the typeerror part of the exception so loop defereed error handling can postpone those caused by undefined variables until the when check is done. - fix tests to comply with the 'new normal' - human_to_bytes and others can issue TypeError not only on 'non string' but also bad string that is not convertable. Co-authored-by: Sloane Hertel <shertel@redhat.com> Co-authored-by: Sloane Hertel <shertel@redhat.com>
Diffstat (limited to 'test/integration/targets/filter_core')
-rw-r--r--test/integration/targets/filter_core/handle_undefined_type_errors.yml29
-rwxr-xr-xtest/integration/targets/filter_core/runme.sh1
-rw-r--r--test/integration/targets/filter_core/tasks/main.yml2
3 files changed, 31 insertions, 1 deletions
diff --git a/test/integration/targets/filter_core/handle_undefined_type_errors.yml b/test/integration/targets/filter_core/handle_undefined_type_errors.yml
new file mode 100644
index 0000000000..70628809a4
--- /dev/null
+++ b/test/integration/targets/filter_core/handle_undefined_type_errors.yml
@@ -0,0 +1,29 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - debug: msg={{item}}
+ with_dict: '{{myundef}}'
+ when:
+ - myundef is defined
+ register: shouldskip
+
+ - name: check if skipped
+ assert:
+ that:
+ - shouldskip is skipped
+
+ - debug: msg={{item}}
+ loop: '{{myundef|dict2items}}'
+ when:
+ - myundef is defined
+
+ - debug: msg={{item}}
+ with_dict: '{{myundef}}'
+ register: notskipped
+ ignore_errors: true
+
+ - name: check it failed
+ assert:
+ that:
+ - notskipped is not skipped
+ - notskipped is failed
diff --git a/test/integration/targets/filter_core/runme.sh b/test/integration/targets/filter_core/runme.sh
index ac4361f3a4..c055603b0f 100755
--- a/test/integration/targets/filter_core/runme.sh
+++ b/test/integration/targets/filter_core/runme.sh
@@ -3,3 +3,4 @@
set -eux
ANSIBLE_ROLES_PATH=../ ansible-playbook runme.yml "$@"
+ANSIBLE_ROLES_PATH=../ ansible-playbook handle_undefined_type_errors.yml "$@"
diff --git a/test/integration/targets/filter_core/tasks/main.yml b/test/integration/targets/filter_core/tasks/main.yml
index 4f7517004b..3b5cba39ee 100644
--- a/test/integration/targets/filter_core/tasks/main.yml
+++ b/test/integration/targets/filter_core/tasks/main.yml
@@ -528,7 +528,7 @@
- subelements_1 is failed
- 'subelements_1.msg == "obj must be a list of dicts or a nested dict"'
- subelements_2 is failed
- - 'subelements_2.msg == "subelements must be a list or a string"'
+ - '"subelements must be a list or a string" in subelements_2.msg'
- 'subelements_demo|subelements("does not compute", skip_missing=True) == []'
- subelements_3 is failed
- '"could not find" in subelements_3.msg'