Problem/Motivation

In #2312191: Change Simpletest UI from a test runner to a CLI snippet generator we're thinking about removing the simpletest ui. Users need a simple way to consume the test results and look at any pages generated by the test.

Proposed resolution

This patch allows the user to add a --browser flag to run-tests that opens the result in a browser window. If you are --verbose then you'll get the same verbose output as through the UI with the ability to look at pages that are generated by the test.

Remaining tasks

The current patch just uses the existing route in the Simpletest UI - it's the simpletest solution. Potentially we could save this output to html to and therefore not require a running Drupal to display results.

User interface changes

None

API changes

None

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because we are adding a feature.
Issue priority Normal because this is a nice-to-have feature.
Unfrozen changes Unfrozen because it changes the only test system.
Disruption Not disruptive because it is an optional new command-line feature that doesn't affect operation in other modes.

Comments

alexpott’s picture

First implementation... to test:

php ./core/scripts/run-tests.sh --url http://WHATEVER_YOU_USE --verbose --browser --concurrency 4 --module content_translation

(yep concurrent tests and opening results in a browser - how sweet is that!)

alexpott’s picture

StatusFileSize
new6.47 KB
new4.03 KB

New patch to fix a couple of things so that tests are still cleared once you've viewed the results - just duplicating the behaviour of the UI.

dawehner’s picture

