php 官方自动化测试方法

├── Makefile
├── phpt
│ └── test.phpt
└── run-tests.php

Makefile文件

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
base_dir=./
top_builddir=${base_dir}
top_srcdir=${base_dir}
TESTS=${base_dir}/phpt
#PHP_EXECUTABLE=/usr/local/php/bin/php
PHP_EXECUTABLE=/usr/bin/php
EGREP = /bin/grep -E
CC = cc
PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
all:
@echo
@echo "You should run 'make test'."
@echo
test:
-@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
cp "$$INI_FILE" $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini $(TESTS); \
rm $(top_builddir)/tmp-php.ini; \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
.PHONY: all test

参考