Page MenuHomePhabricator

MediaWikiTestCase::hideDeprecated() does not reset between tests
Closed, ResolvedPublic

Description

In the test suite, when one uses hideDeprecated(), the deprecated warning will be ignored for the rest of the test run. That can cause an unexpected deprecated warning when the tests are being run in a different order

I have hit that in REL1_30 which has WatchedItem methods deprecated (T182381). The suite has two tests cases:

WatchedItemIntegrationTesthides deprecated
WatchedItemUnitTestdoes NOT hide them

On CI they are executed in that order, hence the deprecated methods are already hidden when WatchedItemUnitTest is run. On my local machine, WatchedItemUnitTest got to run first and thus raised warnings failling the test run.

The fix was to copy paste the hideDeprecated() notice to WatchedItemUnitTest: https://gerrit.wikimedia.org/r/#/c/423469/

I guess whenever we use hideDeprecated(), we should make sure we reset the deprecation list. Possibly in MediaWikiTestCase::tearDown() by invoking MWDebug::clearLog() (though that also clear the log).

hideDeprecated has been introduced in a108dbfe8f7f20f22d6513838022d50bbdc17165.

Event Timeline

Change 461977 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] Ensure disabled deprecation warnings are re-enabled before next test

https://gerrit.wikimedia.org/r/461977

Change 462718 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] OutputPageTest: Don't rely on side effects of previous tests

https://gerrit.wikimedia.org/r/462718

Change 462718 merged by jenkins-bot:
[mediawiki/core@master] OutputPageTest: Don't rely on side effects of previous tests

https://gerrit.wikimedia.org/r/462718

Change 461977 merged by jenkins-bot:
[mediawiki/core@master] Ensure disabled deprecation warnings are re-enabled before next test

https://gerrit.wikimedia.org/r/461977