Automated testing of PHP7 extensions

Source: Internet
Author: User
Tags egrep
In the process of installing PHP7 and various extensions, if you are installing with the source code, you will notice that after make is successful there is always a hint: Don ' t forget to run ' makes test '. This make test is the automated test that runs PHP.

If you have just installed PHP7, run make test directly, after a long wait time, the final statistic is probably this:

There will be so many skip and fail instructions for some extensions you don't have to install, and the configuration of the relevant environment also needs to be optimized

But in general we don't need to run so many test scripts, especially for a single extension, to test for the relevant interfaces, so let's take a closer look at how to run the test scripts independently

First open the PHP makefile file and let's see what make test did.

Test:all @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 \ $ (EGREP)-h-v $ (Php_deprecated_directives_regex) "$ $INI _file" > $ (Top_builddir)/tmp-php. Ini \ Else \ Echo > $ (top_builddir)/tmp-php.ini; \ fi; \ ini_scanned_path= ' $ (php_executable)-d ' display_errors=stderr '-r ' $ $a = explode ("\ n", Trim (php_ini_scan Ned_files ())); echo $ $a [0]; ' 2>/dev/null '; \ if test "$ $INI _scanned_path"; Then \ ini_scanned_path= ' $ (top_srcdir)/build/shtool path-d $ $INI _scanned_path '; \ $ (EGREP)-h-v $ (Php_deprecated_directives_regex) "$ $INI _scanned_path"/*.ini >> $ (top_build dir)/tmp-php.ini; \ fi; \ test_php_executable=$ (php_executable) \ test_php_srcdir=$ (top_srcdir) \ cc= "$ (CC)" \ $ (php_executable)-n-c $ (top_builddir)/tmp-php.ini $ (php_test_settings) $ (top_srcdir)/run-tests.php-n-C $ (Top_bui Lddir)/tmp-php.ini-d extensi/modules/$ (php_test_shared_extensions) $ (TESTS); \ test_result_exit_code=$$?; \ RM $ (top_builddir)/tmp-php.ini; \ Exit $ $TEST _result_exit_code; \ Else \ echo "Error:cannot Run Tests without CLI SAPI."; \ Fi

Without the definition of those variables, the core is the following sentence

$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extensi/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS);

The original automatic test is done by executing the PHP source root directory under the run-tests.php, test scripts are generally placed in the tests folder

We casually open the PHP installation directory under the./tests/basic, there are some PHPT files, this is a test script

Some of the script content is simple, the content in 001.phpt is like this

--TEST--Trivial "Hello World" test--FILE--
  
   --EXPECT--Hello World

Now let's just run 001.PHPT and try it.
First, set the relevant environment variables, specify the object to be tested PHP, where the landlord uses the installation path under the
Php

Export test_php_executable=/usr/local/php7/bin/php

Then execute it under the PHP installation root directory

PHP run-tests.php./tests/basic/001.phpt

Without an accident, you can get the following results.

So we can write a script later to specify the PHPT to test, and to count the final results.

OneAPM for PHP is able to drill down into all of the PHP applications to perform application performance management in-depth application performance management and monitoring within all PHP applications, including code-level visibility, rapid identification and traceability of performance bottlenecks, real user experience monitoring, Server monitoring and end-to-end application performance management. To read more technical articles, please visit the OneAPM Official technology blog.

This article was transferred from OneAPM official blog

The above describes the PHP7 extension of the automated testing, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.