mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make tests more cross platform. (#17154)
This commit is contained in:
parent
fa395bee7b
commit
04bd6a3619
4 changed files with 19 additions and 22 deletions
|
@ -33,6 +33,14 @@
|
||||||
- name: prep our test script
|
- name: prep our test script
|
||||||
copy: src=remove_afile.sh dest="{{ output_dir_test }}" mode=0755
|
copy: src=remove_afile.sh dest="{{ output_dir_test }}" mode=0755
|
||||||
|
|
||||||
|
- name: locate bash
|
||||||
|
shell: which bash
|
||||||
|
register: bash
|
||||||
|
|
||||||
|
- name: locate sha1sum/shasum
|
||||||
|
shell: which sha1sum || which shasum
|
||||||
|
register: sha1sum
|
||||||
|
|
||||||
##
|
##
|
||||||
## command
|
## command
|
||||||
##
|
##
|
||||||
|
@ -53,7 +61,7 @@
|
||||||
# FIXME doesn't have the expected stdout.
|
# FIXME doesn't have the expected stdout.
|
||||||
|
|
||||||
#- name: execute the test.sh script with executable via command
|
#- name: execute the test.sh script with executable via command
|
||||||
# command: "{{output_dir_test | expanduser}}/test.sh executable=/bin/bash"
|
# command: "{{output_dir_test | expanduser}}/test.sh executable={{ bash.stdout }}"
|
||||||
# register: command_result1
|
# register: command_result1
|
||||||
#
|
#
|
||||||
#- name: assert that the script executed correctly with command
|
#- name: assert that the script executed correctly with command
|
||||||
|
@ -133,7 +141,7 @@
|
||||||
# FIXME doesn't pass the expected stdout
|
# FIXME doesn't pass the expected stdout
|
||||||
|
|
||||||
#- name: execute the test.sh script
|
#- name: execute the test.sh script
|
||||||
# shell: "{{output_dir_test | expanduser}}/test.sh executable=/bin/bash"
|
# shell: "{{output_dir_test | expanduser}}/test.sh executable={{ bash.stdout }}"
|
||||||
# register: shell_result1
|
# register: shell_result1
|
||||||
#
|
#
|
||||||
#- name: assert that the shell executed correctly
|
#- name: assert that the shell executed correctly
|
||||||
|
@ -174,13 +182,13 @@
|
||||||
|
|
||||||
- name: execute a shell command using a literal multiline block
|
- name: execute a shell command using a literal multiline block
|
||||||
args:
|
args:
|
||||||
executable: /bin/bash
|
executable: "{{ bash.stdout }}"
|
||||||
shell: |
|
shell: |
|
||||||
echo this is a \
|
echo this is a \
|
||||||
"multiline echo" \
|
"multiline echo" \
|
||||||
"with a new line
|
"with a new line
|
||||||
in quotes" \
|
in quotes" \
|
||||||
| sha1sum \
|
| {{ sha1sum.stdout }} \
|
||||||
| tr -s ' ' \
|
| tr -s ' ' \
|
||||||
| cut -f1 -d ' '
|
| cut -f1 -d ' '
|
||||||
echo "this is a second line"
|
echo "this is a second line"
|
||||||
|
@ -196,7 +204,7 @@
|
||||||
|
|
||||||
- name: execute a shell command using a literal multiline block with arguments in it
|
- name: execute a shell command using a literal multiline block with arguments in it
|
||||||
shell: |
|
shell: |
|
||||||
executable=/bin/bash
|
executable="{{ bash.stdout }}"
|
||||||
creates={{output_dir_test | expanduser}}/afile.txt
|
creates={{output_dir_test | expanduser}}/afile.txt
|
||||||
echo "test"
|
echo "test"
|
||||||
register: shell_result6
|
register: shell_result6
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
- name: record the output directory
|
- name: record the output directory
|
||||||
set_fact: output_file={{output_dir}}/foo.txt
|
set_fact: output_file={{output_dir}}/foo.txt
|
||||||
|
|
||||||
|
- name: locate sha1sum/shasum
|
||||||
|
shell: which sha1sum || which shasum
|
||||||
|
register: sha1sum
|
||||||
|
|
||||||
- name: initiate a basic copy, and also test the mode
|
- name: initiate a basic copy, and also test the mode
|
||||||
copy: src=foo.txt dest={{output_file}} mode=0444
|
copy: src=foo.txt dest={{output_file}} mode=0444
|
||||||
register: copy_result
|
register: copy_result
|
||||||
|
@ -247,7 +251,7 @@
|
||||||
- stat_link_result.stat.islnk
|
- stat_link_result.stat.islnk
|
||||||
|
|
||||||
- name: get the checksum of the link target
|
- name: get the checksum of the link target
|
||||||
shell: sha1sum {{output_dir}}/follow_test | cut -f1 -sd ' '
|
shell: "{{ sha1sum.stdout }} {{output_dir}}/follow_test | cut -f1 -sd ' '"
|
||||||
register: target_file_result
|
register: target_file_result
|
||||||
|
|
||||||
- name: assert that the link target was updated
|
- name: assert that the link target was updated
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
result.cmd == "echo foo=bar foo=bar"
|
result.cmd == "echo foo=bar foo=bar"
|
||||||
|
|
||||||
- name: raw duplicates, noop
|
- name: raw duplicates, noop
|
||||||
raw: /bin/true foo=bar foo=bar
|
raw: env true foo=bar foo=bar
|
||||||
|
|
||||||
- name: multi-line inline shell commands (should use script module but hey) are a thing
|
- name: multi-line inline shell commands (should use script module but hey) are a thing
|
||||||
shell: "{{ multi_line }}"
|
shell: "{{ multi_line }}"
|
||||||
|
|
|
@ -47,21 +47,6 @@ pip install \
|
||||||
virtualenv \
|
virtualenv \
|
||||||
jmespath
|
jmespath
|
||||||
|
|
||||||
# FIXME: tests assume bash is in /bin/bash
|
|
||||||
if [ ! -f /bin/bash ]; then
|
|
||||||
ln -s /usr/local/bin/bash /bin/bash
|
|
||||||
fi
|
|
||||||
|
|
||||||
# FIXME: tests assume true is in /bin/true
|
|
||||||
if [ ! -f /bin/true ]; then
|
|
||||||
ln -s /usr/bin/true /bin/true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# FIXME: tests assume sha1sum is available (some platforms have shasum instead)
|
|
||||||
if [ ! -f /usr/local/bin/sha1sum ]; then
|
|
||||||
ln -s /usr/local/bin/shasum /usr/local/bin/sha1sum
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Tests assume loopback addresses other than 127.0.0.1 will work.
|
# Tests assume loopback addresses other than 127.0.0.1 will work.
|
||||||
# Add aliases for loopback addresses used by tests.
|
# Add aliases for loopback addresses used by tests.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue