Problem/Motivation
In #3057420: [meta] How to deprecate Simpletest with minimal disruption we are contemplating making simpletest a contrib module.
That issue has many steps involved in decoupling run-tests.sh (the test runner) from simpletest module. This issue is one of those steps.
Note that run-tests.sh can already be run without the simpletest module installed in a site: https://www.drupal.org/docs/8/phpunit/running-tests-through-command-line...
Scope of this issue
h
The scope of this issue is to decouple run-tests.sh from the simpletest module. This will allow current behavior from run-tests.sh even if the simpletest module itself is removed from the codebase. As a child issue of #3057420: [meta] How to deprecate Simpletest with minimal disruption, we wish to do this with minimal disruption.
Some proof of concept for removing the simpletest module is occurring in #3075490-28: Move simpletest module to contrib
Things we’ll need to solve
run-tests.sh uses logic like this in order to figure out how to run tests it discovers:
foreach ($matches[1] as $class_name) {
$namespace_class = $namespace . '\\' . $class_name;
if (is_subclass_of($namespace_class, '\Drupal\simpletest\TestBase') || is_subclass_of($namespace_class, TestCase::class)) {
$test_list[] = $namespace_class;
}
}
We want to make \Drupal\simpletest\TestBase
a soft dependency, so that run-tests.sh can operate completely independently of the simpletest module.
Proposed resolution
Remove code-based assumptions from run-tests.sh that there are two types of tests, and if a test class is not a PHPUnit test, then it must be a simpletest-based one.
Deprecate simpletest_script_open_browser()
and --browser
option in Drupal 8 and remove this in Drupal 9. All the internal functionality of simpletest_script_open_browser()
is moved to simpletest.module as it is completely dependent on it.
Recommend using --verbose instead of --browser in the deprecation message. --verbose already provides links to stored HTML output, it just doesn't open the browser for you.
Remaining tasks
Other remaining issues from #3057420: [meta] How to deprecate Simpletest with minimal disruption
Eventually remove the simpletest module #3075490: Move simpletest module to contrib
User interface changes
None
API changes
simpletest_script_open_browser() is deprecated.
Data model changes
None
Release notes snippet
The --browser
option in run-tests.sh has been deprecated in favor of --verbose.
Comment | File | Size | Author |
---|---|---|---|
#76 | 3074433-3-76.patch | 11.83 KB | alexpott |
#76 | 74-76-interdiff.txt | 2.5 KB | alexpott |
#74 | 3074433-3-74.patch | 11.65 KB | alexpott |
#74 | 71-74-interdiff.txt | 704 bytes | alexpott |
#71 | 3074433-3-71.patch | 11.65 KB | alexpott |
Comments
Comment #2
Mile23Immediately postponed on decisions from #3057420: [meta] How to deprecate Simpletest with minimal disruption
Comment #3
Mile23Comment #4
Mile23Still waiting on #3057420: [meta] How to deprecate Simpletest with minimal disruption, but here's a patch. Change back to postponed after this test run.
Note that we're also soft-blocked here by #2863055: Move TestDiscovery out of simpletest module, minimize dependencies because the form builder uses the test_discovery service.
We'll also need to modify
TestDiscovery
to allow for the non-existence ofDrupal\simpletest\TestBase
, but that can be a follow-up.Comment #5
Mile23Setting back to postponed.
Comment #6
Mile23Unpostponing based on #3057420-17: [meta] How to deprecate Simpletest with minimal disruption
Comment #7
volegerAll changes looks good for me, but found the following one:
Should be there a space before unary operator statement?
Comment #8
Mile23Thanks, @voleger.
Fixed CS from #7.
Comment #9
volegerGreat!
+1 for rtbc
Comment #10
Mile23Committing this will require a reroll in #2863055: Move TestDiscovery out of simpletest module, minimize dependencies (or vice-versa). See #4. Totally OK with either way. :-)
Comment #11
Mile23Needs reroll after #2863055: Move TestDiscovery out of simpletest module, minimize dependencies
Also needs some love when it comes to the display-oriented functions in simpletest.module:
Also _simpletest_format_summary_line() is dead code.
Comment #12
Mile23Copies simpletest's result summary twig template to be an
#inline_template
inRunTestsResultsBuilder
.We leave the theming functions and template behind because they're also used by the UI batch runner, where they'll live in contrib or be removed in that process.
Removes
_simpletest_format_summary_line()
which is a) dead code and b) internal due to prefix underscore.Comment #14
Mile23...in which I learn some twig so that the testception of
SimpleTestTest
can pass.Comment #16
Mile23So the fails in #14 are really hard to track down. The fail is
SimpletestUiTest
, which runs three tests through the UI form: kernel, unit, and functional.The kernel test passes, but the unit and functional test don't, because the twig template renders differently in those two for some reason. I think there's probably a service container mixup at some point in those frameworks.
So therefore Twig's
{% trans %}{% plural %}{% endtrans %}
pattern won't help us pass tests even though it's really the best solution. So we refactor_simpletest_build_summary_line()
to be used byRunTestsResultsBuilder
.This new theming code is not used by the batch runner, but is used by the UI results form. Converting the batch runner is out of scope here since our focus is run-tests.sh, but I added a
@todo
.Marked
RunTestsResultsBuilder
as@internal
. We can un-@internal
whatever parts we need as a stable API for contrib simpletest module in #3075490: Move simpletest module to contrib.Comment #17
Mile23Needed a reroll.
Comment #18
Mile23This is a child issue of a critical meta: #3057420: [meta] How to deprecate Simpletest with minimal disruption
Comment #19
Mile23Needed reroll after #2800267: Turn simpletest_clean*() functions into a helper class
Comment #21
Mile23Reran tests after spurious fail.
Comment #22
Mile23Postponed on some refactoring occurring in #2913819: run-tests.sh ignores final classes
Comment #23
catchComment #24
Mile23Reroll after #2913819: run-tests.sh ignores final classes
Comment #25
Mile23The NF tag here is from #4 and refers to modifying
TestDiscovery
so that it doesn't have a hard dependency onTestBase
/WebTestBase
. As it turns out,TestDiscovery
deduces that if a test class doesn't belong to a suite, it's a simpletest test, so it doesn't have that hard dependency.It does, however, parse out and handle @requires annotations for simpletest tests, with a @todo for #1273478: Implement @requires and @dependencies within TestBase, mark tests as skipped
That issue is not required in order to deprecate the simpletest module, which is our mission here as part of #3057420: [meta] How to deprecate Simpletest with minimal disruption
Comment #26
Wim LeersThe code changes look reasonable:
run-tests.sh
is changed minimally, and some logic is moved out of a form into a@internal
helper class.This is what I wanted to write:
I tested this manually. For the first time ever, I can do a fresh D8 install, runrun-tests.sh
, without having to install thesimpletest
module. I must've run into that hundreds of times over the past decade, so it's wonderful to finally have that fixed! 🥳But … the reality is that this patch doesn't seem to work for me, or I misunderstood the purpose:
What am I missing?
Comment #27
mondrake#26 have not tried myself, but if simpletest is not installed, then its db schema is not available. This is where the test run results are stored, and that is a must have, one way or another. The 'another' in this case would be to instruct run-tests.sh to create a separate SQLite database through the
--sqlite
option, and results will be stored in that db. This is AFAICS what the testbot on DrupalCI is doing. If you want a sneak peek to the future, #3075608: Introduce TestRun objects and refactor TestDatabase to be testable :)Comment #28
Wim LeersAha, so I misunderstood the scope and intent of this patch — my bad!
Comment #29
LendudeWell if that is the scope of this issue, then the title should probably be something like:
'Allow run-tests.sh to run with --sqlite when Simpletest module is not present'
I think that would be a great first step but it would be better is you could also run it with a mysql database without the Simpletest module. I took a quick look at what that would take, and getting the tests to run is pretty easy
can be changed to
and the tests will run with mysql without Simpletest. The problem is clean up. With just that change, you will be stuck with simpletest tables without a way to get rid of them. Didn't immediately see a way to clean them up, the sqlite file isn't cleaned up either.
But the main thing I wanted to test is that the result printer still worked with the --browser option and simpletest disabled, and it does.
edit: wanted to make it clear that scoping this to just --sqlite seems fine to me!
Comment #30
Mile23Thanks for the reviews, everyone.
So the scope of this issue is to make it so you can remove the simpletest module from core, and run-tests.sh will still work as it did before. If you check out #3075490-28: Move simpletest module to contrib, that patch actually removes the simpletest module after applying this patch, and it passes drupalci.
The trick is the 'as it did before' part. You can already use the
--sqlite
parameter and run-tests.sh will set up a results database using SQLite, so that you don't have to have the simpletest module enabled, or even have a host site.There's some documentation about it: https://www.drupal.org/docs/8/phpunit/running-tests-through-command-line...
I'll update IS later.
@lendude: We're refactoring a lot of that stuff in #3075608: Introduce TestRun objects and refactor TestDatabase to be testable. This issue and the others from its parent have a more limited scope about being able to remove the simpletest module from core. I say 'we,' it's mostly @mondrake. :-)
Comment #31
Mile23Updated IS and title.
Comment #32
Lendude@Mile23 thanks for the feedback and IS update, all clear
So:
All boxes checked I think, so this looks ready.
Comment #33
Wim Leers🥳 Manually tested with
--sqlite
, works great :)Comment #34
alexpottWe're still adding CSS and JS from the simpletest module with run-tests.
I wonder if we're going about this the wrong way around. Like maybe only offer the --browser stuff if simpletest is still around. I used to use it more when we didn't output of all the verbose output as links but now I don't ever use it -
\Drupal\Tests\Listeners\HtmlOutputPrinter
has replaced the need. This makes me think we should deprecate the --browser option instead of maintaining all this code in core.Comment #35
Mile23Thanks, @lendude, @Wim Leers, @alexpott.
D'oh. I never looped back to that. Fixed here, although the CSS classes still say 'simpletest' in them.
run-tests.sh only has two useful structured reports:
--xml
which is our own bespoke format (not JUnit), and--browser
, which lets you see why something failed. I think we still need--browser
, and I've kind of already made it work anyway. This issue is about allowing us to remove the simpletest module if we'd like to without disruption: #3057420: [meta] How to deprecate Simpletest with minimal disruptionWe can do a follow-up to remove the
--browser
report or whatever else, but way more important than that would be this long-standing issue: #2834033: Add a junit format to run-tests.sh With that you could do any of a zillion different types of visualizations using your IDE or whatever else.If you're using run-tests.sh for concurrent test running (its big feature), then
HtmlOutputPrinter
doesn't really help you at all, other than the fact that you can say--browser
and get links to the output it generates in your web browser.Comment #37
Mile23Added the new system/runtests library to the ignore list for
Drupal\KernelTests\Core\Theme\StableLibraryOverrideTest::testStableLibraryOverrides()
.Comment #38
alexpott@Mile23 I disagree with
- it has one useful structured report - the
--xml
option and two ways that the user can see what has failed--browser
and--verbose
. I really think we should take the opportunity to deprecate the the--browser
option here. It really only was added to make it easier to get at the HTML produced during a test and now we have the\Drupal\Tests\Listeners\HtmlOutputPrinter
for that.I think we should take the opportunity to remove functionality from run-tests.sh. In Drupal 9 I'd like to see us only use it for concurrent testing and recommend the people and most CI systems use PHPUnit directly. It'd be great for it to be doing less.
Comment #39
Mile23So here's run-tests.sh without a
--browser
option.@alexpott you're welcome to write a change record.
Personally, I use
--browser
all the time, because I need the concurrency, and because--verbose
looks like this:You'll note that it is impossible to see which function passed or failed.
Also, this critical issue is supposed to be non-disruptive, and a follow-up would be an appropriate place to remove this feature. I'd strongly suggest we not use this patch and use #37 instead.
Comment #40
alexpott@Mile23 I'm confused - I think the reason why you can't see which function passed or failed is because
DenyNodePreviewTest
uses a data provider and the --browser option is not going to provide you any more information as far as I know. Data provider tests have always been badly represented in --verbose and --browser output. Which for me is yet another reason to try to move towards PHPUnit test reporting and away from our custom stuff.For me this critical issue is choosing to move a load of code to core that once it is there will be hard to remove and I'm not sure this code belongs in core.
I've created a change record - https://www.drupal.org/node/3083549
Comment #41
Mile23See #29, #32.
Marked @internal.
Also, to reiterate: *I use it.* The change record says it's being deprecated, but it's not. It's being removed without deprecation. It's not being replaced with a similar or better option, because run-tests.sh is the only way to run tests concurrently, and --browser is the only way to get useful human-readable test results.
Comment #42
alexpott@Mile23 Ah I see what you are saying... the issue is with the cut off output. Ie.
Drupal\Tests\node\Unit\PageCache\De
and not\Drupal\Tests\node\Unit\PageCache\DenyNodePreviewTest::testPrivateImageStyleDownloadPolicy()
. That is a good point. I'd still argue that really we should be telling people to use the phpunit from the CLI - because as the DenyNodePreviewTest shows the output using --browser or the CLI from run-tests.sh is unsuitable because it doesn't tell you what data has been provided.There's an issue with the
@internal
stuff though.We've marked this internal but we're using it in a module that we plan to remove from core. That's breaking the idea of something being internal.
Comment #43
larowlanTrying to strike a compromise here, what if we add a --table option which outputs something better than the current sprintf approach, and then retain but deprecate the --browser option and have it trigger an error but then fallback to --table
Then we're doing something close to what the title of the change-record suggest, 'deprecating' rather than 'removing' - albeit where 'deprecating' means 'a fallback'. We're also closer to what we'll likely do if we were to finalise #2624926: Refactor run-tests.sh for Console component. as we'd likely use the table helper there too.
Looks like so
Comment #44
larowlanLooks like so when Drupal.org doesn't mangle it :)
Comment #45
Mile23--table
+1 :-)Comment #46
alexpottI think we could leave simpletest_script_open_browser() around for the rest on D8's life cycle and only remove in D9. Because that's when Simpletest is leaving core.
The --table option doesn't need the keep results option.
Comment #47
Mile23Super ultra plus one for @larowlan. :-)
#46.1: #2624926: Refactor run-tests.sh for Console component. :-)
#46.2: OK, reverted
simpletest_script_open_browser()
and added a deprecation message andtrigger_error()
. This means we aren't actually decoupling run-tests.sh from the simpletest module, so we'll have to rescope here a little. But since we're turningsimpletest_script_open_browser()
into dead code, it fits our needs. We just have to be sure and remove it later, so I'm adding a @todo for #3075490: Move simpletest module to contrib#46.3: Neither does
--verbose
, any more. Done.Updated CR. https://www.drupal.org/node/3083549
Comment #48
Mile23Grr. Stupid mistake.
Comment #49
alexpott--browser does need keep-results as far as I know. Otherwise the html links won't work.
Comment #50
Mile23It does if we're using it, but we aren't. If you pass in
--browser
, you'll get a deprecation message and the--table
output. If you're somehow callingsimpletest_script_open_browser()
in any context other than this script, all bets are off anyway.Guess we need to change that, too.
Comment #51
alexpottah I see. I think if you pass in --browser then we should call simpletest_script_open_browser() - there's no point in breaking people's expectations in D8 - and now we're telling them how to set new expectations and use --table. That's how deprecation is supposed to work.
Comment #52
Mile23Yah, I thought we had decided to replace it with
--table
in this issue, and that we needed to keep the deadcodesimpletest_script_open_browser()
because it might be API, but I guess not.This patch restores full
--browser
without refactoringSimpletestResultsForm
, adds--table
, warns you that--browser
is going away.When D9 time happens, we'll fully remove
--browser
functionality andsimpletest_script_open_browser()
. #3075490: Move simpletest module to contribComment #53
alexpottSo I've done some testing with #52 and unfortunately the only situation is works for is passing PHPUnit tests. If a PHPUnit test fails or you run Simpletests the output is not as you'd like it.
Whilst fixing this I've realised that the new
--table
switch is not necessary. We should fix --verbose output here and be done. The verbose output is not an API and as @Mile23 has shown there are many situations is it totally problematic for. Funnily enough though the one situation is does work for where --browser fails for is where there is a fail because the current behaviour is to output the PHPUnit output so the user can see what has happened.Here are the test cases I ran through:
Simpletest
sudo -u _www php ./core/scripts/run-tests.sh --non-html --url http://drupal8alt.test/ --verbose --directory core/modules/simpletest/src/Tests
the output with the patch looks like this.PHPUnit success
sudo -u _www php ./core/scripts/run-tests.sh --non-html --url http://drupal8alt.test/ --verbose --types PHPUnit-Unit node
the output looks like this:PHPUnit fail
sudo -u _www php ./core/scripts/run-tests.sh --non-html --url http://drupal8alt.test/ --verbose --types PHPUnit-Unit node
where I've hacked \Drupal\Tests\node\Unit\PageCache\DenyNodePreviewTest::providerPrivateImageStyleDownloadPolicy to fail some of the time - the output looks like this:Comment #54
mondrakeI tested the patch on TravisCI with some combinations of run-test.sh, https://travis-ci.org/mondrake/d8-unit/builds/590486099
Results are nice.
1) I get a
PHP Notice: Undefined index: debug in /home/travis/drupal8/core/scripts/run-tests.sh on line 1342
error. I think that we need to add a'debug'
key to the$result_map
insimpletest_script_reporter_init
:2) when one of the lines of the detailed log is very long the entire table gets weird at reading (see the SimpleTestInstallBatchTest test in the link for example)
3) do I understand correct since #39 we are no longer moving any code from the simpletest module and that suffices for the scope here?
EDIT:
4) Also, in case of failing PHPUnit tests I was kind of expecting the failure log be part of the table, but it's appended after the table in fact - see for example the failing Entity tests in https://travis-ci.org/mondrake/d8-unit/builds/590494824
Comment #55
Mile23To me, #54 illustrates why we should concentrate on deprecation and have a follow-up, and not try to graft new features onto an untestable script. That way, we stand a chance of getting a contrib simpletest before the 9.0.0 release.
If 8.8.0-alpha1 weren't two weeks away we could continue to take our time, but it's two weeks away. My understanding is that basically we're stuck with core simpletest module after that, through the entire D9 life cycle.
I mean: If we're just going to say
--verbose
and not--table
then there are plenty of better ways to format this without a table, that would be more readable. (PHPUnit doesn't use a table, for instance.) And in order to implement any of this consistently, we'd have to do some refactoring in order to write tests. But that will take time and plenty of back-and-forth, and then the clock will run out and it won't matter.I suggest we roll back to #37 so that we accomplish the goal of being able to deprecate the simpletest module as per the parent issue #3057420: [meta] How to deprecate Simpletest with minimal disruption, and then pursue this in a followup: #3084354: Deprecate --browser option from run-tests.sh
This patch is #37 with a note about the followup issue.
Comment #56
Mile23Back to the old scope, please, and we don't need a change record.
Comment #57
alexpott@Mile23 #37 / #55 is still not a solution though. Moving something to core and making in @internal and then planning to move it's usages to contrib is not a plan. #54 is completely fixable. The --verbose results are already compromised and #53 makes it better. Also --browser formatting is very compromised for PHPUnit tests - which by the way are the only tests in Drupal 9 core - so maintaining the feature for Drupal 9 core makes little sense.
Comment #58
Mile23Correct. That is not the plan.
So here’s a question we have to answer:
If run-tests.sh has a hard dependency on
\Drupal\simpletest\Form\SimpletestResultsForm
, then can we deprecate the simpletest module?In other words: Will we do this work, and then have a release manager say that nope, we can’t deprecate either
--browser
or the simpletest module because there is a hard dependency between these two things?Previous personal experience suggests that, yes, this is exactly what will happen.
So:
If we don't refactor
SimpletestResultsForm
then we have to keep that piece of the simpletest module in order to provide BC for run-tests.sh in D8.8+, which might very well mean not deprecating the simpletest module.However, if we do refactor
SimpletestResultsForm
intoRunTestsResultsBuilder
, then run-tests.sh will have zero dependencies on the simpletest module at all. We could commit #55 today and literally delete the simpletest module tomorrow with no loss of functionality of run-tests.sh. You can see where I did this in #3075490-28: Move simpletest module to contrib, showing that only test fixtures referencing the simpletest module fail tests.So: Should we force ourselves to need pieces of
SimpletestResultsForm
and thus the simpletest module for BC moving forward, and then needing to do the refactoring anyway when a release manager complains? Or should we refactor it now in order to not need pieces of the simpletest module going forward with a clean break?My answer is that we should refactor in this issue, and thus give ourselves options in the next few steps of removing the module that no one wants.
I'm putting my foot down a little bit here because core maintainers have been sleeping on this problem for four years* and I do not want to end up running out the clock bikeshedding output formatting in the last two weeks. If there wasn't a looming deadline, then yah, whatever, we'll pick it up later. But there's a deadline.
I'm traveling and away from Drupal until BADCamp late next week. Then more radio silence for 5-6 days.
* Filed in 2015: #2624926: Refactor run-tests.sh for Console component.
Comment #59
mondrakeWhat if, instead of moving simpletest code to
RunTestsResultsBuilder
, we duplicate it in run-tests.sh? That way we could decouple the two things now and do whatever refactors of the two things separately later.Comment #60
alexpottI thought about #59 too.
So I'm going to repeat myself here and question the statements that @Mile23 makes about --browser being useful with --concurrency. If a test fails and you have --verbose on you see exactly where it fails regardless of --concurrency. Yes the output is not the best for successful PHPUnit tests but the important information is there ie. you know that the test has passed and if it has failed exactly where and how. Note that PHPUnit output does not even tell you what test method has passed in visual output to the CLI because this information just noise. Therefore I stand by claims that even with --concurrency the --browser is not actually useful.
Also with respect to process we are totally allowed to remove a "feature" (though I really don't regard --browser as one) from Drupal 9 and deprecate it without replacement in Drupal 8. However I contend that there is a replacement in Drupal 9 - it's called the Simpletest in contrib module which can come with its own run-tests.sh - actually it'll need to because the core will no longer run Simpletest tests because core has none.
I suggest that this issue deprecates the --browser flag and we can improve / fix the bugs in --verbose as and when we choose because they have existing even since we integrated PHPUnit.
Here's visual proof of what I'm saying... running the command
sudo -u _www php ./core/scripts/run-tests.sh --color --non-html --url http://drupal8alt.test/ --verbose --concurrency 2 --types PHPUnit-Unit node
where DenyNodePreviewTest as been hacked to fail.Comment #61
Mile23Ok, so where's the meta for this? We've got this one: #3075490: Move simpletest module to contrib On that issue I see me trying to make it so we can delete the simpletest module, but I don't see a plan to do this. There's also the issue filed in the contrib module: #3076422: [contrib] Move simpletest module to contrib for D9
We have the beginnings of speccing that out here: #3057420-46: [meta] How to deprecate Simpletest with minimal disruption
If someone could please write it all down such that it's clear what's going to happen in the next few days (because it's days at this point), then we can talk about how this issue fits into that process.
Comment #62
mondrake#59, in practice. No interdiff, this takes bits of #55 and bits of #53.
--browser is deprecated as an option, as well as the functions in run-tests.sh that support it. Code is duplicated from simpletest. So we can refactor the run-test.sh --verbose output later, independently from the fate of the simpletest module.
Comment #63
Mile23OK, #62 is good. I'd much rather not make run-tests.sh more complex, but it's all deprecated and we accomplish the scope of the issue, and instead of refactoring to a class it duplicates to some functions.
We can use the follow-up to improve whatever needs improving in either
--verbose
or--browser
or--table
or--chair
or whatever else: #3084354: Deprecate --browser option from run-tests.shGood so far...
It's a bit of a nit because it works, but this is a dependency on a class in the
Drupal\simpletest
namespace. Can we please notuse
TestBase
and instead have the class name as a string inclass_exists()
andis_subclass_of()
?So while this is all deprecated (and still in core) the CSS and JS will load, diggit.
Other than the one thing above, +1.
Comment #64
mondrakeWRT #63.3, how about duplicating the CSS too, adding maybe an entry in system.libraries? The JS is totally irrelevant here, it seems - it is needed for the tests list form, not for the test results one
Comment #65
Mile23Re: #64: I think that between #3084493: Fully deprecate and prepare for removal of SimpleTest module and #3084354: Deprecate --browser option from run-tests.sh we'll either discover that we need to move the CSS around, or just conditionally loading that library will be sufficient.
Comment #66
mondrake#63.2 done (I do not understand why it's better, but no problem)
Comment #67
Mile23Thank you, @mondrake.
Setting RTBC even though I did some patches up there, so we can expedite this.
Comment #68
alexpottI have some reservations / tweaks I think we should make but as it’s the weekend and I’m on my phone I can’t add them right now. I will comment first thing tomorrow.
Comment #69
larowlanThanks Mondrake! Couple of questions, feel free to push back if these are not reasonable
Is there a way here we can also trigger a deprecation error if the class doesn't exist - something like 'your tests rely on simpletest and this will be moved to contrib in 9.0.0 - please move to WTB or declare a test_dependency on simpletest module?'
should we be triggering a deprecation error here too?
should we make these 3 anonymous functions inside simpletest_script_open_browser so no-one else can call them?
Comment #70
Mile23Re: #69.1: We don't actually have the contrib lined up at this point, so let's point to this change record: https://www.drupal.org/node/3030340
Also, we want to do that once for the test run, and not once per test class. Given this tiny bit of complexity, it might be better to add that when we're clearer what the actual course of action is.
Comment #71
alexpottRe #69.1 this gets to something I've been pondering this weekend. If simpletest is moving to contrib then either (a) run-tests.sh in Drupal 9 needs to be able to run Simpletest tests or (b) DrupalCI needs to support different test runners per test type. The simpletest solution is to suppose that (a) to be true for now. I've tried to address this point and be able to inform the user but adding a new failure mode when
simpletest_script_run_one_test()
cannot run a test.Re #69.2 I don't think so we already have an unsilenced (so users actually see it) deprecation error. Adding a silenced deprecation error here is unlikely to ever be caught because deprecation handling is set up at a lower level in the test runner than this.
Re #66 if we're going to deprecate simpletest_script_open_browser() - which I'm totally in favour of. Then we don't need to bring all the functionality into run-tests.sh. The simpler and less complex thing to do is to move the functionality into the simpletest module. This also answers #69.3
Comment #72
Mile23So we have three options:
If we succeed in splitting up run-tests.sh to not use simpletest module in this issue then we can do any of them.
For the second and third option we have this issue:
For the third option we have these follow-up issues as well:
We can add another follow-up about how to run those tests if needed, or add a note to #3075490: Move simpletest module to contrib
For the use-case of a d.o contrib module that needs drupalci to run
WebTestBase
tests in Drupal 9: We can spec the new contrib simpletest module to have its own script runner, and maintainers can use container_command in their drupalci.yml file to run it. This is the already-existing solution for now, and if there is hue and cry we can work on a better one.+1 on #71, which keeps
--browser
but separates it from run-tests.sh, so there are no hard dependencies with simpletest module. This also deprecates--browser
, so we can close #3084354: Deprecate --browser option from run-tests.sh We can deprecate--browser
because--verbose
gives adequate fail info.Comment #73
LendudeI think this should be referencing [#3083549] and not the WebTestBase deprecation?
Comment #74
alexpott@Lendude good point. Leaving at rtbc as this is only fixing text.
Comment #75
mondrakeNitpick: instead of
trigger_error
, why not usingsimpletest_script_print
to echo the information to CLI?trigger_error
is meant to capture deprecation errors in tests - but here we would log the message in error.log (do we need that?), and the output on CLI is not very nice (see example below). run-tests.sh is not tested itself.Comment #76
alexpott@mondrake good call. The output with
simpletest_script_print_error()
is not that much better - it is indented for whatever reason. But it's not duplicated and there's a tonne of precedent in the file.This means that we should follow deprecation policy and do a silenced @trigger_error in
simpletest_script_open_browser()
just in case.Again as this is only touching on the display of messages leaving at RTBC.
Comment #77
Mile23RTBC +1. :-)
Comment #78
xjmSo on #2750461: Remove Simpletest UI because we don't want to maintain a graphical test runner I indicated I was alright with simpletest moving to contrib and core not providing a UI test runner so long as verbose output continued to be provided by the core test runner. I'd say that's an essential part of the core featureset for the test runner.
If that's being deprecated here I have strong concerns with that.
Comment #79
Mile23I'll say #58 came true about 75%. :-)
Comment #80
Mile23Let's undeprecate
--browser
, follow-up in #3084354: Deprecate --browser option from run-tests.sh to solve for no-browser.Since we have to keep the feature (for now), we either duplicate the report code in the script per @mondrake, or we move it to a class like I did. Either way. :-)
Then in the followup we move it wherever it has to be.
Comment #81
alexpott--verbose is not deprecated. Verbose output is not being deprecated. The ability to open it in a browser window is.
Comment #82
alexpottUpdated the issue summary to be inline with the latest patch.
Comment #83
catchAdded an extra line to the issue summary to make it clear that --verbose gives you links to HTML, so the only thing we lose from --browser is it opening the actual browser in the site under test for you. But since these are equivalent for actually figuring out what went wrong, we're not losing much of anything by deprecating it. Discussed this with @xjm and we're both agreed this is good to go.
Comment #84
LendudeWe can remove this from the IS right?
Comment #85
catchBack to RTBC. I'm arbitrarily removing the Needs product manager review tag because we're removing a CLI option that is already de-facto deprecated by another CLI option. Added it to #3075490: Move simpletest module to contrib which is the actual issue that's removing all the stuff we're preparing for here and elsewhere.
Comment #86
catchper @Lendude in #84
Comment #87
xjmThis is unclear. What use is HTML if it cannot be opened in a browser somehow? Is the output still HTML?
When I said to @Mile23 that what was important to me was that core continue to provide verbose output, and present links to said verbose output in the
run_tests.sh
output, he implied (but did not outright say I guess) that this functionality was being deprecated. If core retains the ability to output a list of verbose output HTML files on the file system, which can be opened in a browser with copy and paste, and if the UI test runner in SimpleTest module itself also continues to work with links available to this output, that's fine. However, if an actual major feature is being removed from the module, that's what will (always) need product manager review.Comment #88
alexpottLinks to the pages generated by the system under test during a test are available if
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
is set - which is now the default! Yay #2870145: Set printerClass in phpunit.xml.dist.Unfortunately --browser has never been able to provide links to these generated by PHPUnit tests (i.e all browser tests apart from the Simpletest module's test now in core). --browser (and run-tests.sh in general) is not all great for PHPUnit test output.
Compare what happens when you do (on HEAD):
php ./core/scripts/run-tests.sh --color --non-html --url http://drupal8alt.test/ --verbose --class '\\Drupal\\Tests\\node\\Functional\\NodeAdminTest'
php ./core/scripts/run-tests.sh --color --non-html --url http://drupal8alt.test/ --verbose --browser --class '\\Drupal\\Tests\\node\\Functional\\NodeAdminTest'
versus
./vendor/bin/phpunit -v -c ./core core/modules/node/tests/src/Functional/NodeAdminTest.php
If your phpunit.xml.dist has been properly set up you'll get browser output whilst running PHPUnit. Neither of the run-tests.sh versions are able to link the test browser output. This patch has no impact on the ability to get to the html generated by the test.
Comment #89
xjmThis is hugely insulting, BTW, and unnecessarily combative. Core maintainers work on a lot of stuff, and a response from one core maintainer shouldn't be confused with signoff on a plan that hasn't been reviewed and signed off by relevant stakeholders.
Yes, there's a lot of technical debt in SimpleTest. We had a whole initiative to clean up that technical debt and among that initiative's requirements were to retain the features of the current workflow for PHPUnit tests instead of WTB tests.
From my perspective, these issues are major task, like any other major tasks to clean up significant technical debt. There won't be any security, data ingerity, or upgrade path implmications if we retain the features in core. There's no depdnencies EOLing their security coverage or aside from phpunit forcing thei ridiculous schedule on us. https://www.drupal.org/core/issue-priority#critical outlines when an issue or chain of issues should be critical.
TLDR, I think this suite of issues should probbaly be marked major, not critical. If it's not done in time for 8.9/9.0 that's kinda a bummber, but it it still is acceptable.
For review: drup
Comment #91
catchI think this was a crosspost but just to confirm:
--browser was literally opening a browser window to the page in question on the under-test simpletest site. --verbose provides a link to the stored HTML of the page.
Agreed on issue priority, this is more rightly major alpha-deadline than critical - even if it'd be a massive shame if we can't remove Simpletest for 9.x it's not actually blocking the 9.x release or causing other critical issues.
Untagging 'Needs change record update' since the change record is accurate.
Since the actual proposal here is OK, and the patch is also OK... Committed 1b0ae80 and pushed to 8.8.x. Thanks!
Comment #92
Mile23I have to address this, because it's incorrect.
I've used all of the channels one is supposed to use to attempt to address this issue. I talked to subsystem maintainers about it on numerous occasions. If I were a subsystem maintainer myself, I'd feel as though it were important to get 'signoff by relevant stakeholders,' but I'm not.
I've been working within my role as an unpaid volunteer in a best-faith effort to try and deprecate the simpletest module for many years. At any point, anyone with any degree of authority greater than mine could have said, "We're not doing that until much later in the release cycle," and I would have said: "The sooner the better, though..." And you'd repeat that you have a plan, and I'd be OK with that.
But: You folks snoozed on this for four years, and it frustrates me. What's insulting is four years of re-rolls because no one said, "No, we don't want this at this point." And no one said that because there never was a plan other than the one I outlined.