Two problems: the browser did not opened (haven't debugged it but i guess you should check for shell_exec == 0?).
Sadly I also don't see the test to finish, there seems to be a blocking process.

  1. +++ b/core/scripts/run-tests.sh
    @@ -1059,3 +1073,30 @@ function simpletest_script_color_code($status) {
    +function simpletest_script_open_browser() {
    +  global $args, $test_ids;
    

    It would be great to just pass this as parameters ... but yeah not important.

  2. +++ b/core/scripts/run-tests.sh
    @@ -1059,3 +1073,30 @@ function simpletest_script_color_code($status) {
    +  else if (shell_exec('which open')) {
    ...
    +  }
    +  else if (substr(PHP_OS, 0, 3) == 'WIN') {
    

    ha, even a core committer does code style mistakes: else if => elseif (yes I do hate this policy)

alexpott’s picture

StatusFileSize
new4.5 KB
new8.74 KB

@dawehner
1. This is how all the other functions in run-tests.sh
2. lol that'll teach me for copying and pasting from Drush :)

Latest patch removes dependency on parent test site actually existing.

php ./core/scripts/run-tests.sh --sqlite /tmp/coretest.sqlite --dburl mysql://username:password@localhost/database_name --color --url SOME_VALID_URL_WITH_DRUPAL_CHECKEDOUT --verbose --browser --class 'Drupal\content_translation\Tests\ContentTranslationWorkflowsTest'

Status: Needs review » Needs work

The last submitted patch, 4: 2315791.4.patch, failed testing.

cilefen’s picture

Status: Needs work » Needs review

Rerolled. If you use --browser in this version, you get:

PHP Fatal error:  Uncaught exception 'Symfony\Component\Routing\Exception\RouteNotFoundException' in /Library/WebServer/Documents/drupal8x/core/lib/Drupal/Core/Routing/NullGenerator.php:47
Stack trace:
#0 /Library/WebServer/Documents/drupal8x/core/lib/Drupal/Core/Routing/UrlGenerator.php(151): Drupal\Core\Routing\NullGenerator->getRoute('simpletest.resu...')
#1 /Library/WebServer/Documents/drupal8x/core/lib/Drupal.php(509): Drupal\Core\Routing\UrlGenerator->generateFromRoute('simpletest.resu...', Array, Array)
#2 /Library/WebServer/Documents/drupal8x/core/modules/simpletest/src/Form/SimpletestResultsForm.php(212): Drupal::url('simpletest.resu...', Array)
#3 /Library/WebServer/Documents/drupal8x/core/scripts/run-tests.sh(1193): Drupal\simpletest\Form\SimpletestResultsForm->buildForm(Array, Object(Drupal\Core\Form\FormState), '3')
#4 /Library/WebServer/Documents/drupal8x/core/scripts/run-tests.sh(96): simpletest_script_open_browser()
#5 {main}
  thrown in /Library/WebServer/Documents/drupal8x/core/lib/Drupal/Core/Routing/NullGenerator.php on line 47

Fatal error: Uncaught exception 'Symfony\Component\Routing\Exception\RouteNotFoundException' in /Library/WebServer/Documents/drupal8x/core/lib/Drupal/Core/Routing/NullGenerator.php:47
Stack trace:
#0 /Library/WebServer/Documents/drupal8x/core/lib/Drupal/Core/Routing/UrlGenerator.php(151): Drupal\Core\Routing\NullGenerator->getRoute('simpletest.resu...')
#1 /Library/WebServer/Documents/drupal8x/core/lib/Drupal.php(509): Drupal\Core\Routing\UrlGenerator->generateFromRoute('simpletest.resu...', Array, Array)
#2 /Library/WebServer/Documents/drupal8x/core/modules/simpletest/src/Form/SimpletestResultsForm.php(212): Drupal::url('simpletest.resu...', Array)
#3 /Library/WebServer/Documents/drupal8x/core/scripts/run-tests.sh(1193): Drupal\simpletest\Form\SimpletestResultsForm->buildForm(Array, Object(Drupal\Core\Form\FormState), '3')
#4 /Library/WebServer/Documents/drupal8x/core/scripts/run-tests.sh(96): simpletest_script_open_browser()
#5 {main}
  thrown in /Library/WebServer/Documents/drupal8x/core/lib/Drupal/Core/Routing/NullGenerator.php on line 47
cilefen’s picture

StatusFileSize
new7.65 KB
cilefen’s picture

Status: Needs review » Needs work

@alexpott suggests adding a static method to SimpletestResultsForm that returns the form parts needed in run-tests.sh and also call it in SimpletestResultsForm::buildForm().

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new16.13 KB

Something like this...

dawehner’s picture

Manually tested the patch, that is really cool, it works for me!

+++ b/core/modules/simpletest/src/Form/SimpletestResultsForm.php
@@ -58,37 +59,37 @@ public function __construct(Connection $database) {
-      '#alt' => $this->t('Pass'),
+      '#alt' => $translation->translate('Pass'),
...
-      '#alt' => $this->t('Fail'),
+      '#alt' => $translation->translate('Fail'),
...
-      '#alt' => $this->t('Exception'),
+      '#alt' => $translation->translate('Exception'),

Mh, isn't the point of this ->t function that potx can scan them? Maybe we need a static wrapper for t?

alexpott’s picture

I think we should just remove all the translation here. Because none of the assertions are translated so what's the point?

cilefen’s picture

#9 works for me too. The results styling could be better themed.

cilefen’s picture

Issue summary: View changes
alexpott’s picture

StatusFileSize
new15.85 KB
new6.22 KB

Discussed with @GaborHojtsy in IRC - we agreed that translation here was pointless because assertions are not translated.

18:22 GaborHojtsy
alexpott: yeah looks like its only a few strings
18:23 GaborHojtsy
alexpott: looks to me its a good tradeoff, feel free
18:23 GaborHojtsy
alexpott: to remove :)

Wrt to #12. I guess we could include seven's styles but that feels quite heavy and icky.

cilefen’s picture

Issue summary: View changes
StatusFileSize
new241.92 KB

It is very plain as compared to the UI form.

cilefen’s picture

Also I just noticed that on Firefox, the disclosure triangle is missing and its function doesn't work but it does work in Chrome. The web console is not really helpful on why.

alexpott’s picture

StatusFileSize
new2.99 KB
new16.3 KB

Fixed firefox.

cilefen’s picture

@alexpott Agreed - fixed!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/scripts/run-tests.sh
@@ -291,6 +305,10 @@ function simpletest_script_parse_args() {
+  //

Pure lonely comment :P

webchick’s picture

Status: Reviewed & tested by the community » Fixed

This seems useful to help with debugging. Removed the phantom comment.

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 488f558 on 8.0.x
    Issue #2315791 by alexpott, cilefen, dawehner: Add functionality to open...
cilefen’s picture

Version: 8.0.x-dev » 7.x-dev
Status: Fixed » Patch (to be ported)
Issue tags: +Needs backport to D7

Let's backport this.

  • webchick committed 488f558 on 8.1.x
    Issue #2315791 by alexpott, cilefen, dawehner: Add functionality to open...

  • webchick committed 488f558 on 8.3.x
    Issue #2315791 by alexpott, cilefen, dawehner: Add functionality to open...

  • webchick committed 488f558 on 8.3.x
    Issue #2315791 by alexpott, cilefen, dawehner: Add functionality to open...

  • webchick committed 488f558 on 8.4.x
    Issue #2315791 by alexpott, cilefen, dawehner: Add functionality to open...

  • webchick committed 488f558 on 8.4.x
    Issue #2315791 by alexpott, cilefen, dawehner: Add functionality to open...

Status: Patch (to be ported) » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.