summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ansible-test-sanity-lint/runme.sh
blob: 3e73cb4a615b99da15413e771cd2b6cbb914f75a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# Make sure that `ansible-test sanity --lint` outputs the correct format to stdout, even when delegation is used.

set -eu

# Create test scenarios at runtime that do not pass sanity tests.
# This avoids the need to create ignore entries for the tests.

mkdir -p ansible_collections/ns/col/plugins/modules

(
  cd ansible_collections/ns/col/plugins/modules

  echo '#!invalid' > python-wrong-shebang.py # expected module shebang "b'#!/usr/bin/python'" but found: b'#!invalid'
)

source ../collection/setup.sh

set -x

###
### Run the sanity test with the `--lint` option.
###

# Use the `--venv` option to verify that delegation preserves the output streams.
ansible-test sanity --test shebang --color --failure-ok --lint --venv "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
diff -u "${TEST_DIR}/expected.txt" actual-stdout.txt
grep -f "${TEST_DIR}/expected.txt" actual-stderr.txt

# Run without delegation to verify direct output uses the correct streams.
ansible-test sanity --test shebang --color --failure-ok --lint        "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
diff -u "${TEST_DIR}/expected.txt" actual-stdout.txt
grep -f "${TEST_DIR}/expected.txt" actual-stderr.txt

###
### Run the sanity test without the `--lint` option.
###

# Use the `--venv` option to verify that delegation preserves the output streams.
ansible-test sanity --test shebang --color --failure-ok --venv "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
grep -f "${TEST_DIR}/expected.txt" actual-stdout.txt
[ ! -s actual-stderr.txt ]

# Run without delegation to verify direct output uses the correct streams.
ansible-test sanity --test shebang --color --failure-ok "${@}"        1> actual-stdout.txt 2> actual-stderr.txt
grep -f "${TEST_DIR}/expected.txt" actual-stdout.txt
[ ! -s actual-stderr.txt ]