Skip to content

"printerFile" relative paths behavior causing some problems #582

Closed

Description

@stronk7

Hi,

it seems that using "printerFile" relative paths in phpunit.xml leads to some problems / restricts how tests can be executed.

This is part of the phpunit.xml we generate for the root of the project:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="lib/phpunit/phpunit.xsd"
    bootstrap="lib/phpunit/bootstrap.php"
    ....
    ....
    printerClass="Hint_ResultPrinter"
    printerFile="lib/phpunit/classes/hint_resultprinter.php"
    >
<testsuites>
 ....
 ....

And, this one example for the phpunit corresponding to one plugin/module (/mod/forum, 2 dirs deeper):

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../lib/phpunit/phpunit.xsd"
    bootstrap="../../lib/phpunit/bootstrap.php"
    ....
    ....
    printerClass="Hint_ResultPrinter"
    printerFile="../../lib/phpunit/classes/hint_resultprinter.php"
    >
<testsuites>
 ....
 ....

Using those phpunit files we are able to run:

cd /path/to/rootdir && phpunit
cd /path/to/rootdir/mod/forum && phpunit

But any of these fail with error: "Could not use "Hint_ResultPrinter" as printer."

cd /path/to/rootdir && cd .. && phpunit -c rootdir
cd /path/to/rootdir && cd .. && phpunit -c rootdir/phpunit.xml
cd /path/to/rootdir && phpunit -c mod/forum
cd /path/to/rootdir && phpunit -c mod/forum/phpunit.xml

And they were working ok before introducing the custom ResultPrinter in phpunit.xml. Also note that we use the relative path for the bootstrap and is working perfectly, so it would be desirable to get also the printerFile supporting those relatives.

For reference:

Ciao :-)

Activity

  1. edorian commented on Jun 5, 2012

    @edorian
    SponsorContributor

    Thanks for the report. There have been a couple of issues with relative/absolute on other parts of the config.

    To sum up and to see if i understood you right:

    You'd assume the path to the file is realtive to the phpunit.xml location and not to the current working directory?

    I agree on that. I need to look at the code to find a way to make that happen without any bc break. Maybe check both pathes or something.

    Thanks for the report :)

  2. stronk7 commented on Jun 6, 2012

    @stronk7
    ContributorAuthor

    Yup, I think "relative to the phpunit.xml" is the goal. That enables them being invoked from anywhere.

    Thanks!

  3. locked as resolved and limited conversation to collaborators on Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions