From 6e4f868cca7fdcaca7a615e8759192e8fc4375b8 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 28 Sep 2019 20:03:06 +0300 Subject: [PATCH 01/17] Cleaned up test script [skip appveyor] --- .ci/run-tests.sh | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/.ci/run-tests.sh b/.ci/run-tests.sh index 883e0a8a..d2c2e7cc 100755 --- a/.ci/run-tests.sh +++ b/.ci/run-tests.sh @@ -11,35 +11,29 @@ set -e NO_INTERACTION=1 REPORT_EXIT_STATUS=1 -ZEND_DONT_UNLOAD_MODULES=1 -USE_ZEND_ALLOC=0 +TEST_PHP_EXECUTABLE="$(phpenv which php)" +TEST_PHP_ARGS= -export NO_INTERACTION REPORT_EXIT_STATUS ZEND_DONT_UNLOAD_MODULES USE_ZEND_ALLOC -if [ -z "${TEST_PHP_EXECUTABLE}" ]; then - TEST_PHP_EXECUTABLE="$(phpenv which php)" - export TEST_PHP_EXECUTABLE +if [ -n "$(command -v valgrind 2>/dev/null || true)" ]; then + TEST_PHP_ARGS=-m fi -PHP_VERNUM="$($(phpenv which php-config) --vernum)" -PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" +export NO_INTERACTION REPORT_EXIT_STATUS TEST_PHP_EXECUTABLE TEST_PHP_ARGS -if [ "${PHP_VERNUM}" -lt 70300 ]; then - if [ -n "$(command -v valgrind 2>/dev/null)" ]; then - TEST_PHP_ARGS=-m - export TEST_PHP_ARGS - else - >&2 echo "Skip check for memory leaks. Valgring does not exist" - fi -else - >&2 echo "Skip check for memory leaks due to unstable PHP version" -fi +PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" ${TEST_PHP_EXECUTABLE} "${PROJECT_ROOT}/run-tests.php" \ - -d extension=zephir_parser.so \ - -d extension_dir="${PROJECT_ROOT}/modules" \ - -d variables_order=EGPCS \ - -n "${PROJECT_ROOT}/tests/*.phpt" \ - -g "FAIL,XFAIL,BORK,WARN,SKIP" \ - --offline \ - --show-diff \ - --set-timeout 120 + -d "error_reporting=32767" \ + -d "display_errors=1" \ + -d "display_startup_errors=1" \ + -d "log_errors=0" \ + -d "report_memleaks=1" \ + -d 'extension=zephir_parser.so' \ + -d "extension_dir=$PROJECT_ROOT/modules" \ + -n "$PROJECT_ROOT/tests/*.phpt" \ + -g "FAIL,XFAIL,BORK,WARN,SKIP" \ + -p "$TEST_PHP_EXECUTABLE" \ + -n \ + --offline \ + --show-diff \ + --set-timeout 120 From fd3d4a5bc38e5cfa016baacbf395d0e235c8583d Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 00:46:44 +0300 Subject: [PATCH 02/17] Remove no longer needed test script [skip appveyor] --- .ci/run-tests.sh | 39 --------------------------------------- .travis.yml | 17 +++++++++++------ 2 files changed, 11 insertions(+), 45 deletions(-) delete mode 100755 .ci/run-tests.sh diff --git a/.ci/run-tests.sh b/.ci/run-tests.sh deleted file mode 100755 index d2c2e7cc..00000000 --- a/.ci/run-tests.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -# -# This file is part of the Zephir Parser. -# -# (c) Zephir Team -# -# For the full copyright and license information, please view -# the LICENSE file that was distributed with this source code. - -set -e - -NO_INTERACTION=1 -REPORT_EXIT_STATUS=1 -TEST_PHP_EXECUTABLE="$(phpenv which php)" -TEST_PHP_ARGS= - -if [ -n "$(command -v valgrind 2>/dev/null || true)" ]; then - TEST_PHP_ARGS=-m -fi - -export NO_INTERACTION REPORT_EXIT_STATUS TEST_PHP_EXECUTABLE TEST_PHP_ARGS - -PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" - -${TEST_PHP_EXECUTABLE} "${PROJECT_ROOT}/run-tests.php" \ - -d "error_reporting=32767" \ - -d "display_errors=1" \ - -d "display_startup_errors=1" \ - -d "log_errors=0" \ - -d "report_memleaks=1" \ - -d 'extension=zephir_parser.so' \ - -d "extension_dir=$PROJECT_ROOT/modules" \ - -n "$PROJECT_ROOT/tests/*.phpt" \ - -g "FAIL,XFAIL,BORK,WARN,SKIP" \ - -p "$TEST_PHP_EXECUTABLE" \ - -n \ - --offline \ - --show-diff \ - --set-timeout 120 diff --git a/.travis.yml b/.travis.yml index 054c3746..76f7f56e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,18 +48,23 @@ install: - .ci/install-re2c.sh - phpize - | - ./configure \ - --with-php-config=$(phpenv which php-config) \ - --enable-zephir-parser \ - --enable-zephir-parser-debug \ - --enable-coverage + ./configure \ + --with-php-config=$(phpenv which php-config) \ + --enable-zephir-parser \ + --enable-zephir-parser-debug \ + --enable-coverage - make $MAKEJOBS before_script: - if [ $COVERAGE = "ON" ]; then make coverage-initial; fi + - | + if [ "$($(phpenv which php-config) --vernum)" -lt 70300 ]; then + export ZEND_DONT_UNLOAD_MODULES=1 + export USE_ZEND_ALLOC=0 + fi script: - - .ci/run-tests.sh + - make test NO_INTERACTION=1 REPORT_EXIT_STATUS=1 TEST_PHP_ARGS=-m after_failure: - .ci/after-failure.sh From eb57aab5364bb8e00c7a6a09a2540beedda4dca5 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 01:30:32 +0300 Subject: [PATCH 03/17] Added valgrind suppression file for PHP >= 7.3 [skip appveyor] --- .travis.yml | 10 +++++++--- tests/php-7.3.supp | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/php-7.3.supp diff --git a/.travis.yml b/.travis.yml index 76f7f56e..241cd296 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,8 @@ env: global: - MAKEJOBS="-j$(getconf _NPROCESSORS_ONLN)" - COVERAGE=ON + - ZEND_DONT_UNLOAD_MODULES=1 + - USE_ZEND_ALLOC=0 - TRAVIS_COMMIT_LOG=`git log --format=fuller -2` matrix: - RE2C_VERSION="0.13.6" @@ -58,9 +60,11 @@ install: before_script: - if [ $COVERAGE = "ON" ]; then make coverage-initial; fi - | - if [ "$($(phpenv which php-config) --vernum)" -lt 70300 ]; then - export ZEND_DONT_UNLOAD_MODULES=1 - export USE_ZEND_ALLOC=0 + if [ "$(php-config --vernum)" -ge "70300" ]; then + echo "Patching PHP tests ruunner" + # TODO: Add to makefile + sed -e "s|'\(valgrind -q --tool=memcheck --trace-children=yes\)'|'\1 --suppressions=./tests/php-7.3.supp'|" \ + run-tests.php > tmp.php && mv tmp.php run-tests.php fi script: diff --git a/tests/php-7.3.supp b/tests/php-7.3.supp new file mode 100644 index 00000000..747a849f --- /dev/null +++ b/tests/php-7.3.supp @@ -0,0 +1,41 @@ +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + ... + fun:php_module_startup + fun:php_cli_startup + fun:main +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + ... + fun:php_execute_script + fun:do_cli +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + ... + fun:php_module_startup + ... +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + fun:zend_new_interned_string_request + fun:zval_make_interned_string + ... +} From 9c8c51c41dc8491cb32f49100e579872e5fa1aba Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 01:59:18 +0300 Subject: [PATCH 04/17] Ammend suppresion file [skip appveyor] --- tests/php-7.3.supp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/php-7.3.supp b/tests/php-7.3.supp index 747a849f..bf2961eb 100644 --- a/tests/php-7.3.supp +++ b/tests/php-7.3.supp @@ -39,3 +39,24 @@ fun:zval_make_interned_string ... } + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + ... + fun:zend_startup_modules +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_hash_find_bucket + ... + fun:compile_file + ... +} From 40533d1c7a1e9791769170b86a81a997a7f643bb Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 01:59:45 +0300 Subject: [PATCH 05/17] Cleaned up travis config [skip appveyor] --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 241cd296..a1983689 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,9 +62,12 @@ before_script: - | if [ "$(php-config --vernum)" -ge "70300" ]; then echo "Patching PHP tests ruunner" - # TODO: Add to makefile - sed -e "s|'\(valgrind -q --tool=memcheck --trace-children=yes\)'|'\1 --suppressions=./tests/php-7.3.supp'|" \ - run-tests.php > tmp.php && mv tmp.php run-tests.php + + # TODO: Move to makefile + search_str="valgrind -q --tool=memcheck --trace-children=yes" + add_str="--suppressions=./tests/php-7.3.supp" + sed -e "s|'\($search_str\)'|'\1 $add_str'|" run-tests.php > tmp.php + mv tmp.php run-tests.php fi script: From 9461c68ecaaebadb2c134e8b6925c9f35706538d Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 02:00:28 +0300 Subject: [PATCH 06/17] Improved after_failure script [skip appveyor] --- .ci/after-failure.sh | 45 ++++++++++++++++++++++---------------------- .travis.yml | 3 +++ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.ci/after-failure.sh b/.ci/after-failure.sh index 12e8f64d..cc3490ba 100755 --- a/.ci/after-failure.sh +++ b/.ci/after-failure.sh @@ -7,33 +7,33 @@ # For the full copyright and license information, please view # the LICENSE file that was distributed with this source code. -$(phpenv which php) -v -$(phpenv which php) -m - -PROJECT_ROOT=$(readlink -enq "$(dirname $0)/../") -cd ${PROJECT_ROOT} +# -e Exit immediately if a command exits with a non-zero status. +# -u Treat unset variables as an error when substituting. +set -eu shopt -s nullglob -for i in `find ./tests -name "*.out" 2>/dev/null`; do - echo "-- START ${i}"; cat ${i}; echo "-- END"; -done - -for i in `find ./tests -name "*.mem" 2>/dev/null`; do - echo "-- START ${i}"; cat ${i}; echo "-- END"; -done - -if [ -f "./configure.log" ]; then - cat "./configure.log" -fi - -ls -al ${PROJECT_ROOT} - export LC_ALL=C -for i in core core.*; do - if [ -f "$i" -a "$(file "$i" | grep -o 'core file')" ]; then - gdb -q $(file "${i}" | grep -oE "'[^ ']+" | sed "s/^'//g") "$i" <&1 printf ">>> START (%d)\\n%s\\n<<< END (%d)\\n\\n" $count "$(cat "$file")" $count) +done < <(find ./tests -type f \( -name '*.out' -o -name '*.mem' \) -print0) + +# for some reason Ubuntu 18.04 on Travis CI doesn't install gdb +function install_gdb() { + if [ "${CI}" = "true" ] && [ "$(command -v gdb 2>/dev/null)" = "" ] + then + (>&1 echo "Install gdb...") + sudo apt-get install --no-install-recommends --quiet --assume-yes gdb 1> /dev/null + fi +} + +for i in /tmp/core.php.*; do + install_gdb + (>&1 printf "Found core dump file: %s\\n\\n" "$i") + gdb -q "$(phpenv which php)" "$i" < Date: Sun, 29 Sep 2019 02:19:12 +0300 Subject: [PATCH 07/17] Improved after_failure script [skip appveyor] --- .ci/after-failure.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.ci/after-failure.sh b/.ci/after-failure.sh index cc3490ba..a616c72c 100755 --- a/.ci/after-failure.sh +++ b/.ci/after-failure.sh @@ -7,10 +7,6 @@ # For the full copyright and license information, please view # the LICENSE file that was distributed with this source code. -# -e Exit immediately if a command exits with a non-zero status. -# -u Treat unset variables as an error when substituting. -set -eu - shopt -s nullglob export LC_ALL=C @@ -32,7 +28,7 @@ function install_gdb() { for i in /tmp/core.php.*; do install_gdb - (>&1 printf "Found core dump file: %s\\n\\n" "$i") + (>&1 printf "Found core dump file: %s\\n\\n" "$i") gdb -q "$(phpenv which php)" "$i" < Date: Sun, 29 Sep 2019 02:19:55 +0300 Subject: [PATCH 08/17] Always enable coverage [skip appveyor] --- .travis.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7950d366..406a80fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,6 @@ addons: env: global: - MAKEJOBS="-j$(getconf _NPROCESSORS_ONLN)" - - COVERAGE=ON - ZEND_DONT_UNLOAD_MODULES=1 - USE_ZEND_ALLOC=0 - TRAVIS_COMMIT_LOG=`git log --format=fuller -2` @@ -59,7 +58,7 @@ install: - make $MAKEJOBS before_script: - - if [ $COVERAGE = "ON" ]; then make coverage-initial; fi + - make coverage-initial - | if [ "$(php-config --vernum)" -ge "70300" ]; then echo "Patching PHP tests ruunner" @@ -80,11 +79,8 @@ after_failure: - .ci/after-failure.sh after_success: - - | - if [ $COVERAGE = "ON" ]; then - make coverage-capture - bash <(curl -s https://codecov.io/bash) - fi + - make coverage-capture + - bash <(curl -s https://codecov.io/bash) after_script: - printf "$TRAVIS_COMMIT_RANGE\n" From d85a07f353ba6cfe7e3cec4d87b3da83446e3cc3 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 10:41:33 +0300 Subject: [PATCH 09/17] Amended suppression file for PHP 7.3 [skip appveyor] --- tests/php-7.3.supp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/php-7.3.supp b/tests/php-7.3.supp index bf2961eb..f656ff88 100644 --- a/tests/php-7.3.supp +++ b/tests/php-7.3.supp @@ -60,3 +60,14 @@ fun:compile_file ... } + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_hash_find_bucket + ... + fun:zend_compile_stmt + ... +} From fb9965d76fff294209448d011be328c3d2d5cd84 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 11:32:43 +0300 Subject: [PATCH 10/17] Added suppression file for PHP 7.4 [skip appveyor] --- .travis.yml | 8 ++--- tests/php-7.4.supp | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 tests/php-7.4.supp diff --git a/.travis.yml b/.travis.yml index 406a80fa..516e129e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,12 +61,12 @@ before_script: - make coverage-initial - | if [ "$(php-config --vernum)" -ge "70300" ]; then - echo "Patching PHP tests ruunner" + echo "Patching PHP tests runner to silence messages about PHP memory leaks ¯\_(ツ)_/¯" # TODO: Move to makefile - search_str="valgrind -q --tool=memcheck --trace-children=yes" - add_str="--suppressions=./tests/php-7.3.supp" - sed -e "s|'\($search_str\)'|'\1 $add_str'|" run-tests.php > tmp.php + search_str="valgrind -q --tool=.* --trace-children=yes" + add_str="--suppressions=./tests/php-$(php-config --version | cut -d'.' -f1,2).supp" + sed -e "s|[\"']\($search_str\)[\"']|\"\1 $add_str\"|" run-tests.php > tmp.php mv tmp.php run-tests.php fi diff --git a/tests/php-7.4.supp b/tests/php-7.4.supp new file mode 100644 index 00000000..b86b1347 --- /dev/null +++ b/tests/php-7.4.supp @@ -0,0 +1,83 @@ +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + ... + fun:zend_compile_dim +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + ... + fun:zend_compile_top_stmt +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + ... + fun:zend_delayed_compile_var +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + ... + fun:zend_compile_var +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + ... + fun:php_cli_startup + ... +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_hash_find_bucket + ... + fun:php_execute_script + ... +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_fast_equal_strings + fun:ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_CONST_JMPZ_HANDLER + ... + fun:php_execute_script + ... +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_hash_del + ... + fun:zend_hash_apply + fun:zend_startup_modules +} From ef835e71353abb86a55bd65d66ff27e8111c7dbd Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 11:36:48 +0300 Subject: [PATCH 11/17] Add latest re2c to build & test matrix [skip appveyor] --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 516e129e..7326f03f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,13 +23,13 @@ addons: env: global: - - MAKEJOBS="-j$(getconf _NPROCESSORS_ONLN)" + - MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)" - ZEND_DONT_UNLOAD_MODULES=1 - USE_ZEND_ALLOC=0 - TRAVIS_COMMIT_LOG=`git log --format=fuller -2` matrix: - RE2C_VERSION="0.13.6" - - RE2C_VERSION="1.1.1" + - RE2C_VERSION="1.2.1" matrix: fast_finish: true @@ -55,7 +55,7 @@ install: --enable-zephir-parser \ --enable-zephir-parser-debug \ --enable-coverage - - make $MAKEJOBS + - make before_script: - make coverage-initial From 89b73ffae1ebc475c0402453190e2b2fde4d983d Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 11:45:41 +0300 Subject: [PATCH 12/17] Debug patching PHP tests runner [skip appveyor] --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7326f03f..53fe2c60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,6 +68,9 @@ before_script: add_str="--suppressions=./tests/php-$(php-config --version | cut -d'.' -f1,2).supp" sed -e "s|[\"']\($search_str\)[\"']|\"\1 $add_str\"|" run-tests.php > tmp.php mv tmp.php run-tests.php + grep 'valgrind -q --tool=' run-tests.php + + echo "Done" fi script: From fa5e2b7e7016a50580dd686f035383f33f0fe2e8 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 12:29:59 +0300 Subject: [PATCH 13/17] Update re2c installer [skip appveyor] --- .ci/install-re2c.sh | 71 ++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/.ci/install-re2c.sh b/.ci/install-re2c.sh index 6b1e2010..264d8e3b 100755 --- a/.ci/install-re2c.sh +++ b/.ci/install-re2c.sh @@ -8,65 +8,64 @@ # the LICENSE file that was distributed with this source code. if [ -z ${RE2C_VERSION+x} ]; then - >&2 echo "The RE2C_VERSION value is not set. Stop." - exit 1 + >&2 echo "The RE2C_VERSION value is not set. Stop." + exit 1 fi if [ "${RE2C_VERSION}" == "system" ]; then - echo "Use system re2c. Skip." - exit 0 + echo "Use system re2c. Skip." + exit 0 fi pkgname=re2c -source="https://github.com/skvadrik/${pkgname}/releases/download/${RE2C_VERSION}/${pkgname}-${RE2C_VERSION}.tar.gz" +source="https://github.com/skvadrik/${pkgname}/releases/download/${RE2C_VERSION}/${pkgname}-${RE2C_VERSION}.tar.xz" downloaddir="${HOME}/.cache/${pkgname}/${pkgname}-${RE2C_VERSION}" prefix="${HOME}/.local/opt/${pkgname}/${pkgname}-${RE2C_VERSION}" bindir="${prefix}/bin" if [ ! -f "${bindir}/re2c" ]; then - if [ ! -d `dirname ${downloaddir}` ]; then - mkdir -p `dirname ${downloaddir}` - fi - - cd `dirname ${downloaddir}` + if [ ! -d `dirname ${downloaddir}` ]; then + mkdir -p `dirname ${downloaddir}` + fi + cd "$(dirname "$downloaddir")" || exit 1 - if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.gz" ]; then - curl -sSL "$source" -o "${pkgname}-${RE2C_VERSION}.tar.gz" - fi + if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.xz" ]; then + curl -sSL "$source" -o "${pkgname}-${RE2C_VERSION}.tar.xz" + fi - if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.gz" ]; then - >&2 echo "Unable to locate ${pkgname}-${RE2C_VERSION}.tar.gz file. Stop." - exit 1 - fi + if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.xz" ]; then + >&2 echo "Unable to locate ${pkgname}-${RE2C_VERSION}.tar.xz file. Stop." + exit 1 + fi - if [ ! -d "${downloaddir}" ]; then - mkdir -p "${downloaddir}" - tar -zxf "${pkgname}-${RE2C_VERSION}.tar.gz" - fi + if [ ! -d "${downloaddir}" ]; then + mkdir -p "${downloaddir}" + tar -xf "${pkgname}-${RE2C_VERSION}.tar.xz" || exit 1 + fi - if [ ! -d "${downloaddir}" ]; then - >&2 echo "Unable to locate re2c source. Stop." - exit 1 - fi + if [ ! -d "${downloaddir}" ]; then + >&2 echo "Unable to locate re2c source. Stop." + exit 1 + fi - if [ ! -d "${prefix}" ]; then - mkdir -p "${prefix}" - fi + if [ ! -d "${prefix}" ]; then + mkdir -p "${prefix}" + fi - cd "${downloaddir}" - ./configure --prefix="${prefix}" + cd "${downloaddir}" || exit 1 + ./configure --prefix="${prefix}" - make -j"$(getconf _NPROCESSORS_ONLN)" - make install + make -j"$(getconf _NPROCESSORS_ONLN)" + make install fi if [ ! -x "${bindir}/re2c" ]; then - >&2 echo "Unable to locate re2c executable. Stop." - exit 1 + >&2 echo "Unable to locate re2c executable. Stop." + exit 1 fi -mkdir -p ${HOME}/bin -ln -s "${bindir}/re2c" ${HOME}/bin/re2c +mkdir -p "${HOME}/bin" +ln -s "${bindir}/re2c" "${HOME}/bin/re2c" re2c --version exit 0 From 28008605fedc8c342490b4fa81484b759a32f3e3 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 12:30:21 +0300 Subject: [PATCH 14/17] Amended suppression file for PHP 7.4 [skip appveyor] --- tests/php-7.4.supp | 59 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/tests/php-7.4.supp b/tests/php-7.4.supp index b86b1347..f9ffd1c7 100644 --- a/tests/php-7.4.supp +++ b/tests/php-7.4.supp @@ -5,7 +5,8 @@ fun:zend_string_equal_content fun:zend_interned_string_ht_lookup ... - fun:zend_compile_dim + fun:zend_startup_modules + ... } { @@ -15,7 +16,7 @@ fun:zend_string_equal_content fun:zend_interned_string_ht_lookup ... - fun:zend_compile_top_stmt + fun:zend_compile_dim } { @@ -25,7 +26,7 @@ fun:zend_string_equal_content fun:zend_interned_string_ht_lookup ... - fun:zend_delayed_compile_var + fun:zend_compile_top_stmt } { @@ -35,7 +36,7 @@ fun:zend_string_equal_content fun:zend_interned_string_ht_lookup ... - fun:zend_compile_var + fun:zend_delayed_compile_var } { @@ -43,13 +44,23 @@ Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + ... + fun:zend_compile_var +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content ... fun:php_cli_startup ... } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -60,7 +71,41 @@ } { - + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_hash_find_bucket + ... + fun:OnUpdate_mbstring_encoding_translation + ... + fun:php_module_startup +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_interned_string_ht_lookup + ... + fun:date_register_classes + ... + fun:php_module_startup +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content + fun:zend_hash_find_bucket + ... + fun:compile_file +} + +{ + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -72,7 +117,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content From c1f83e8fbd2bd1838a9354f993a09d66f6ac1a5c Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 14:07:27 +0300 Subject: [PATCH 15/17] Amended suppression file for PHP 7.4 [skip appveyor] --- tests/php-7.4.supp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/php-7.4.supp b/tests/php-7.4.supp index f9ffd1c7..04843801 100644 --- a/tests/php-7.4.supp +++ b/tests/php-7.4.supp @@ -34,13 +34,24 @@ Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content + fun:zend_hash_find_bucket + fun:zend_hash_find + ... + fun:zend_compile_top_stmt +} + +{ + + Memcheck:Cond + fun:zend_string_equal_val + fun:zend_string_equal_content fun:zend_interned_string_ht_lookup ... fun:zend_delayed_compile_var } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -50,7 +61,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -60,7 +71,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -71,7 +82,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -83,7 +94,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -95,7 +106,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -105,7 +116,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content @@ -117,7 +128,7 @@ } { - + Memcheck:Cond fun:zend_string_equal_val fun:zend_string_equal_content From e8b7ab167a92bda19b4d8af1c69d158622b7f002 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 16:45:24 +0300 Subject: [PATCH 16/17] Improved clean targets [skip appveyor] --- parser.mk | 15 +++++++-------- tests/.gitignore | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/parser.mk b/parser.mk index ad79262c..edd6665a 100644 --- a/parser.mk +++ b/parser.mk @@ -13,19 +13,20 @@ clean: parser-clean tests-clean .PHONY: parser-clean parser-clean: - find . -name \*.loT -o -name \*.out | xargs rm -f + find . \( -name '*.loT' -o -name '*.out' \) -exec rm -f {} + find ./parser \ - -name zephir.c \ + \( -name zephir.c \ -o -name zephir.h \ -o -name scanner.c \ - -o -name parser.c | xargs rm -f + -o -name parser.c \) -exec rm -f {} + .PHONY: tests-clean tests-clean: - find ./tests -name \*.php -o -name \*.sh | xargs rm -f - find ./tests -name \*.diff -o -name \*.exp -o -name \*.log | xargs rm -f - find ./tests -name \*.tmp | xargs rm -f + find ./tests \( -name '*.php' -o -name '*.sh' \) -exec rm -f {} + + find ./tests \( -name '*.diff' -o -name '*.exp' \) -exec rm -f {} + + find ./tests \( -name '*.tmp' -o -name '*.mem' \) -exec rm -f {} + + find ./tests -name '*.log' -exec rm -f {} + .PHONY: maintainer-clean maintainer-clean: @@ -33,8 +34,6 @@ maintainer-clean: @echo 'deletes files that may need special tools to rebuild.' @echo -rm -f $(srcdir)/parser/lemon - -rm -f $(srcdir)/parser/scanner.c - -rm -f $(srcdir)/parser/parser.c $(srcdir)/parser/scanner.c: $(srcdir)/parser/scanner.re $(RE2C) $(RE2C_FLAGS) -d --no-generation-date -o $@ $< diff --git a/tests/.gitignore b/tests/.gitignore index 12f04a44..25420e2c 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -4,3 +4,4 @@ *.diff *.php *.log +*.mem From 00cf312a8a4f4019d50b29f33f94a29581598b3b Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2019 17:43:49 +0300 Subject: [PATCH 17/17] Amended lemon docs [skip appveyor] --- parser/zephir.lemon | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/parser/zephir.lemon b/parser/zephir.lemon index 7551ea11..29b60b25 100644 --- a/parser/zephir.lemon +++ b/parser/zephir.lemon @@ -8,19 +8,36 @@ * the LICENSE file that was distributed with this source code. */ +// All token codes are small integers with #defines that begin with "XX_" %token_prefix XX_ + +// The type of the data attached to each token is xx_parser_token. %token_type {xx_parser_token*} + +// Default type for non-terminals is zval. %default_type {zval} + +// The generated parser function takes a 4th argument as follows: +%extra_argument {xx_parser_status *status} + %default_destructor { if (&$$) { zval_ptr_dtor(&$$); } } -%extra_argument {xx_parser_status *status} + +// The name of the generated procedure that implements the parser +// is as follows: %name xx_ +// Define operator precedence early so that this is the first occurrence +// of the operator tokens in the grammer. Keeping the operators together +// causes them to be assigned integer values that are close together, +// which keeps parser tables smaller. +// +// The token values assigned to these symbols is determined by the order +// in which lemon first sees them. %left INTERNAL PUBLIC PROTECTED STATIC PRIVATE SCOPED . - %left COMMA . %right REQUIRE . %right DOUBLEARROW . @@ -45,16 +62,18 @@ %right SBRACKET_OPEN . %right ARROW . +// The following text is included near the beginning of the C source +// code file that implements the parser. %include { #include "parser.h" } +// end %include +// This code runs whenever there is a syntax error %syntax_error { - zval syntax_error; array_init(&syntax_error); - parser_add_str(&syntax_error, "type", "error"); if (status->scanner_state->start_length) { @@ -80,7 +99,7 @@ } } -program ::= xx_language(Q) . { +input ::= xx_language(Q) . { status->ret = Q; }