feat(test): make unittest pattern configurable and pass TEST_PATTERN into containers
This update introduces a configurable TEST_PATTERN variable in the Makefile,
allowing selective execution of unit, integration, and E2E tests without
modifying scripts.
Key changes:
- Add TEST_PATTERN (default: test_*.py) to Makefile and export it.
- Inject TEST_PATTERN into all test containers via `-e TEST_PATTERN=...`.
- Update test-unit.sh, test-integration.sh, and test-e2e.sh to use
`-p "$TEST_PATTERN"` instead of a hardcoded pattern.
- Ensure flexible test selection via:
make test-e2e TEST_PATTERN=test_install_pkgmgr_shallow.py
This enables fast debugging, selective test runs, and better developer
experience while keeping full compatibility with CI defaults.
https://chatgpt.com/share/69385400-2f14-800f-b093-bb03c8ef9c7f
This commit is contained in:
6
Makefile
6
Makefile
@@ -12,7 +12,7 @@ NIX_CACHE_VOLUME := pkgmgr_nix_cache
|
|||||||
# Distro list and base images
|
# Distro list and base images
|
||||||
# (kept for documentation/reference; actual build logic is in scripts/build)
|
# (kept for documentation/reference; actual build logic is in scripts/build)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
DISTROS := arch debian ubuntu fedora centos
|
DISTROS := arch debian ubuntu fedora centos
|
||||||
BASE_IMAGE_ARCH := archlinux:latest
|
BASE_IMAGE_ARCH := archlinux:latest
|
||||||
BASE_IMAGE_DEBIAN := debian:stable-slim
|
BASE_IMAGE_DEBIAN := debian:stable-slim
|
||||||
BASE_IMAGE_UBUNTU := ubuntu:latest
|
BASE_IMAGE_UBUNTU := ubuntu:latest
|
||||||
@@ -27,6 +27,10 @@ export BASE_IMAGE_UBUNTU
|
|||||||
export BASE_IMAGE_FEDORA
|
export BASE_IMAGE_FEDORA
|
||||||
export BASE_IMAGE_CENTOS
|
export BASE_IMAGE_CENTOS
|
||||||
|
|
||||||
|
# PYthon Unittest Pattern
|
||||||
|
TEST_PATTERN := test_*.py
|
||||||
|
export TEST_PATTERN
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# PKGMGR setup (developer wrapper -> scripts/installation/main.sh)
|
# PKGMGR setup (developer wrapper -> scripts/installation/main.sh)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ for distro in $DISTROS; do
|
|||||||
$MOUNT_NIX \
|
$MOUNT_NIX \
|
||||||
-v "pkgmgr_nix_cache:/root/.cache/nix" \
|
-v "pkgmgr_nix_cache:/root/.cache/nix" \
|
||||||
-e PKGMGR_DEV=1 \
|
-e PKGMGR_DEV=1 \
|
||||||
|
-e TEST_PATTERN="${TEST_PATTERN}" \
|
||||||
--workdir /src \
|
--workdir /src \
|
||||||
--entrypoint bash \
|
--entrypoint bash \
|
||||||
"package-manager-test-$distro" \
|
"package-manager-test-$distro" \
|
||||||
@@ -51,6 +52,6 @@ for distro in $DISTROS; do
|
|||||||
nix develop .#default --no-write-lock-file -c \
|
nix develop .#default --no-write-lock-file -c \
|
||||||
python3 -m unittest discover \
|
python3 -m unittest discover \
|
||||||
-s /src/tests/e2e \
|
-s /src/tests/e2e \
|
||||||
-p "test_*.py";
|
-p "$TEST_PATTERN";
|
||||||
'
|
'
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ docker run --rm \
|
|||||||
-v "pkgmgr_nix_cache:/root/.cache/nix" \
|
-v "pkgmgr_nix_cache:/root/.cache/nix" \
|
||||||
--workdir /src \
|
--workdir /src \
|
||||||
-e PKGMGR_DEV=1 \
|
-e PKGMGR_DEV=1 \
|
||||||
|
-e TEST_PATTERN="${TEST_PATTERN}" \
|
||||||
--entrypoint bash \
|
--entrypoint bash \
|
||||||
"package-manager-test-arch" \
|
"package-manager-test-arch" \
|
||||||
-c '
|
-c '
|
||||||
@@ -19,5 +20,5 @@ docker run --rm \
|
|||||||
python -m unittest discover \
|
python -m unittest discover \
|
||||||
-s tests/integration \
|
-s tests/integration \
|
||||||
-t /src \
|
-t /src \
|
||||||
-p "test_*.py";
|
-p "$TEST_PATTERN";
|
||||||
'
|
'
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ docker run --rm \
|
|||||||
-v "pkgmgr_nix_cache:/root/.cache/nix" \
|
-v "pkgmgr_nix_cache:/root/.cache/nix" \
|
||||||
--workdir /src \
|
--workdir /src \
|
||||||
-e PKGMGR_DEV=1 \
|
-e PKGMGR_DEV=1 \
|
||||||
|
-e TEST_PATTERN="${TEST_PATTERN}" \
|
||||||
--entrypoint bash \
|
--entrypoint bash \
|
||||||
"package-manager-test-arch" \
|
"package-manager-test-arch" \
|
||||||
-c '
|
-c '
|
||||||
@@ -19,5 +20,5 @@ docker run --rm \
|
|||||||
python -m unittest discover \
|
python -m unittest discover \
|
||||||
-s tests/unit \
|
-s tests/unit \
|
||||||
-t /src \
|
-t /src \
|
||||||
-p "test_*.py";
|
-p "$TEST_PATTERN";
|
||||||
'
|
'
|
||||||
|
|||||||
Reference in New Issue
Block a user