Page MenuHomePhabricator

Wikibase CI broken: Call to undefined method WikibaseLibraryTestCase::suite()
Closed, ResolvedPublic

Description

Seen e.g. in this build for this empty change:

> MediaWiki\Composer\PhpUnitSplitter\PhpUnitXmlManager::listTestsNotice

Running `phpunit --list-tests-xml` to get a list of expected tests ... 

> Composer\Config::disableProcessTimeout
Using PHP 8.3.30
Running with MediaWiki settings because there might be integration tests
PHP Fatal error:  Uncaught Error: Call to undefined method Wikibase\Client\Tests\Integration\DataAccess\Scribunto\WikibaseLibraryTestCase::suite() in /workspace/src/extensions/WikibaseLexeme/tests/phpunit/mediawiki/Scribunto/WikibaseLexemeLibraryTestCase.php:72
Stack trace:
#0 [internal function]: Wikibase\Lexeme\Tests\MediaWiki\Scribunto\WikibaseLexemeLibraryTestCase::suite()
#1 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(486): ReflectionMethod->invoke()
#2 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(537): PHPUnit\Framework\TestSuite->addTestFile()
#3 /workspace/src/tests/phpunit/suites/ExtensionsTestSuite.php(37): PHPUnit\Framework\TestSuite->addTestFiles()
#4 /workspace/src/tests/phpunit/suites/ExtensionsTestSuite.php(46): ExtensionsTestSuite->__construct()
#5 [internal function]: ExtensionsTestSuite::suite()
#6 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(486): ReflectionMethod->invoke()
#7 /workspace/src/vendor/phpunit/phpunit/src/TextUI/TestSuiteMapper.php(84): PHPUnit\Framework\TestSuite->addTestFile()
#8 /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php(391): PHPUnit\TextUI\TestSuiteMapper->map()
#9 /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php(114): PHPUnit\TextUI\Command->handleArguments()
#10 /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php(99): PHPUnit\TextUI\Command->run()
#11 /workspace/src/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()
#12 /workspace/src/vendor/bin/phpunit(122): include('...')
#13 {main}

Next PHPUnit\TextUI\RuntimeException: Call to undefined method Wikibase\Client\Tests\Integration\DataAccess\Scribunto\WikibaseLibraryTestCase::suite() in /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php:101
Stack trace:
#0 /workspace/src/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()
#1 /workspace/src/vendor/bin/phpunit(122): include('...')
#2 {main}
  thrown in /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php on line 101

Looks similar to T411340: Call to undefined method MediaWikiIntegrationTestCase::suite() in extensions/JsonConfig/tests/phpunit/JCLuaLibraryTest.php:48 – but in this case Scribunto should be available AFAICT (it’s mentioned as being cloned).

Event Timeline

Instead, each test class becomes abstract with two concrete subclasses
(*SandboxTest/*StandaloneTest) that implement getEngineName(). Engine
availability is checked via markTestSkipped() in setUp(). Group
annotations (@group Lua, LuaSandbox, LuaStandalone, Standalone) are
placed on the concrete subclasses.

@Arendpieter do we need to do this in every extension with Scribunto tests as well? (I tried to remove WikibaseLexeme’s use of parent::suite() but it’s just giving me other errors like “LogicException: Wikibase\Lexeme\Tests\MediaWiki\Scribunto\WikibaseLexemeEntityFormLibraryTest must implement getEngineName()”.)

Change #1247121 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@master] Adapt to Scribunto test changes (split tests, no more suite())

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

Argh, sorry, forgot that these horrible mal-adapted tests were re-used in Wikibase code.

Sorry, I didn’t realize that the same pattern is also in the WikibaseLexeme repository. Does Gerrit allow searching across all repositories?

Sorry, I didn’t realize that the same pattern is also in the WikibaseLexeme repository. Does Gerrit allow searching across all repositories?

Best tool for this is https://codesearch.wmcloud.org/search/ which will let you find uses across many codebases including some on GitLab.

Yup, https://codesearch.wmcloud.org/search/?q=public+static+function+suite%5C%28 finds the suite() override in WikibaseLexeme and a handful of unrelated ones in core. (You can also limit the search to subsets of repositories, e.g. “MediaWiki & services at WMF”.)

Some extensions does not implement suite(), but extends LuaEngineTestBase which could be fail as well due to new getEngineName function.
(Like FlaggedRevs)

When there are class checks for LuaEngineTestBase or "fake class" implementation, please keep them or move to the non-TestBase class as tests should be runnable without Scribunto installed.

What is the status here? For math it seems that there are two different issues that brake CI tests. I tested making the latest change in Math dependent on the proposed fix, but that was not enough for the tests to pass.

I thought this was only blocked by the MinervaNeue browser test, but there seems to be yet another issue.

10:07:21 There was 1 failure:
10:07:21 
10:07:21 1) Wikibase\Repo\Tests\RepoHooksTest::testOnContentModelCanBeUsedOn with data set "Wikitext on a page with an entity in a slot" ('wikitext', MediaWiki\Title\TitleValue Object (...), true)
10:07:21 Failed asserting that null is identical to 'slottedEntityType'.
10:07:21 
10:07:21 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/RepoHooksTest.php:485
10:07:21 /workspace/src/extensions/Wikibase/repo/tests/phpunit/includes/RepoHooksTest.php:465

https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php84/549/console

This seems to be an independent issue that only occurs in the PHP 8.4 job. I'll make another task...

Change #1247121 merged by Jforrester:

[mediawiki/extensions/WikibaseLexeme@master] Adapt to Scribunto test changes (split tests, no more suite())

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

FWICT this is now fully Resolved?

Well, Wikibase CI is still (or again?) broken due to the Scribunto changes, but it’s a slightly different issue: T419371: Test failure in quibble-with-WikibaseClient-extensions-tests-php83 - Capiunto extension