Debian Codegraph @

test/integration/targets/ansible-test-sanity-lint/runme.sh

raw
1 #!/usr/bin/env bash
2 # Make sure that `ansible-test sanity --lint` outputs the correct format to stdout, even when delegation is used.
3
4 set -eu
5
6 # Create test scenarios at runtime that do not pass sanity tests.
7 # This avoids the need to create ignore entries for the tests.
8
9 mkdir -p ansible_collections/ns/col/plugins/modules
10
11 (
12 cd ansible_collections/ns/col/plugins/modules
13
14 echo '#!invalid' > python-wrong-shebang.py # expected module shebang "b'#!/usr/bin/python'" but found: b'#!invalid'
15 )
16
17 source ../collection/setup.sh
18
19 set -x
20
21 ###
22 ### Run the sanity test with the `--lint` option.
23 ###
24
25 # Use the `--venv` option to verify that delegation preserves the output streams.
26 ansible-test sanity --test shebang --color --failure-ok --lint --venv "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
27 diff -u "${TEST_DIR}/expected.txt" actual-stdout.txt
28 grep -f "${TEST_DIR}/expected.txt" actual-stderr.txt
29
30 # Run without delegation to verify direct output uses the correct streams.
31 ansible-test sanity --test shebang --color --failure-ok --lint "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
32 diff -u "${TEST_DIR}/expected.txt" actual-stdout.txt
33 grep -f "${TEST_DIR}/expected.txt" actual-stderr.txt
34
35 ###
36 ### Run the sanity test without the `--lint` option.
37 ###
38
39 # Use the `--venv` option to verify that delegation preserves the output streams.
40 ansible-test sanity --test shebang --color --failure-ok --venv "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
41 grep -f "${TEST_DIR}/expected.txt" actual-stdout.txt
42 [ ! -s actual-stderr.txt ]
43
44 # Run without delegation to verify direct output uses the correct streams.
45 ansible-test sanity --test shebang --color --failure-ok "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
46 grep -f "${TEST_DIR}/expected.txt" actual-stdout.txt
47 [ ! -s actual-stderr.txt ]