Debian Codegraph @

test/integration/targets/ansible-test-sanity-validate-modules/runme.sh

raw
1 #!/usr/bin/env bash
2
3 source ../collection/setup.sh
4
5 set -eux
6
7 ansible-test sanity --test validate-modules --color --truncate 0 --failure-ok --lint "${@}" 1> actual-stdout.txt 2> actual-stderr.txt
8 diff -u "${TEST_DIR}/expected.txt" actual-stdout.txt
9 grep -F -f "${TEST_DIR}/expected.txt" actual-stderr.txt
10
11 cd ../col
12 ansible-test sanity --test runtime-metadata
13
14 cd ../failure
15 if ansible-test sanity --test runtime-metadata 2>&1 | tee out.txt; then
16 echo "runtime-metadata in failure should be invalid"
17 exit 1
18 fi
19 grep out.txt -e 'extra keys not allowed'
20
21 cd ../ps_only
22
23 if ! command -V pwsh; then
24 echo "skipping test since pwsh is not available"
25 exit 0
26 fi
27
28 pwsh --version
29
30 # Use a PowerShell-only collection to verify that validate-modules does not load the collection loader multiple times.
31 ansible-test sanity --test validate-modules --color --truncate 0 "${@}"
32
33 cd ../failure
34
35 if ansible-test sanity --test validate-modules --color --truncate 0 "${@}" 1> ansible-stdout.txt 2> ansible-stderr.txt; then
36 echo "ansible-test sanity for failure should cause failure"
37 exit 1
38 fi
39
40 cat ansible-stdout.txt
41 grep -q "ERROR: plugins/modules/failure_ps.ps1:0:0: import-error: Exception attempting to import module for argument_spec introspection" < ansible-stdout.txt
42 grep -q "test inner error message" < ansible-stdout.txt
43
44 cat ansible-stderr.txt
45 grep -q "FATAL: The 1 sanity test(s) listed below (out of 1) failed" < ansible-stderr.txt
46 grep -q "validate-modules" < ansible-stderr.txt