Debian Codegraph @

test/integration/targets/ansible-test-vendoring/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 # Run import sanity tests which require modifications to the source directory.
6
7 vendor_dir="$(python -c 'import pathlib, ansible._vendor; print(pathlib.Path(ansible._vendor.__file__).parent)')"
8
9 mkdir "${vendor_dir}/packaging/" # intended to fail if packaging is already present (to avoid deleting it later)
10
11 cleanup() {
12 rm -rf "${vendor_dir}/packaging/"
13 }
14
15 trap cleanup EXIT
16
17 # Verify that packages installed in the vendor directory are loaded by ansible-test.
18 # This is done by injecting a broken `packaging` package, which should cause ansible-test to fail.
19
20 echo 'raise Exception("intentional failure from ansible-test-vendoring integration test")' > "${vendor_dir}/packaging/__init__.py"
21
22 if ansible-test sanity --test import --color --truncate 0 "${@}" > output.log 2>&1; then
23 echo "ansible-test did not exit with a non-zero status"
24 cat output.log
25 exit 1
26 fi
27
28 if ! grep '^Exception: intentional failure from ansible-test-vendoring integration test$' output.log; then
29 echo "ansible-test did not fail with the expected output"
30 cat output.log
31 exit 1
32 fi
33