Created page with "== in a Docker Container == After you clone the code for SemanticMediaWiki and initialize the build submodule, you should be able to use '''make''' for various activities. <code>make bash</code> puts you into a bash shell as root in the wiki container Change to the SMW directory if instead you are at the document root of <tt>/var/www/html</tt><br> <code> cd extensions/SemanticMediaWiki</code><br> <pre> root@2421517631d1:/var/www/html/extensions/SemanticMediaWiki# </pre..." |
No edit summary |
||
Line 25: | Line 25: | ||
<pre>SMW\Tests\Integration\JSONScript\JSONScriptTestCaseRunnerTest::testCaseFile"a-0001.json"</pre> | <pre>SMW\Tests\Integration\JSONScript\JSONScriptTestCaseRunnerTest::testCaseFile"a-0001.json"</pre> | ||
But | But you can't simply pass these test names to the <code>--filter</code> option of PHPUnit when trying to '''run''' the tests. This<br> | ||
<code>php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --filter SMW\Tests\Integration\JSONScript\JSONScriptTestCaseRunnerTest::testCaseFile"a-0001.json"</code><br> | <code>php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --filter SMW\Tests\Integration\JSONScript\JSONScriptTestCaseRunnerTest::testCaseFile"a-0001.json"</code><br> | ||
Line 32: | Line 32: | ||
No tests executed! | No tests executed! | ||
</pre> | </pre> | ||
because the value is not delimited and wouldn't work "as is". The required format of the <tt>--filter</tt> parameter is defined as basically equivalent to the __METHOD__ magic constant. The expected parameter value is a '''pattern''', so if not enclosed in delimiters, the '/' delimiter will '''automatically''' be added. [https://docs.phpunit.de/en/9.6/textui.html See the v9.6 docs] | |||
From the docs, valid <code>--filter</code> parameter examples are: | |||
<pre> | |||
--filter 'TestNamespace\\TestCaseClass::testMethod' | |||
--filter 'TestNamespace\\TestCaseClass' | |||
--filter TestNamespace | |||
--filter TestCaseClass | |||
--filter testMethod | |||
--filter '/::testMethod .*"my named data"/' | |||
--filter '/::testMethod .*#5$/' | |||
--filter '/::testMethod .*#(5|6|7)$/' | |||
</pre> | |||
So, to properly invoke the above test, you could add single quotes and explicit delimiters with the name of the method plus use a wildcard in the pattern: | |||
<code>php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --filter '/::testCaseFile .*0001.json/'</code><br> | |||
or broaden the scope with a "pattern" that matches the class name - in which case all such tests would run (about 300). | |||
<code>php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --filter JSONScriptTestCaseRunnerTest</code> |
Revision as of 16:10, 10 February 2025
in a Docker Container[edit]
After you clone the code for SemanticMediaWiki and initialize the build submodule, you should be able to use make for various activities.
make bash
puts you into a bash shell as root in the wiki container
Change to the SMW directory if instead you are at the document root of /var/www/html
cd extensions/SemanticMediaWiki
root@2421517631d1:/var/www/html/extensions/SemanticMediaWiki#
Now you can manually interact with PHPUnit from the command line to accomplish precise objectives without having to wade through volumes of data and spend huge amounts of time waiting for entire test runs.
php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --list-tests
lists the ~8800 tests such as:
SMW\Tests\Integration\SpecialsTest::testValidCovers
If you pipe it through grep, you can filter out the tests you want to run:
|grep JSONScript
such as
SMW\Tests\Integration\JSONScript\JSONScriptTestCaseRunnerTest::testCaseFile"a-0001.json"
But you can't simply pass these test names to the --filter
option of PHPUnit when trying to run the tests. This
php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --filter SMW\Tests\Integration\JSONScript\JSONScriptTestCaseRunnerTest::testCaseFile"a-0001.json"
only produces the result
No tests executed!
because the value is not delimited and wouldn't work "as is". The required format of the --filter parameter is defined as basically equivalent to the __METHOD__ magic constant. The expected parameter value is a pattern, so if not enclosed in delimiters, the '/' delimiter will automatically be added. See the v9.6 docs
From the docs, valid --filter
parameter examples are:
--filter 'TestNamespace\\TestCaseClass::testMethod' --filter 'TestNamespace\\TestCaseClass' --filter TestNamespace --filter TestCaseClass --filter testMethod --filter '/::testMethod .*"my named data"/' --filter '/::testMethod .*#5$/' --filter '/::testMethod .*#(5|6|7)$/'
So, to properly invoke the above test, you could add single quotes and explicit delimiters with the name of the method plus use a wildcard in the pattern:
php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --filter '/::testCaseFile .*0001.json/'
or broaden the scope with a "pattern" that matches the class name - in which case all such tests would run (about 300).
php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --bootstrap tests/bootstrap.php --filter JSONScriptTestCaseRunnerTest