From 2cc68efd5654c37e91725d403bc9d06eda19ef8a Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 28 May 2020 19:24:08 -0700 Subject: [PATCH] Simplified PHP testing scripts. (#7574) * Simplified PHP testing scripts. - allow them to be run from any directory. - remove "VERSION" arg, we can get PHP from $PATH. * Added a few places I missed. * Removed redundant "cd `dirname $0`". Also replaced all backticks with $(), for consistency. --- php/tests/compatibility_test.sh | 8 --- php/tests/compile_extension.sh | 13 +++-- php/tests/gdb_test.sh | 4 -- php/tests/multirequest.sh | 8 +-- php/tests/test.sh | 7 +-- tests.sh | 94 ++++++++++----------------------- 6 files changed, 43 insertions(+), 91 deletions(-) diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh index b228e5589b..ddf05e85c7 100755 --- a/php/tests/compatibility_test.sh +++ b/php/tests/compatibility_test.sh @@ -1,12 +1,5 @@ #!/bin/bash -function use_php() { - VERSION=$1 - - OLD_PATH=$PATH - export PATH=/usr/local/php-${VERSION}/bin:$OLD_PATH -} - function generate_proto() { PROTOC1=$1 PROTOC2=$2 @@ -87,7 +80,6 @@ git checkout v$OLD_VERSION popd # Build and copy the new runtime -use_php 7.1 pushd ../ext/google/protobuf make clean || true phpize && ./configure && make diff --git a/php/tests/compile_extension.sh b/php/tests/compile_extension.sh index 93916b17b6..3d6759e5ea 100755 --- a/php/tests/compile_extension.sh +++ b/php/tests/compile_extension.sh @@ -1,12 +1,17 @@ #!/bin/bash -VERSION=$2 +cd $(dirname $0) -export PATH=/usr/local/php-$VERSION/bin:$PATH +if [ "$1" = "--release"]; then + CFLAGS="-Wall" +else + # To get debugging symbols in PHP itself, build PHP with: + # $ ./configure --enable-debug CFLAGS='-g -O0' + CFLAGS="-g -O0 -Wall" +fi pushd ../ext/google/protobuf make clean || true set -e -# Add following in configure for debug: --enable-debug CFLAGS='-g -O0' -phpize && ./configure --with-php-config=`which php-config` CFLAGS='-g -O0 -Wall' && make +phpize && ./configure --with-php-config=$(which php-config) CFLAGS="$CFLAGS" && make popd diff --git a/php/tests/gdb_test.sh b/php/tests/gdb_test.sh index 80950c338c..76a0fc3b19 100755 --- a/php/tests/gdb_test.sh +++ b/php/tests/gdb_test.sh @@ -1,9 +1,5 @@ #!/bin/bash -VERSION=$1 - -export PATH=/usr/local/php-$VERSION/bin:$PATH - php -i | grep "Configuration" # gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which diff --git a/php/tests/multirequest.sh b/php/tests/multirequest.sh index f3f68d0d7b..ec4a1ae51e 100755 --- a/php/tests/multirequest.sh +++ b/php/tests/multirequest.sh @@ -1,12 +1,12 @@ #!/bin/bash + +cd $(dirname $0) + set -e -# Compile c extension -VERSION=7.4 PORT=12345 -export PATH=/usr/local/php-$VERSION/bin:$PATH -/bin/bash ./compile_extension.sh $VERSION +./compile_extension.sh nohup php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so -S localhost:$PORT multirequest.php 2>&1 & diff --git a/php/tests/test.sh b/php/tests/test.sh index 45a68f87e5..3ecc0c7516 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -1,11 +1,8 @@ #!/bin/bash -VERSION=$1 +cd $(dirname $0) -export PATH=/usr/local/php-$VERSION/bin:$PATH - -# Compile c extension -/bin/bash ./compile_extension.sh $VERSION +./compile_extension.sh tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php descriptors_test.php wrapper_type_setters_test.php) diff --git a/tests.sh b/tests.sh index 4def89dc01..0a0e7988fc 100755 --- a/tests.sh +++ b/tests.sh @@ -501,12 +501,6 @@ use_php_zts() { generate_php_test_proto } -use_php_bc() { - VERSION=$1 - export PATH=/usr/local/php-${VERSION}-bc/bin:$PATH - generate_php_test_proto -} - build_php5.5() { use_php 5.5 @@ -523,9 +517,7 @@ build_php5.5() { build_php5.5_c() { IS_64BIT=$1 use_php 5.5 - pushd php/tests - /bin/bash ./test.sh 5.5 - popd + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -541,9 +533,7 @@ build_php5.5_mixed() { pushd php rm -rf vendor composer update - pushd tests - /bin/bash ./compile_extension.sh 5.5 - popd + tests/compile_extension.sh php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -551,7 +541,7 @@ build_php5.5_mixed() { build_php5.5_zts_c() { IS_64BIT=$1 use_php_zts 5.5 - cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -577,7 +567,7 @@ build_php5.6() { build_php5.6_c() { IS_64BIT=$1 use_php 5.6 - cd php/tests && /bin/bash ./test.sh 5.6 && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -593,9 +583,7 @@ build_php5.6_mixed() { pushd php rm -rf vendor composer update - pushd tests - /bin/bash ./compile_extension.sh 5.6 - popd + tests/compile_extension.sh php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -603,7 +591,7 @@ build_php5.6_mixed() { build_php5.6_zts_c() { IS_64BIT=$1 use_php_zts 5.6 - cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -633,10 +621,8 @@ build_php5.6_mac() { sudo mv valgrind /usr/local/bin/valgrind # Test - cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - make test_php_c - popd + php/tests/test.sh + (cd conformance && make test_php_c) } build_php7.0() { @@ -646,15 +632,13 @@ build_php7.0() { composer update ./vendor/bin/phpunit popd - pushd conformance - make test_php - popd + (cd conformance && make test_php) } build_php7.0_c() { IS_64BIT=$1 use_php 7.0 - cd php/tests && /bin/bash ./test.sh 7.0 && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -670,9 +654,7 @@ build_php7.0_mixed() { pushd php rm -rf vendor composer update - pushd tests - /bin/bash ./compile_extension.sh 7.0 - popd + tests/compile_extension.sh php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -680,7 +662,7 @@ build_php7.0_mixed() { build_php7.0_zts_c() { IS_64BIT=$1 use_php_zts 7.0 - cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -710,10 +692,8 @@ build_php7.0_mac() { sudo mv valgrind /usr/local/bin/valgrind # Test - cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - make test_php_c - popd + php/tests/test.sh + (cd conformance && make test_php_c) } build_php7.3_mac() { @@ -737,10 +717,8 @@ build_php7.3_mac() { sudo mv valgrind /usr/local/bin/valgrind # Test - cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - make test_php_c - popd + php/tests/test.sh + (cd conformance && make test_php_c) } build_php_compatibility() { @@ -750,9 +728,7 @@ build_php_compatibility() { build_php_multirequest() { use_php 7.4 - pushd php/tests - ./multirequest.sh - popd + php/tests/multirequest.sh } build_php7.1() { @@ -762,15 +738,13 @@ build_php7.1() { composer update ./vendor/bin/phpunit popd - pushd conformance - make test_php - popd + (cd conformance && make test_php) } build_php7.1_c() { IS_64BIT=$1 use_php 7.1 - cd php/tests && /bin/bash ./test.sh 7.1 && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -786,9 +760,7 @@ build_php7.1_mixed() { pushd php rm -rf vendor composer update - pushd tests - /bin/bash ./compile_extension.sh 7.1 - popd + tests/compile_extension.sh php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -796,7 +768,7 @@ build_php7.1_mixed() { build_php7.1_zts_c() { IS_64BIT=$1 use_php_zts 7.1 - cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -814,15 +786,13 @@ build_php7.4() { composer update ./vendor/bin/phpunit popd - pushd conformance - make test_php - popd + (cd conformance && make test_php) } build_php7.4_c() { IS_64BIT=$1 use_php 7.4 - cd php/tests && /bin/bash ./test.sh 7.4 && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -831,9 +801,7 @@ build_php7.4_c() { make test_php_c_32 fi popd - pushd php/ext/google/protobuf - phpize --clean - popd + (cd php/ext/google/protobuf && phpize --clean) } build_php7.4_mixed() { @@ -841,20 +809,16 @@ build_php7.4_mixed() { pushd php rm -rf vendor composer update - pushd tests - /bin/bash ./compile_extension.sh 7.4 - popd + tests/compile_extension.sh php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd - pushd php/ext/google/protobuf - phpize --clean - popd + (cd php/ext/google/protobuf && phpize --clean) } build_php7.4_zts_c() { IS_64BIT=$1 use_php_zts 7.4 - cd php/tests && /bin/bash ./test.sh 7.4-zts && cd ../.. + php/tests/test.sh pushd conformance if [ "$IS_64BIT" = "true" ] then @@ -863,9 +827,7 @@ build_php7.4_zts_c() { make test_php_c_32 fi popd - pushd php/ext/google/protobuf - phpize --clean - popd + (cd php/ext/google/protobuf && phpize --clean) } build_php_all_32() {