summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/collection/setup.sh
blob: 346a21ca9a26a79722374716fcf0d4eca3e8731d (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
#!/usr/bin/env bash
# Source this file from collection integration tests.
#
# It simplifies several aspects of collection testing:
#
# 1) Collection tests must be executed outside of the ansible source tree.
#    Otherwise ansible-test will test the ansible source instead of the test collection.
#    The temporary directory provided by ansible-test resides within the ansible source tree.
#
# 2) Sanity test ignore files for collections must be versioned based on the ansible-core version being used.
#    This script generates an ignore file with the correct filename for the current ansible-core version.
#
# 3) Sanity tests which are multi-version require an ignore entry per Python version.
#    This script replicates these ignore entries for each supported Python version based on the ignored path.
#
# 4) Windows tests need access to the ansible.windows vendored collection.
#    This script copies any of the existing collections in ANSIBLE_COLLECTIONS_PATH to the temporary directory.

set -eu -o pipefail

export TEST_DIR
export WORK_DIR

TEST_DIR="$PWD"
WORK_DIR="$(mktemp -d)"

trap 'rm -rf "${WORK_DIR}"' EXIT

cp -a "${TEST_DIR}/ansible_collections" "${WORK_DIR}"
cd "${WORK_DIR}/ansible_collections/ns/${COLLECTION_NAME:-col}"

if [ "${ANSIBLE_COLLECTIONS_PATH:+set}" = "set" ]; then
    cp -aL "${ANSIBLE_COLLECTIONS_PATH}"/ansible_collections/* "${WORK_DIR}/ansible_collections"
fi

"${TEST_DIR}/../collection/update-ignore.py"