Skip to content

Commit 174c721

Browse files
committed
Implement test with bash_unit
1 parent 39276ba commit 174c721

22 files changed

+2843
-14
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ test-quick: ## Test 8.0 and 8.1 quickly
1616
test-8.1: ## Test php8.1 build only
1717
VERSION=8.1 VARIANT=cli $(MAKE) _test-version
1818
VERSION=8.1 VARIANT=apache $(MAKE) _test-version
19+
VERSION=8.1 VARIANT=fpm $(MAKE) _test-version
1920

2021
test-8.0: ## Test php8.0 build only
2122
VERSION=8.0 VARIANT=cli $(MAKE) _test-version
2223
VERSION=8.0 VARIANT=apache $(MAKE) _test-version
24+
VERSION=8.0 VARIANT=fpm $(MAKE) _test-version
2325

2426
_test-version: _test-prerequisites ## Test php build for VERSION="" and VARIANT=""
2527
docker buildx bake --load \
2628
--set "*.platform=$$(uname -p)" \
27-
php$${VERSION//.}-cli
28-
PHP_VERSION="$(VERSION)" BRANCH=v4 VARIANT=cli ./test-image.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT))" && exit 1)
29+
php$${VERSION//.}-$(VARIANT)-all
30+
PHP_VERSION="$(VERSION)" BRANCH=v4 VARIANT=$(VARIANT) ./tests-suite/bash_unit -f tap ./tests-suite/*.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT))" && exit 1)
2931
notify-send -u critical "Tests passed with success ($(VERSION)-$(VARIANT))"
3032

3133
clean: ## Clean dangles image after build

test-image.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env bash
2-
32
set -eE -o functrace
43

54
failure() {
@@ -9,6 +8,9 @@ failure() {
98
}
109
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR
1110

11+
echo "This testing suite is deprecated : use instead bash_unit in tests-suite directory"
12+
sleep 5
13+
1214
# Use either docker's 'build' command or 'buildx '
1315
export BUILDTOOL="buildx build --load --platform=${PLATFORM:-$(uname -p)}"
1416

@@ -19,9 +21,6 @@ export BRANCH_VARIANT="${VARIANT//./-}"
1921
export DOCKER_BUILDKIT=1 # Force use of BuildKit
2022
export BUILDKIT_STEP_LOG_MAX_SIZE=10485760 # output log limit fixed to 10MiB
2123

22-
# Let's build the "slim" image.
23-
docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" --build-arg BLACKFIRE_VERSION="${BLACKFIRE_VERSION}" -f "Dockerfile.slim.${VARIANT}" .
24-
2524
# Let's check that the extensions can be built using the "ONBUILD" statement
2625
docker $BUILDTOOL -t test/slim_onbuild --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg BRANCH="$BRANCH" --build-arg BRANCH_VARIANT="$BRANCH_VARIANT" tests/slim_onbuild
2726
# This should run ok (the sudo disable environment variables but call to composer proxy does not trigger PHP ini file regeneration)
@@ -200,6 +199,8 @@ docker run --rm -e PHP_EXTENSION_XDEBUG=1 "thecodingmachine/php:${PHP_VERSION}-$
200199
# Let's check that "xdebug.mode" is properly overridden
201200
docker run --rm -e PHP_EXTENSION_XDEBUG=1 -e PHP_INI_XDEBUG__MODE=debug,coverage "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" php -i | grep xdebug.mode | grep "debug,coverage"
202201

202+
# TODO
203+
203204
if [[ "${PHP_VERSION}" != "8.1" ]]; then
204205
# Tests that blackfire + xdebug will output an error
205206
RESULT="$(docker run --rm -e PHP_EXTENSION_XDEBUG=1 -e PHP_EXTENSION_BLACKFIRE=1 "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" php -v 2>&1 | grep 'WARNING: Both Blackfire and Xdebug are enabled. This is not recommended as the PHP engine may not behave as expected. You should strongly consider disabling Xdebug or Blackfire.')"
@@ -214,12 +215,4 @@ docker $BUILDTOOL -t test/composer_with_gd --build-arg PHP_VERSION="${PHP_VERSIO
214215
docker run --rm test/composer_with_gd sudo composer update
215216
docker rmi test/composer_with_gd
216217

217-
#################################
218-
# Let's build the "node" images
219-
#################################
220-
docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node10" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node10" .
221-
docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node12" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node12" .
222-
docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node14" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node14" .
223-
docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node16" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node16" .
224-
225218
echo "Tests passed with success"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
echo ini_get('memory_limit');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RewriteEngine On
2+
3+
RewriteRule .? test.php [L]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
echo 'foo';

tests-suite/assets/apache/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
if (!isset($_SERVER['MYVAR'])) {
3+
echo "No variable set";
4+
} else {
5+
echo $_SERVER['MYVAR'];
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ARG BRANCH
2+
ARG BRANCH_VARIANT
3+
ARG PHP_VERSION
4+
5+
FROM thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}
6+
7+
ENV PHP_EXTENSION_GD=1
8+
9+
COPY composer.json composer.json
10+
11+
# Let's check that GD is available.
12+
RUN composer install
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"ext-gd": "*"
4+
}
5+
}

0 commit comments

Comments
 (0)