Skip to content

Commit cfa5888

Browse files
committed
tests: Print variables on failure of assert tasks
Fixes #852
1 parent bd94c57 commit cfa5888

File tree

93 files changed

+198
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+198
-3
lines changed

tests/ansible/integration/action/copy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
- stat.results[1].stat.checksum == "62951f943c41cdd326e5ce2b53a779e7916a820d"
6464
- stat.results[2].stat.checksum == "b26dd6444595e2bdb342aa0a91721b57478b5029"
6565
- stat.results[3].stat.checksum == "d675f47e467eae19e49032a2cc39118e12a6ee72"
66+
fail_msg: stat={{stat}}
6667

6768
- file:
6869
state: absent

tests/ansible/integration/action/fixup_perms2__copy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- assert:
2222
that:
2323
- out.stat.mode in ("0644", "0664")
24+
fail_msg: out={{out}}
2425

2526
#
2627
# copy module (explicit mode).
@@ -37,6 +38,7 @@
3738
- assert:
3839
that:
3940
- out.stat.mode == "0400"
41+
fail_msg: out={{out}}
4042

4143
#
4244
# copy module (existing disk files, no mode).
@@ -63,6 +65,7 @@
6365
- assert:
6466
that:
6567
- out.stat.mode in ("0644", "0664")
68+
fail_msg: out={{out}}
6669

6770
#
6871
# copy module (existing disk files, preserve mode).
@@ -79,6 +82,7 @@
7982
- assert:
8083
that:
8184
- out.stat.mode == "1462"
85+
fail_msg: out={{out}}
8286

8387
#
8488
# copy module (existing disk files, explicit mode).
@@ -96,6 +100,7 @@
96100
- assert:
97101
that:
98102
- out.stat.mode == "1461"
103+
fail_msg: out={{out}}
99104

100105
- file:
101106
state: absent

tests/ansible/integration/action/low_level_execute_command.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- 'raw.rc == 0'
1717
- 'raw.stdout_lines[-1]|to_text == "2"'
1818
- 'raw.stdout[-1]|to_text == "2"'
19+
fail_msg: raw={{raw}}
1920

2021
- name: Run raw module with sudo
2122
become: true
@@ -39,3 +40,4 @@
3940
["root\r\n"],
4041
["root"],
4142
)
43+
fail_msg: raw={{raw}}

tests/ansible/integration/action/make_tmp_path.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@
4444
assert:
4545
that:
4646
- good_temp_path == good_temp_path2
47+
fail_msg: good_temp_path={{good_temp_path}} good_temp_path2={{good_temp_path2}}
4748

4849
- name: "Verify different subdir for both tasks"
4950
assert:
5051
that:
5152
- tmp_path.path != tmp_path2.path
53+
fail_msg: tmp_path={{tmp_path}} tmp_path2={{tmp_path2}}
5254

5355
#
5456
# Verify subdirectory removal.
@@ -69,6 +71,7 @@
6971
that:
7072
- not stat1.stat.exists
7173
- not stat2.stat.exists
74+
fail_msg: stat1={{stat1}} stat2={{stat2}}
7275

7376
#
7477
# Verify good directory persistence.
@@ -83,6 +86,7 @@
8386
assert:
8487
that:
8588
- stat.stat.exists
89+
fail_msg: stat={{stat}}
8690

8791
#
8892
# Write some junk into the temp path.
@@ -105,6 +109,7 @@
105109
- assert:
106110
that:
107111
- not out.stat.exists
112+
fail_msg: out={{out}}
108113

109114
#
110115
# root
@@ -123,6 +128,7 @@
123128
that:
124129
- tmp_path2.path != tmp_path_root.path
125130
- tmp_path2.path|dirname != tmp_path_root.path|dirname
131+
fail_msg: tmp_path_root={{tmp_path_root}} tmp_path2={{tmp_path2}}
126132

127133
#
128134
# readonly homedir
@@ -153,3 +159,4 @@
153159
that:
154160
- out.module_path.startswith(good_temp_path2)
155161
- out.module_tmpdir.startswith(good_temp_path2)
162+
fail_msg: out={{out}}

tests/ansible/integration/action/remote_expand_user.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
register: out
2828
- assert:
2929
that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo'
30+
fail_msg: out={{out}}
3031

3132
- name: "Expand ~/foo with become active. ~ is become_user's home."
3233
action_passthrough:
@@ -49,6 +50,7 @@
4950
register: out
5051
- assert:
5152
that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo'
53+
fail_msg: out={{out}}
5254

5355
- name: "Expanding $HOME/foo has no effect."
5456
action_passthrough:
@@ -59,6 +61,7 @@
5961
register: out
6062
- assert:
6163
that: out.result == '$HOME/foo'
64+
fail_msg: out={{out}}
6265

6366
# ------------------------
6467

@@ -71,6 +74,7 @@
7174
register: out
7275
- assert:
7376
that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo'
77+
fail_msg: out={{out}}
7478

7579
- name: "sudoable; Expand ~/foo with become active. ~ is become_user's home."
7680
action_passthrough:
@@ -94,6 +98,7 @@
9498
register: out
9599
- assert:
96100
that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo'
101+
fail_msg: out={{out}}
97102

98103
- name: "sudoable; Expanding $HOME/foo has no effect."
99104
action_passthrough:
@@ -104,3 +109,4 @@
104109
register: out
105110
- assert:
106111
that: out.result == '$HOME/foo'
112+
fail_msg: out={{out}}

tests/ansible/integration/action/remote_file_exists.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
- assert:
1717
that: out.result == False
18+
fail_msg: out={{out}}
1819

1920
# ---
2021

@@ -29,6 +30,7 @@
2930

3031
- assert:
3132
that: out.result == True
33+
fail_msg: out={{out}}
3234

3335
- file:
3436
path: /tmp/does-exist

tests/ansible/integration/action/remove_tmp_path.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- assert:
2424
that:
2525
- not out2.stat.exists
26+
fail_msg: out={{out}}
2627

2728
- stat:
2829
path: "{{out.src|dirname}}"
@@ -31,6 +32,7 @@
3132
- assert:
3233
that:
3334
- not out2.stat.exists
35+
fail_msg: out={{out}}
3436

3537
- file:
3638
path: /tmp/remove_tmp_path_test

tests/ansible/integration/action/synchronize.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
- assert:
6262
that: outout == "item!"
63+
fail_msg: outout={{outout}}
6364
when: False
6465

6566
# TODO: https://github.com/dw/mitogen/issues/692

tests/ansible/integration/action/transfer_data.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- assert:
2525
that: |
2626
out.content|b64decode == '{"I am JSON": true}'
27+
fail_msg: out={{out}}
2728

2829

2930
# Ensure it handles strings.
@@ -40,6 +41,7 @@
4041
- assert:
4142
that:
4243
out.content|b64decode == 'I am text.'
44+
fail_msg: out={{out}}
4345

4446
- file:
4547
path: /tmp/transfer-data

tests/ansible/integration/async/multiple_items_loop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@
3434
- out.results[1].stdout == 'hi-from-job-2'
3535
- out.results[1].rc == 0
3636
- out.results[1].delta > '0:00:05'
37+
fail_msg: out={{out}}

0 commit comments

Comments
 (0)