test(scripts): cover a failing venv and name the extra collections path

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-24 07:25:10 +00:00
1 parent 8c52c91dfd
commit 1d28f1a8bc
2 files changed
+6 -5

No files matched your search

+3 -3
View File
@@ -11,7 +11,7 @@ set -euo pipefail
selected="$(cat)"
pins="$AC_ROOT/pins"
collections=""
extra_collections=""
if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools."
else
@@ -24,11 +24,11 @@ else
ANSIBLE_COLLECTIONS_PATH="$pins/collections" \
ansible-galaxy collection install --force -r "$req" -p "$pins/collections"
done
collections="$pins/collections:"
extra_collections="$pins/collections:"
fi
ansible --version
molecule --version
# The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME,
# which the run script keeps in the job tree.
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:$collections/opt/collections"
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"
@@ -27,6 +27,7 @@ exit 0
# The base python: `-m venv <dir>` makes a venv whose bin holds a pip stub.
PYTHON_STUB = """#!/usr/bin/env bash
echo "python args=$*" >> "$STUB_LOG"
[ -n "${STUB_FAIL_python:-}" ] && exit 1
[ "$1 $2" = "-m venv" ] || exit 1
mkdir -p "$3/bin"
cp "$STUB_SOURCE" "$3/bin/pip"
@@ -124,7 +125,7 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
line,
)
# The target alone, so a baked copy is not taken as already installed.
self.assertIn(f"acp={self.pins}/collections\n", line + "\n")
self.assertTrue(line.endswith(f"acp={self.pins}/collections"), line)
(runner,) = self.calls("runner")
self.assertIn(f"path={self.pins}/venv/bin:", runner)
self.assertIn(
@@ -142,7 +143,7 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
)
def test_a_failing_install_fails_the_run(self):
for stub in ("pip", "ansible-galaxy"):
for stub in ("python", "pip", "ansible-galaxy"):
with self.subTest(stub=stub):
self.log.write_text("")
shutil.rmtree(self.pins, True)