Problem/Motivation
As part of #2869825: Leverage JS for JS testing (using nightwatch) we need to allow nightwatch to install Drupal, so we can test a site in isolation.
Proposed resolution
- Add a command to install Drupal
- This command allows to specify the installation profile and a file to setup additional configuration
- Nightwatch then can run this command from node.
Test instructions
After applying the patch there will be new commands to install a test site and tear it down. To install a test site run:
php core/scripts/test-site.php install --json
This will output information about the test site in a JSON format if successful. For example:
{"db_prefix":"test22029735","user_agent":"simpletest22029735:1518188974:5a7db9aee752c4.29037117:Vvw9BjAc-58eRlb95RphcXV4Xeb72-eWTba4XYtc4pY"}
To tear down the site:
php core/scripts/test-site.php tear-down test22029735
Other features:
// Get general help.
php core/scripts/test-site.php
// Get specific help.
php core/scripts/test-site.php install --help
php core/scripts/test-site.php tear-down --help
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #137 | 2926633-2-137.patch | 36.91 KB | alexpott |
| #137 | 133-137-interdiff.txt | 12.69 KB | alexpott |
| #133 | interdiff-2926633.txt | 1.52 KB | dawehner |
| #133 | 2926633-133.patch | 36.79 KB | dawehner |
| #131 | 2926633-2-131.patch | 36.71 KB | alexpott |
Comments
Comment #2
dawehnerComment #3
dawehnerComment #4
larowlanThe way this reuses the existing traits is sweet - nice work
could we just use
$autoload->addPsr4instead of special casing these four or so? If not, we should document why.Should we provide a sample setup file?
A single class?
We already throw an exception if the class doesn't implement the interface, so I don't think we need the second check
any reason we can't put these in their own files and again use the $autoloader to handle loading. This file would then be just booting the application and running, like you get with app/console in symfony apps
whitespace
I reckon we should call it TestSiteSetup or somesuch instead of FakeTest, cause although its using the testing traits, its not really a test - to avoid confusion.
We could probably give the user something more verbose here, like instructions on how to set the cookie?
needs docs obviously
Comment #5
mile23Could this be an installer class that can be shared between this use-case and BTB?
Comment #6
dawehnerI thought this sounds like a great idea, but then I realized: This will no longer make it possible for tests to interfere with the installation process on this low level, like the installer test base and the update test base both rely on it. I still think overall this would be a good idea, so maybe we should open up a follow up to do more research?
TestSetupInstalleror something like this, see patchWell, I mostly tried to have something which is machine parseable, maybe we could print out json?
Done
I made one ...
Totally ...
Done
Done, see above for renaming.
I also started writing a test, but then I realized that I don't know how to test async php APIs.
Comment #8
mile23Re: Making it a reusable class...
Actually, yah, I was thinking about the wrong thing. The magic ingredient is this:
'prod' should be 'test' or 'test-for-js' or whatever.
But that's out of scope here. Unfortunately, it will be out of scope everywhere.
Comment #9
droplet commentedMind I ask a question?
Can we add REST API capital to it? It's ultra useful for sites using another test engines than the CORE one :)
I think it will be cool if it returns SUCCESS install code
Comment #10
dawehnerI just use 'test', let's see how this work out :)
I think it will be cool if it returns SUCCESS install codeThis is a good suggestion! Doesn't it do that already though?
\Symfony\Component\Console\Application::runcatches exceptions and return error codes, as needed?I was not able to follow how this script is related with a REST API. Do you mind elaborating a bit on that?
Comment #11
dawehnerOh here is the change.
Comment #12
mile23Of course we currently ignore that setting, which is what I was trying to obliquely point out. :-)
Comment #13
dawehnerJust fixing some minor points.
Comment #14
borisson_This comment isn't very helpful.
stray space.
I tried testing this manually, but couldn't get it to work. I ran: "$ php core/scripts/setup-drupal-test.php", but got the error:
You must provide a SIMPLETEST_BASE_URL environment variable to run some PHPUnit based functional tests.. I have this in my phpunit.xml:<env name="SIMPLETEST_BASE_URL" value="http://localhost/search-drupal"/>.Does that mean I'm doing something wrong?
Comment #15
dawehner@borisson_
Well, the only thing needed is for you to specify the simpletest base url.
Comment #16
mile23Hmm.....
https://symfony.com/doc/current/console.html#testing-commands
See also the testbot, such as: http://cgit.drupalcode.org/drupalci_testbot/tree/tests/DrupalCI/Tests/Ap...
ApplicationTesteris your friend. You can use it to test against output, and also grab properties from the command object for assertions.Comment #17
mile23I guess that's a NW...
Comment #18
dawehner@Mile23
It is absolutely "needs work".
I'm struggling a bit with not running into an
AlreadyInstalledException, do you have any idea how to install a test within a test?Comment #20
mile23Shifted things around a little.
The command is now responsible for bootstrapping the kernel.
The test is a TestCase test, run in its own process, to avoid the already-installed exception.
In order to test the state of the installed Drupal, you'd need a way to get the kernel from the console app.
Comment #21
larowlanyes, this was what I came back here to check for.
in the middle of the night I had a thought that there may have been a security risk here.
thanks..carry on
Comment #22
mile23Looking at the results,
SetupDrupalTestScriptTestdidn't run. That's because of #2878269: Modify TestDiscovery so the testbot runs all the testsComment #23
mile23Moved the test to be a kernel test because
DrupalKernelTestdefinesdrupal_valid_test_ua()all on its own. Kill includes.The test now uses the test bootstrap.php to get the autoloader, which had to be modified to return the autoloader. This change was an experiment and should be discarded.
IIRC, @neclimdul put that all into
drupal_phpunit_populate_class_loader()so we wouldn't have a global called $loader hanging around during testing, which is smart. So this is a WIP and please don't leave it like this.This patch will fail with an error that looks like this:
Comment #25
dawehner@Mile23
Nice work! Thank you for that
Comment #26
jibranWhat is the difference between #2911319: Provide a single command to install & run Drupal and this?
Comment #27
dawehner@jibran
This issue is about installing a test site using an existing database connection.
The other one installs a real drupal site from scratch aka. just using sqlite.
I agree with you that there are similarities which is why we should mark everything internally as
@internalfor potential future refactorings.Comment #28
dawehnerI rerolled the patch, made it passing and enlarged the test coverage to include a test that the setup_file bit runs as well. This uncovered that this bit actually doesn't work :)
Comment #30
dawehnerThis is caused by having the test script in the same directory. Let's move it out, there is no reason to require us to change the discovery code in simpletest to deal with that particular edge case.
Comment #32
dawehnerI asked @alexpott for some feedback and based upon that we no longer specify a filename, but rather a classname and leverage the autoloader for it.
Comment #33
dawehnerComment #34
alexpottAnother thought...
I think I prefer passing the autoloader into the constructor since it is definitely required for this to work. That way we could protect the setAutoloader() method and have less public API. Or not ever bother with the setter.
Comment #35
dawehnerGood point. Done.
Comment #38
dawehnerThis should fix the remaining errors.
Comment #39
jibranNice work. Patch looks ready to me some minor observations.
Let move require to separate line.
Let's use a local var instead of calling the
getDisplayagain and again.We should assert response code as well.
We should expose profile option as well.
Doc block missing.
Can we use
$kernel->getAppRoot()here? Or are we trying to get parent site app root? If that's the case we should add a comment here about it.Desc missing.
Parentheses missing.
:missing.Comment #40
alexpottWhy bother passing this? Couldn't bootstrapDrupal() just use $this->autoloader?
Does this need an @group - it is not a test per-se is it?
I think the docs here could be expanded to explain what a set up class is.
Should we allow an empty set up class?
It is optional...
Comment #41
dawehner@alexpott made clear that #4 is actually not valid, given this code:
Comment #42
dawehnerComment #43
alexpottI'm not 100% convinced about doing this. It means we're registering stuff for things like deprecation testing unnecessarily. Why do we need this? Just for the class loading of the Setup stuff? Can't we just add that to the autoloader ourselves here?
Comment #44
alexpottAlso I discussed the need to be able to teardown the site - ie. drop the database and remove all the files. Analogous to what happens in \Drupal\Tests\BrowserTestBase::cleanupEnvironment()
Comment #45
dawehnerAssigning myself to work on this.
Comment #46
mile23If only we had some kind of helper class that does consistent test cleanups for us... #2800267: Turn simpletest_clean*() functions into a helper class
Comment #48
dawehnerComment #49
berdirLooks good to me, not much feedback but I don't know much about symfony cli applications.
maybe expand this regex so it actually is on and match better on what you're expecting? Right now it's just an assertContains() ?
pretty awesome that we can re-use all that code directly through traits :)
in tests we have the ability to install in a different language. I guess we can add this later, might eventually be useful.
Comment #50
dawehnerI was surprised, to say the least.
Good point! Let's add it now, it really doesn't hurt.
One thing I added as part of this change is to use a JSON result, which is descriptive.
Comment #51
dawehnerUnassigning myself, I hope this didn't block anyone from reviewing this particular issue.
Comment #52
lendudeJust some nits and stuff, haven't tried running the command yet, will do so when I find some time:
Uhh isn't it already in that namespace?
Shouldn't we assert something to test that the tear down worked? Or are we just waiting for exceptions to be thrown?
missing a docblock
"Symfony console command to tear down Drupal." to keep it inline with the set up command?
copy/paste leftover, needs update to the right class
missing docblock
is 500 seconds completely arbitrary or do we have a reason to limit this to 8.3 minutes? It feels like we might hit that limit under normal circumstances, these tests can run a bit long.
this is always set during setup() now, so is the default value needed?
longer then 80 characters
Run the code to setup the test environment.
longer then 80 characters
Comment #53
alexpottI find the layers of code quite hard to understand in this patch. Everything is very similarly named which does not help. I wonder if refactoring into the relevant part of
TestInstallationSetupintoTestInstallationSetupCommandandTestTeardownCommandwould help. Basically I thinkTestInstallationSetupis unnecessary and I can't see what it is buying us.Comment #54
dawehnerWorking on it now ...
Comment #55
dawehnerNice observation
Good idea, I added that.
I copied the value we have in BTB. Note: this is used inside
\Drupal\Core\Test\FunctionalTestSetupTrait::prepareEnvironment. Given that we don't actually run the test in the same process we don't use that variable properly anyway ...¯\_(ツ)_/¯ I like setting a default value on the class level, you never know.
Comment #56
alexpottNot used
Not needed - i think
assertEquals
Not used.
Should profile be an option here? Might be useful to choose different testing profiles.
Missing @param doc
Unused - maybe this entire class is not used?
Comment #57
dawehnerThank you for your quick feedback @alexpott!
Comment #58
alexpottfilePreDeleteCallback function looks like it is in the wrong class - no? Interesting this is not caught by the test.
Comment #59
dawehnerWell, we don't have that much of test coverage right now.
Comment #60
dawehnerLet's also test the table truncation in the language installation case.
Comment #63
dawehneroops
Comment #64
alexpottThe teardown command as being called by the test was not working as expected. The patch attached fixes this and improves the test to ensure it is doing what we want it too.
Comment #65
alexpottAdding missing docs.
Comment #66
dawehnerOh I see! It turns out connecting to a database is never as easy as you expect it to be :) Thank you Alex!
Comment #67
jibranThank you, for amazing work.
If the
SIMPLETEST_DBandSIMPLETEST_BASE_URLare already set then why are we setting them again? Do you think it is worth doinggetenv('SIMPLETEST_DB')first beforeputenv("SIMPLETEST_DB=$db_url")and don't set them if the values are same?Can we mention the reason for overriding this method?
Comment #68
alexpottThanks for the review @jibran
Comment #69
alexpottAnd here's the patch
Comment #70
jibranThank you for the fixes. I'll create the documentation page(s).
We should add a doc block to this file to explain the sample usage and params.
Should we explain the commands for this application?
I think we should improve the class docs here as well and explain the things this class is doing e.g. installs a Drupal testing site and execute setup class.
I know we have explained the param but we should also improve the function doc block. We are also missing @throw here.
Why are we using sprintf in one and not the other?
Why can't this be just parent call?
Again we should add more docs to this class explaining the functionality.
What do we mean here by 'chmod generated'? Can we please use proper/complete words?
Aren't we planning to deprecate the usage of @ to suppress the warnings with an empty catch?
I think I pointed this earlier as well, can we use $kernal->getAppRoot() here?
> 80 char.
I think it should be
You have access to any API provided by any installed module. For example to installphp core/scripts/setup-drupal-test.phpanymore so we need IS updateWith PHP 7.2.2 and phpunit 6.5.6 when I run
php core/scripts/setup-drupal-test.php setup-drupal-testI'm getting the following warning.Comment #71
alexpottPatch attached moves the test to a unit test and fixes things so that the test works on MySQL, SQLite and Postgres regardless of what is configured in the parent site's settings.php.
#70 is still to be addressed.
Comment #72
dawehnerWhat are other possible values for originalContainer? Like a TRUE boolean? Could we use instanceof check here maybe?
Good look adding a line of documentation here.
It feels like an
@seeto\Drupal\Tests\BrowserTestBase::cleanupEnvironmentWHY?! This API is a bit interesting
Nice, but what do we do with the remaining tables?
Can we test whether the site wasn't installed?
Nice!
Comment #74
alexpottFixing the tests and PHP7.2 too.
Still to address #70 and #72.
Comment #75
alexpottRe #74
$this->originalContainerso an instanceof check will still cause an error. The only possible types for$this->originalContainerare NULL - the default value in most test bases, not set at all - our command or the container as it becomes in most test bases. I think we need the isset() check here or to add the property the will never be used to TestInstallationSetupCommand. I prefer the cleanliness of checking if it isset because it is not defined by the trait.Comment #76
alexpottre #70
php core/scripts/setup-drupal-test.phpis still the application - it has two commands and it tells you about them.Also fixed "teardown" not being a word recognised by PHPStorm - so tear-down and tearDown are preferred.
Comment #77
alexpottThe change record exists https://www.drupal.org/node/2943615
Comment #78
alexpottPatch attached completely refactors all the class names and namespaces to be consistent. The basic idea is that the word Drupal is redundant. The application is a TestSite application with two commands - install and tear-down. Updated the issue summary and change record accordingly. No interdiff because it will be way way bigger than the patch and probably confusing. The reason things got inconsistent was that the first command was just to install a site - we then added a tear down command and didn't refactor all the stuff around it.
See issue summary for updated commands.
Comment #79
alexpottEnsure that both commands now output at least something to tell the user what has happened. The
installcommand now has a new option to output in json ---json.Comment #80
jonathanshawSuggests this will/should only be used for javascript tests, whereas the naming is more generic.
Comment #81
alexpott@jonathanshaw good point. We don't need to specify exactly what the test site might be used for. Javascript testing is the initial aim but the script could be used for all sorts of testing where the test-runner / specification is less tied to Drupal's code.
Comment #82
alexpottFix a typo.
Comment #83
dawehnerI've adapted a couple of nitpicks people might point out, but mostly I had a look at the new direction and the new naming totally makes sense.
We are no longer just setting up a test, but also tear a testside down!
Sorry for the gigantic nerdsnipe.
I'm wondering whether we could treat this entire suite as internal
Would you ever use this script outside of tools? Having human readable output seems nice, but how useful is it actually?
❓I don't understand the use of this unset here :) If you drop that you could replace all that with a
array_walk($tables, $connection->schema()->dropTable)It feels like we could finally ramp it up to '0.1.0' :)
nitpick: You could use assertCount
Comment #84
alexpottNice tidy ups @dawehner
re #83
Comment #85
dawehnerYeah, good point, I think this is a sane number to go with. Still I don't think this number matters.
I agree with the statement about @internal. It is a script, but its internals can change. I like this idea :)
Comment #86
larowlannit: extra line
Can we add a few
->addUsageexamples hereany reasons not to use class_implements here? given its an interface and not a class?
same here, a couple of
addUsageexamples would be usefulshould we validate this - could someone possibly pass an empty string? These all used to be
/^simpletest([0-9]+)$/- should we check that here to prevent people dropping the wrong tables?<3 this is some damn fine work
Comment #87
alexpottThanks for the review @larowlan
Comment #88
dawehnerNice additional test coverage! I'm certainly good with this patch now. @larowlan what do you think?
Comment #89
jibran#86 is addressed so back to RTBC.
Comment #90
mglaman+1 from this side. I ran
with output
and
I have to board a plane, but will test tear-down on plane.
Comment #91
mglamanI kept getting errors. I'm not sure if it happens to be my setup, so I'm not wanting to be the person who kicks it back to Needs Work. But I kept receiving the error " The specified database connection is not defined: default "
The command tests the prefix, but there are errors later in the bootstrap process. It seems to be in
drupal_valid_test_uawhere it falls back todefaultbecause it cannot detect the proper UA. So it seems like we need the UA passed and not the test prefix because the existing process should detect the prefix and validate it via the UA.EDIT: Command w/ output
EDIT 2: This diff of change worked, ensuring there was a UA
Comment #92
mglamanI could not get it work despite what I did, I had to use the user agent, which follows the normal boot process.
Comment #93
alexpott@mglaman thanks for testing the command.
I can't reproduce what you are seeing in #91 with #87 :(
Comment #94
alexpottAh I've got it. It's because @mglaman didn't have a valid Drupal installation so no settings.php. Which is a great way to test this command as it should work in those conditions. Unfortunately I cannot think of a way to test this via run-tests.sh The interesting question is why does the testbot pass? I think this is because a default connection gets defined. I guess this suggests a better fix more internal to the tear-down command. We can set the drupal_valid_test_ua() prefix here and not have a pretend request at all.
Comment #95
alexpott@mglaman's test environment helped yet again. If you have a sites/default/settings.testing.php you'd get issues with DRUPAL_ROOT not being defined. Here's the fix. Again not sure how to test this but the command is now more robust. It works both with and without a sites/default/settings.testing.php and sites/default/settings.php.
Comment #96
alexpottLet's just decouple test site tear down from being able to bootstrap the Drupal test site. This means that the test could break Drupal completely and the tear down still be successful. Which seems like a good idea to me.
Comment #97
mglamanI ran through #96 locally a few times. Works like a charm without errors, and cleans up!
And the SQLite file was removed (only had ones from previous errors
Comment #98
mglamanGoing to pull the RTBC trigger. The initial bugs I found have been addressed by alexpott. It's also more stable around general failures that could occur and prevent clean up.
Comment #99
dawehnerShould we add a todo to point to the symfony file component or our own standalone file component one day?
Comment #100
alexpott@dawehner I dunno that all feels a little bit of a wishful @todo. If we do introduce either of those it'll be the job of that work to do replace things like
file_unmanaged_delete_recursive()and we have an@seehere so I think we're good.Comment #101
dawehnerThat is a good point.
Comment #102
alexpottIn testing with https://github.com/jsdrupal/nightwatch I've discovered one area of complexity. This command requires simpletest/sites to exist and to be writable. If the command is run as a user that can create this then it does so all good. But in reality we need the command to be run by the user running the webserver so I think we should be a bit more defensive and helpful here because people are likely to see an exception.
Comment #103
alexpottHere's a fix for that. This is not testable unfortunately because we can't use a virtual filesystem :(
Here's what happens if the command can't write or create sites/simpletest:
Comment #104
mglaman#103 is a good catch, bumping back to RTBC.
There isn't a good way to test it, and it is a good use case. We currently have the following in our CircleCI config because Functional tests fail when it isn't writeable and I think I recall it having a similar message.
Comment #105
alexpottRealised one thing. When we create a test site if RUN_TESTS_CONCURRENCY is greater than 1 we create a lock file so that no other test site gets the same db prefix. So if we do concurrent testing under nightwatch, and that takes place outside of run-tests.sh, we're going to need to handle this. Both to use the locking solution and somehow clear it up. Given we're not aiming for that here not sure we need to do anything on this issue. But it felt important to note so that others know.
Comment #106
MixologicIt might be that we'll need some kind of concurrency handler for nightwatch tests like run-tests.sh does for php tests.
Comment #107
alexpott@Mixologic well we're still using the TestDatabase class so as long as this sets RUN_TESTS_CONCURRENCY to something greater than one than we'll get locking and ensured uniqueness. So #105 is more about just keeping people informed that we need to think about setting that in concurrent situations. And think about tearing it down. That said we could implement a --lock file flag on the commands to lock and clean up the lock.
Patch attached addresses a weakness @dawehner noticed. We should ensure we only clean up stuff inside of drupal root.
Comment #108
alexpottBeen thinking about the locking stuff a bit more. I think this command should use a different database prefix from the current
test12345678. And it should always create a lock.Comment #109
alexpottHere's a solution with locking in place. This will allow Nightwatch to use multiple workers and we can clean up all the locks at the end. I think it is important that we follow run-tests.sh example and not re-use prefixes during tests since this further isolates tests from weird random fails. It does mean that run-tests.sh and Nightwatch should not run in parallel with each other but I think this is acceptable.
Also we can completely refactor the commands and application to never use the autoloader - which in my opinion is nice.
Comment #110
alexpottDiscussed further with @dawehner we agreed to file to explore always locking. Created #2946439: TestDatabase should always lock to follow this up.
Comment #111
dawehnerOH I see, so this enables to release all locks manually at the end of a concurrent run, but also release individually. For the individual releasing I would have expected that they are done in the tear-down, so it feels like there would be no need to have a dedicated command for it.
Comment #112
alexpott@dawehner so add an option to teardown to clear the lock. Makes sense. Still means we can't test releasing all the locks but that's okay I guess.
Comment #113
alexpottImplemented #112. Now when tearing down you have an option to keep the lock. So the default behaviour is as expected ie it'll remove the lock but if you are implementing concurrent testing and you want to ensure isolation you can keep the locks after tear down.
Comment #114
dawehnerThis is much nicer!
Is it just me that having a short option isn't really needed here? How often would we want to keep the lock?
Comment #115
dawehnerAddressed my own feedback + some minor points.
Comment #116
alexpott@dawehner nice finds. I don't think I can rtbc this myself since many of the changes since the last rtbc are mine but I think we've proved over on the Nightwatch branch this is works. Yes there are additions to make like the support for installing modules without needing a custom script but these will be better to be teased out when we actually write Nightwatch tests rather than guessing upfront. At least with the script we can do any setup tasks required.
Comment #117
jibranI agree with #116.
Comment #118
MixologicAlso, its *really* quite quick. I was surprised when running the nightwatch test that it ran in < 5 sec. Thats fantastic.
Comment #119
dawehnerI opened up a followup: #2948256: Cache the result of test-site.php
Comment #120
mglamanI like this. There are definitely other ways to improve, as stated in #116. But I think those need to be solved by use cases.
The test script isn't even horrible, in my opinion. I experimented with this patch and Nightwatch testing and the test script results are here: https://github.com/mglaman/drupal-commerce-nightwatch/tree/commerce-expe...
Worked like a charm.
+1!
Comment #121
dawehnerComment #122
wim leersThis is confusing. Can we document why it needs to work this way?
Shouldn't this be executable?
❤️
Nit: s/drupal/Drupal/. Fixed.
What's this
'0.1.0'?This also shows up when executing it:
Other than that, ❤️ this script and its output!
WOAH, TIL! 👀
This is not used anywhere? Not sure if it can be removed, or if some code needs to be added.
Nice!
❤️ strict validation, that verifies the script's assumptions are met, thus helping to prevent a developer from getting confused and having to dig into details!
Nits:
- s/full/fully/
- s/setup/set up/
Fixed.
Missing test coverage. I think we could test this at the end of
\Drupal\Tests\Scripts\TestSiteApplicationTest::testInstallScript()?Done.
Nit: s/filepath/path/. Fixed.
I don't understand "this version"?
Nit: Missing
stringtypehint. Fixed.Nit: we avoid "you" in code comments AFAIK. Fixed.
Supernit: s/an/a/. Fixed.
❤️
TIL!
❤️
Nit: s/for tear/for the tear/
Fixed.
Nit: s/ensure tear down only/ensure the tear down command only/
Fixed.
❤️
Missing the fact that we're explicitly keeping the lock during the tear down. Fixed.
Nit: s/other site installed/other site/. Fixed.
Nit: s/is clean up during/'s lock is released during/. Fixed.
Comment #123
alexpottre #122.11 we can't test that because you'll delete all the real test locks :) and potentially cause random fails.
Comment #124
alexpottUnfortunately this need to go :(
Comment #125
alexpottSo we also need to address #122 1, 2, 5, 7, 13
Re 1. I'm not sure what more you want here. It has to work this way because it is being using by DrupalCI / run-test.sh to run with a concurrency of 31.
Re 2. I dunno for me I always run it like
php core/scripts/test-site.php installthat does not need it to be executable.Re 5. It's the command version - we set it to 0.1.0 because this is an internal test running command and not part of the API until we can a chance to use it properly.
Re 7. It's used in \Drupal\Core\Test\FunctionalTestSetupTrait::prepareEnvironment - i.e. by one of the traits - it's not defined there for legacy annoying reasons.
Re 13. version I guess was about this version of this method ... but it makes more sense when version is replaced with method. This is as opposed to file_unmanaged_delete_recursive() which does have dependencies on Drupal and it's container.
Comment #126
alexpottAddressed #124 and #122.1 (hopefully), 5, 7, and 13.
Comment #127
wim leersI think it's very confusing that we accept a parameter to determine behavior, but then sometimes choose to ignore that parameter anyway. I think it'd then be better to NOT have a parameter, and just rely on
getenv(…)always.RE: 2: ok, w/e for now. It's inconsistent already in our existing scripts: some are executable, some are not.
Everything else, and all patch changes make sense. 👍
Can we then at least document either on the command itself or in the place where the test coverage was just removed why we cannot test this?
Comment #128
alexpott@Wim Leers the problem is we're not setting concurrency here (it's a run-tests.sh concept) but we need locking. #2946439: TestDatabase should always lock addresses the issue and will make it simpler.
Did that already...
Comment #129
wim leersSorry, overlooked that!
Back to RTBC 👍
Can't wait!
Comment #130
dawehnerAfter looking at the latest review from lendude on https://www.drupal.org/project/drupal/issues/2869825 I talked with @alexpott and we came to the conclusion that specifiying the classname is a worse DX than specifying the
\\\\File\\\Name\\\\We should optimize for DX, not for the internal complexity of the code. SorryComment #131
alexpottChanged --setup_class to --setup_file and added testing around the new expectation of that being a file that contains a class.
Comment #132
dawehnerNice work @alexpott!
Comment #133
dawehnerWhile updating I realized that the current patch forces you to execute it from within the Drupal root. Let's avoid that.
Comment #135
MixologicLast failure looks like a FunctionalJavascript Randofail. Requeued.
Comment #136
alexpottNice fix @dawehner.
Comment #137
alexpottOver in #2911319: Provide a single command to install & run Drupal we've standardised on
-instead of_and I think this makes sense. It is the standard for console commands. It is used by composer and phpcs and drush.Leaving at rtbc because this is a cosmetic change.
Comment #138
dawehnerThank you alex for updating the patch! +1
Comment #140
lendudeUnrelated fails
Comment #141
dawehnerGiven that #2869825: Leverage JS for JS testing (using nightwatch) is major, this issue should be major too, as it is blocking it.
Comment #142
webchickAgreed.
Comment #143
larowlanTook this for a test drive, only question - should we have a --json option for this too?
Comment #144
alexpott@larowlan re json output - we don't need one atm - can always add one later if we need it. But there's nothing to consume in terms of info. If you want to know whether a tear down is successful - you can check the exit status.
Comment #145
larowlanadding review credits
Comment #146
larowlanCommitted to 8.6.x and published change notice.
Thanks
Comment #148
dawehnerThank you @larowlan!!
Comment #149
garrettw commentedOne test written for this issue is causing a build failure for the D8 Composer template (drupal-composer/drupal-project). As you can see, the failures started happening right after the file referenced below was committed.
Here is the PHPUnit output:
The desired string cannot be found in that output because the output contains a line break and extra spaces in the middle of it, throwing it off.
Comment #150
webflo commentedI created a issue for it. #2960214: TestSiteApplicationTest fails on sites with long base path
Comment #151
garrettw commentedThanks :)
Comment #152
mile23Little bit of a follow-up: #2962157: TestSiteApplicationTest requires a database despite being a unit test