This commit adds the `pkgmgr_nix_store` volume mount (`/nix`) to all test runners (unit, integration, container sanity checks, and E2E tests). Previously only the Arch-based E2E container mounted a persistent `/nix` store, causing all other distros (Debian, Ubuntu, Fedora, CentOS, etc.) to download the entire Nix closure repeatedly during test runs. Changes: - Add `-v pkgmgr_nix_store:/nix` to: - scripts/test/test-container.sh - scripts/test/test-e2e.sh (remove Arch-only condition) - scripts/test/test-unit.sh - scripts/test/test-integration.sh - Ensures all test containers reuse the same Nix store. Benefits: - Significantly faster test execution after the first run. - Prevents redundant downloads from cache.nixos.org. - Ensures consistent Nix environments across all test distros. No functional changes to pkgmgr itself; only test infrastructure improved. https://chatgpt.com/share/693890f5-2f54-800f-b47e-1925da85b434
53 lines
1.4 KiB
Bash
Executable File
53 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
echo ">>> Running E2E tests in all distros: $DISTROS"
|
|
|
|
for distro in $DISTROS; do
|
|
echo "============================================================"
|
|
echo ">>> Running E2E tests: $distro"
|
|
echo "============================================================"
|
|
|
|
docker run --rm \
|
|
-v "$(pwd):/src" \
|
|
-v pkgmgr_nix_store:/nix \
|
|
-v "pkgmgr_nix_cache:/root/.cache/nix" \
|
|
-e PKGMGR_DEV=1 \
|
|
-e TEST_PATTERN="${TEST_PATTERN}" \
|
|
--workdir /src \
|
|
--entrypoint bash \
|
|
"package-manager-test-$distro" \
|
|
-c '
|
|
set -e;
|
|
|
|
if [ -f /etc/os-release ]; then
|
|
. /etc/os-release;
|
|
fi;
|
|
|
|
echo "Running tests inside distro: $ID";
|
|
|
|
# Try to load nix environment
|
|
if [ -f "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]; then
|
|
. "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh";
|
|
fi
|
|
|
|
if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
|
|
. "$HOME/.nix-profile/etc/profile.d/nix.sh";
|
|
fi
|
|
|
|
PATH="/nix/var/nix/profiles/default/bin:$HOME/.nix-profile/bin:$PATH";
|
|
|
|
command -v nix >/dev/null || {
|
|
echo "ERROR: nix not found.";
|
|
exit 1;
|
|
}
|
|
|
|
git config --global --add safe.directory /src || true;
|
|
|
|
nix develop .#default --no-write-lock-file -c \
|
|
python3 -m unittest discover \
|
|
-s /src/tests/e2e \
|
|
-p "$TEST_PATTERN";
|
|
'
|
|
done
|