Problem/Motivation
In the process of debugging a failing test in the DateTime Range module (issue forthcoming), I observed that the test loops over several edgecase timezones, but does not report which timezone is being tested. It would have been really helpful to know (for example) if this particular fail is always related to the Pacific/Tongatapu timezone each of the times I've seen it, or if was related only to (e.g.) the request time, with the timezone different between the fails I've seen.
Proposed resolution
Add the timezone to assertion messages and entity labels for relevant test code that loops over timezones.
Here's one line I added (for example):
$edit = array(
+ 'name[0][value]' => $timezone . ' ' . $this->randomMachineName(),
"{$field_name}[0][value][date]" => $start_date->format($date_format),
"{$field_name}[0][end_value][date]" => $start_date->format($date_format),
For the assertion messages, we could either add the timezone manually to relevant assertions, or do something fun with storing the current timezone on the class and overriding TestBase::assert()
in the datetime test base class. The first option would be easier with a bit of refactoring since a number of methods seem to repeat similar test operations, but that would be a lot more work.
Remaining tasks
TBD
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff-12-14.txt | 2.1 KB | mpdonadio |
#14 | 2829845-14.patch | 13.07 KB | mpdonadio |
#12 | 2829845-12.patch | 13.07 KB | jofitz |
Comments
Comment #2
xjmComment #3
xjmComment #4
xjmFor extra debugging glory we could also record the timestamp.
Comment #5
mpdonadioFirst pass at adding an assertion that we set the TZ properly when we are looping, and to add extra debug to the formatter assertion messages. Think I got them all in the field tests; may also want this in the views tests where we do the TZ loop.
Adding the actual timestamp may be beneficial, but it may cause more harm than good because of the how the date-only fields get handled because the time portion isn't always relevant (#2829848: Random test failure in DateRangeFieldTest will expand on this more if my hypothesis is correct).
Comment #8
mpdonadioBack to NR based on latest run on fixed bots.
Comment #11
jhedstromNeeds a reroll since the tests have been converted to phpunit.
Comment #12
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-rolled.
Comment #13
jhedstromSorry I missed this earlier. This should use the non-deprecated
assertEquals
method.And ditto on these 2.
Comment #14
mpdonadioHere we go.
Comment #15
jhedstromLooks good!
Comment #18
xjmThese reformatted test assertions are easier to read, but most of them are completely out of scope. So are the removals of the deprecated SafeMarkup class.
Speaking of scope, an out-of-scope thing here would be that all of should probably use
assertText()
and remove the use ofFormattableMarkup
.But, hey, this is a really good change and should be a big help when debugging with this test. I decided not to hold it back for fixing the scope. I'll just leave a reminder to make sure your other cleanups go in separate patches.
Committed to 8.5.x and backported to 8.4.x as a testing improvement. Thanks!