Skip to content
Snippets Groups Projects
Verified Commit c22e5e6b authored by Dave Long's avatar Dave Long
Browse files

Issue #3483931 by mondrake: [CI] Use testdox and colors in tests spawned by run-tests.sh

(cherry picked from commit 6e60f0b5)
parent 2573842c
No related branches found
No related tags found
21 merge requests!11515Issue #3480419 by mondrake, smustgrave, catch: Method...,!11380Issue #3490698 by catch, spokje: Bump MINIMUM_STABILITY back to 'stable' when...,!11239Issue #3507548: Allow workspace changes listing to show all items, without a pager,!11238Fix issue #3051797,!11213Issue #3506743 by tomislav.matokovic: Increasing the color contrast for the navigation block title against the background of the navigation sidebar to at least 4.5:1,!11147Draft: Try to avoid manually setting required cache contexts,!11108Issue #3490298 by nicxvan: Profiles can be missed in OOP hooks,!11093Drupal on MongoDB 11.1.x,!11017Issue #3502540: Add date filter for moderated content.,!11009Issue #3486972 migrate feed icon,!10999Cleaning up Taxonomy hooks and updating baseline.,!10977Issue #3501457: Fix path used in a A11y Test Admin,!10881Issue #3489329 by mfb, casey: symfony/http-foundation commit 32310ff breaks PathValidator,!10570Issue #3494197: Convert Twig engine hooks,!10567Issue #3494154: Index is not added if entity doesn't support revisions,!10548Revert "Issue #3478621 by catch, longwave, nicxvan: Add filecache to OOP hook attribute parsing",!10404Margin has been added,!10391Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10388Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10376Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10237Issue #3484105 by nicxvan, godotislate: Automatically included .inc files are no longer included
Pipeline #336409 passed
Pipeline: drupal

#336411

    ...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
    use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
    use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
    // cspell:ignore testdox
    /** /**
    * Run PHPUnit-based tests. * Run PHPUnit-based tests.
    * *
    ...@@ -100,16 +102,24 @@ public function phpUnitCommand(): string { ...@@ -100,16 +102,24 @@ public function phpUnitCommand(): string {
    * A fully qualified test class name. * A fully qualified test class name.
    * @param string $log_junit_file_path * @param string $log_junit_file_path
    * A filepath to use for PHPUnit's --log-junit option. * A filepath to use for PHPUnit's --log-junit option.
    * @param int $status * @param int|null $status
    * (optional) The exit status code of the PHPUnit process will be assigned * (optional) The exit status code of the PHPUnit process will be assigned
    * to this variable. * to this variable.
    * @param string[] $output * @param string[]|null $output
    * (optional) The output by running the phpunit command. If provided, this * (optional) The output by running the phpunit command. If provided, this
    * array will contain the lines output by the command. * array will contain the lines output by the command.
    * @param bool $colors
    * (optional) Whether to use colors in output. Defaults to FALSE.
    * *
    * @internal * @internal
    */ */
    protected function runCommand(string $test_class_name, string $log_junit_file_path, ?int &$status = NULL, ?array &$output = NULL): void { protected function runCommand(
    string $test_class_name,
    string $log_junit_file_path,
    ?int &$status = NULL,
    ?array &$output = NULL,
    bool $colors = FALSE,
    ): void {
    global $base_url; global $base_url;
    // Setup an environment variable containing the database connection so that // Setup an environment variable containing the database connection so that
    // functional tests can connect to the database. // functional tests can connect to the database.
    ...@@ -130,9 +140,13 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa ...@@ -130,9 +140,13 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa
    // Build the command line for the PHPUnit CLI invocation. // Build the command line for the PHPUnit CLI invocation.
    $command = [ $command = [
    $phpunit_bin, $phpunit_bin,
    '--testdox',
    '--log-junit', '--log-junit',
    $log_junit_file_path, $log_junit_file_path,
    ]; ];
    if ($colors) {
    $command[] = '--colors=always';
    }
    // If the deprecation handler bridge is active, we need to fail when there // If the deprecation handler bridge is active, we need to fail when there
    // are deprecations that get reported (i.e. not ignored or expected). // are deprecations that get reported (i.e. not ignored or expected).
    ...@@ -159,9 +173,11 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa ...@@ -159,9 +173,11 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa
    * The test run object. * The test run object.
    * @param string $test_class_name * @param string $test_class_name
    * A fully qualified test class name. * A fully qualified test class name.
    * @param int $status * @param int|null $status
    * (optional) The exit status code of the PHPUnit process will be assigned * (optional) The exit status code of the PHPUnit process will be assigned
    * to this variable. * to this variable.
    * @param bool $colors
    * (optional) Whether to use colors in output. Defaults to FALSE.
    * *
    * @return array * @return array
    * The parsed results of PHPUnit's JUnit XML output, in the format of * The parsed results of PHPUnit's JUnit XML output, in the format of
    ...@@ -169,11 +185,16 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa ...@@ -169,11 +185,16 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa
    * *
    * @internal * @internal
    */ */
    public function execute(TestRun $test_run, string $test_class_name, ?int &$status = NULL): array { public function execute(
    TestRun $test_run,
    string $test_class_name,
    ?int &$status = NULL,
    bool $colors = FALSE,
    ): array {
    $log_junit_file_path = $this->xmlLogFilePath($test_run->id()); $log_junit_file_path = $this->xmlLogFilePath($test_run->id());
    // Store output from our test run. // Store output from our test run.
    $output = []; $output = [];
    $this->runCommand($test_class_name, $log_junit_file_path, $status, $output); $this->runCommand($test_class_name, $log_junit_file_path, $status, $output, $colors);
    if ($status == TestStatus::PASS) { if ($status == TestStatus::PASS) {
    return JUnitConverter::xmlToRows($test_run->id(), $log_junit_file_path); return JUnitConverter::xmlToRows($test_run->id(), $log_junit_file_path);
    ......
    ...@@ -829,9 +829,11 @@ function simpletest_script_execute_batch(TestRunResultsStorageInterface $test_ru ...@@ -829,9 +829,11 @@ function simpletest_script_execute_batch(TestRunResultsStorageInterface $test_ru
    * Run a PHPUnit-based test. * Run a PHPUnit-based test.
    */ */
    function simpletest_script_run_phpunit(TestRun $test_run, $class) { function simpletest_script_run_phpunit(TestRun $test_run, $class) {
    global $args;
    $runner = PhpUnitTestRunner::create(\Drupal::getContainer()); $runner = PhpUnitTestRunner::create(\Drupal::getContainer());
    $start = microtime(TRUE); $start = microtime(TRUE);
    $results = $runner->execute($test_run, $class, $status); $results = $runner->execute($test_run, $class, $status, $args['color']);
    $time = microtime(TRUE) - $start; $time = microtime(TRUE) - $start;
    $runner->processPhpUnitResults($test_run, $results); $runner->processPhpUnitResults($test_run, $results);
    ...@@ -1369,7 +1371,7 @@ function simpletest_script_format_result($result) { ...@@ -1369,7 +1371,7 @@ function simpletest_script_format_result($result) {
    if ($args['non-html']) { if ($args['non-html']) {
    $message = Html::decodeEntities($message); $message = Html::decodeEntities($message);
    } }
    $lines = explode("\n", wordwrap($message), 76); $lines = explode("\n", $message);
    foreach ($lines as $line) { foreach ($lines as $line) {
    echo " $line\n"; echo " $line\n";
    } }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment