The patch adds a new output format for run-tests.sh that is actually useful when parsed by jenkins and the junit plugin. It builds on what drupalci does and the drush patch.

php scripts/run-tests.sh --url http://localhost/ --junit tests Session

gives something like:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite tests="151" disabled="0" errors="11" failures="45">
  <testcase name="setUp()" assertions="2" classname="Session.Session HTTPS handling" status="pass">
    <system-out><![CDATA[pass:      [Other] Enabled modules: session_test [session.test:304]
pass:      [Other] Enabled modules: session_test [session.test:304]
]]></system-out>
  </testcase>
  <testcase name="testHttpsSession()" assertions="123" classname="Session.Session HTTPS handling" status="failed">
    <failure type="fail" message="Number of failed assertions: 35"><![CDATA[fail:      [Other] Failed to set field name to htF3iJoI [session.test:327]
…]]></failure>
    <error type="exception" message="Number of unexpected errors: 11"><![CDATA[exception: [Notice] Undefined index: SSESS49960de5880e8c687434170f6476605b [session.test:337]
…]]></error>
    <system-out><![CDATA[pass:      [Role] Created role of name: aum4bHeD, id: 4 [session.test:319]
…]]></system-out>
  </testcase>
  <testcase name="simpletest_script_run_one_test()" assertions="2" classname="Session.Session HTTPS handling" status="failed">
    <failure type="fail" message="Number of failed assertions: 2"><![CDATA[fail:      [Other] Failed to find test tables to drop. [run-tests.php:395]
fail:      [Other] Failed to find test tables to drop. [run-tests.php:395]
]]></failure>
    <system-out><![CDATA[fail:      [Other] Failed to find test tables to drop. [run-tests.php:395]
fail:      [Other] Failed to find test tables to drop. [run-tests.php:395]
]]></system-out>
  </testcase>
  <testcase name="testEmptySessionId()" assertions="25" classname="Session.Session HTTPS handling" status="failed">
    <failure type="fail" message="Number of failed assertions: 8"><![CDATA[fail:      [Other] Failed to set field name to pYgID2r7 [session.test:509]
…]]></failure>
    <system-out><![CDATA[pass:      [Role] Created role of name: w2Ta0jei, id: 4 [session.test:496]
…]]></system-out>
  </testcase>
</testsuite>

Comments

nod_ created an issue. See original summary.

Mixologic’s picture

$assertion_result = preg_replace('/[^\x{0009}\x{000A}\x{000D}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', '�', $assertion_result);

This is a self defense against improper xml characters.

mile23’s picture

Making the testbot's junit export code more portable here: #2856398: Refactor JUnit XML generation into a helper class

nod_’s picture

@Mixologic, I would expect cdata sections to handle whatever is inside properly. Is this for display or does it break the xml?

Mixologic’s picture

The CDATA section prevents parsers from interpreting the enclosed data as markup, however, xml specification itself does not allow for a many characters to appear anywhere within either cdata or in markup, and thus breaks many parsers.

I definitely ran into this early on with drupalci, and had to hunt this down to end up with no parsing issues.

nod_’s picture

StatusFileSize
new7.31 KB
new775 bytes

Gotcha, updated.

Still D7 patch.

Status: Needs review » Needs work

The last submitted patch, 6: core-run-tests-junit-2834033-6.patch, failed testing.

mile23’s picture

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.