]> git.openstreetmap.org Git - nominatim.git/commitdiff
remove support for PHP code coverage in BDD tests
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 30 Jul 2024 13:43:41 +0000 (15:43 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 31 Jul 2024 09:16:49 +0000 (11:16 +0200)
docs/develop/Testing.md
test/bdd/environment.py
test/bdd/steps/cgi-with-coverage.php [deleted file]
test/bdd/steps/nominatim_environment.py
test/bdd/steps/steps_api_queries.py

index aeaca2ee818a84addcae57dc60e9388f03277c11..c220f4e4e1f80f9a3ee6cbb5473ff004b1a18384 100644 (file)
@@ -121,23 +121,6 @@ and compromises the following data:
 API tests should only be testing the functionality of the website PHP code.
 Most tests should be formulated as BDD DB creation tests (see below) instead.
 
-#### Code Coverage (PHP engine only)
-
-The API tests also support code coverage tests. You need to install
-[PHP_CodeCoverage](https://github.com/sebastianbergmann/php-code-coverage).
-On Debian/Ubuntu run:
-
-    apt-get install php-codecoverage php-xdebug
-
-Then run the API tests as follows:
-
-    behave api -DPHPCOV=<coverage output dir>
-
-The output directory must be an absolute path. To generate reports, you can use
-the [phpcov](https://github.com/sebastianbergmann/phpcov) tool:
-
-    phpcov merge --html=<report output dir> <coverage output dir>
-
 ### DB Creation Tests (`test/bdd/db`)
 
 These tests check the import and update of the Nominatim database. They do not
index 6aec8f597a39dcf5676197fb3288589ea1118561..155b8d90a01fd18614481e5f22452011d5262f34 100644 (file)
@@ -30,8 +30,7 @@ userconfig = {
     'SERVER_MODULE_PATH' : None,
     'TOKENIZER' : None, # Test with a custom tokenizer
     'STYLE' : 'extratags',
-    'API_ENGINE': 'falcon',
-    'PHPCOV' : False, # set to output directory to enable code coverage
+    'API_ENGINE': 'falcon'
 }
 
 use_step_matcher("re")
diff --git a/test/bdd/steps/cgi-with-coverage.php b/test/bdd/steps/cgi-with-coverage.php
deleted file mode 100644 (file)
index dbd8993..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-require_once 'SebastianBergmann/CodeCoverage/autoload.php';
-
-
-function coverage_shutdown($oCoverage)
-{
-    $oCoverage->stop();
-    $writer = new \SebastianBergmann\CodeCoverage\Report\PHP;
-    $writer->process($oCoverage, $_SERVER['PHP_CODE_COVERAGE_FILE']);
-}
-
-$covfilter = new SebastianBergmann\CodeCoverage\Filter();
-if (method_exists($covfilter, 'addDirectoryToWhitelist')) {
-    // pre PHPUnit 9
-    $covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/lib-php');
-    $covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/website');
-    $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(null, $covfilter);
-} else {
-    // since PHP Uit 9
-    $covfilter->includeDirectory($_SERVER['COV_PHP_DIR'].'/lib-php');
-    $covfilter->includeDirectory($_SERVER['COV_PHP_DIR'].'/website');
-    $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(
-        (new SebastianBergmann\CodeCoverage\Driver\Selector)->forLineCoverage($covfilter),
-        $covfilter
-    );
-}
-
-$coverage->start($_SERVER['COV_TEST_NAME']);
-
-register_shutdown_function('coverage_shutdown', $coverage);
-
-include $_SERVER['COV_SCRIPT_FILENAME'];
index 88a4f11c73ebc5ec135b0443660cce3f14753731..c4b055885d1a61211190d227e47eaef57d9d206c 100644 (file)
@@ -37,8 +37,6 @@ class NominatimEnvironment:
         self.server_module_path = config['SERVER_MODULE_PATH']
         self.reuse_template = not config['REMOVE_TEMPLATE']
         self.keep_scenario_db = config['KEEP_TEST_DB']
-        self.code_coverage_path = config['PHPCOV']
-        self.code_coverage_id = 1
 
         self.default_config = Configuration(None).get_os_env()
         self.test_env = None
@@ -70,13 +68,6 @@ class NominatimEnvironment:
             dbargs['password'] = self.db_pass
         return psycopg.connect(**dbargs)
 
-    def next_code_coverage_file(self):
-        """ Generate the next name for a coverage file.
-        """
-        fn = Path(self.code_coverage_path) / "{:06d}.cov".format(self.code_coverage_id)
-        self.code_coverage_id += 1
-
-        return fn.resolve()
 
     def write_nominatim_config(self, dbname):
         """ Set up a custom test configuration that connects to the given
index aa1b43b8493d387a7323c1fc5ff6b67eb5e7e53e..93501e42c756c3aa24f07a93c40e356e07e7e13e 100644 (file)
@@ -114,18 +114,7 @@ def send_api_query_php(endpoint, params, context):
         for k, v in context.http_headers.items():
             env['HTTP_' + k.upper().replace('-', '_')] = v
 
-    cmd = ['/usr/bin/env', 'php-cgi', '-f']
-    if context.nominatim.code_coverage_path:
-        env['XDEBUG_MODE'] = 'coverage'
-        env['COV_SCRIPT_FILENAME'] = env['SCRIPT_FILENAME']
-        env['COV_PHP_DIR'] = context.nominatim.src_dir
-        env['COV_TEST_NAME'] = f"{context.scenario.filename}:{context.scenario.line}"
-        env['SCRIPT_FILENAME'] = \
-                os.path.join(os.path.split(__file__)[0], 'cgi-with-coverage.php')
-        cmd.append(env['SCRIPT_FILENAME'])
-        env['PHP_CODE_COVERAGE_FILE'] = context.nominatim.next_code_coverage_file()
-    else:
-        cmd.append(env['SCRIPT_FILENAME'])
+    cmd = ['/usr/bin/env', 'php-cgi', '-f', env['SCRIPT_FILENAME']]
 
     for k,v in params.items():
         cmd.append(f"{k}={v}")