]> granicus.if.org Git - php/commitdiff
run-tests: echo message and exit if no tests found
authorGerard Roche <gerardroche@users.noreply.github.com>
Wed, 20 May 2020 15:45:14 +0000 (16:45 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 22 May 2020 07:37:46 +0000 (09:37 +0200)
The test runner currently defaults to running the entire test suite if
no selected tests can be found. This can be unexpected.

For example the ext/mysqlnd/ directory has no tests, if you specify that
directory when testing the entire test suite will be run.

    run-tests.php [options] ext/mysqlnd/

Closes GH-5605.

run-tests.php

index d14fcafeeed24314cb7a95be09465910d1eea37f..51a82aad64cf980cb518c80ffa55cf3b89609e07 100755 (executable)
@@ -394,6 +394,7 @@ NO_PROC_OPEN_ERROR;
     $temp_urlbase = null;
     $conf_passed = null;
     $no_clean = false;
+    $selected_tests = false;
     $slow_min_ms = INF;
     $preload = false;
     $file_cache = null;
@@ -634,6 +635,7 @@ NO_PROC_OPEN_ERROR;
         }
 
         if (!$is_switch) {
+            $selected_tests = true;
             $testfile = realpath($argv[$i]);
 
             if (!$testfile && strpos($argv[$i], '*') !== false && function_exists('glob')) {
@@ -664,6 +666,11 @@ NO_PROC_OPEN_ERROR;
         }
     }
 
+    if ($selected_tests && count($test_files) === 0) {
+        echo "No tests found.\n";
+        return;
+    }
+
     // Default to PHP_BINARY as executable
     if (!isset($environment['TEST_PHP_EXECUTABLE'])) {
         $php = PHP_BINARY;