Moodle
  1. Moodle
  2. MDL-34893

PHPunit command-line options --debug --colors and --verbose ignored

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.1, 2.4
    • Fix Version/s: 2.3.2
    • Component/s: Unit tests
    • Labels:
    • Rank:
      43418

      Description

      I don't know if this is bugs in our code, or in core PHP unit. Anyway, these options should do useful things. E.g. --debug outputs the name of each test before running it, which is helpful when you get weird crashes, but adding that has no effect when running the Moodle tests.

      I think this may acutally be a core PHPunit bug. If you look at https://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/TextUI/Command.php#L740, it does not pass any of the options to the printer class constructor, and I cannot see any other way for those options to be set.

        Activity

        Hide
        Michael de Raadt added a comment -

        David: Was it you that introduced these wonderful features? If not, please reassign to Petr.

        Show
        Michael de Raadt added a comment - David: Was it you that introduced these wonderful features? If not, please reassign to Petr.
        Hide
        Tim Hunt added a comment -

        Those settings are a standard part of PHPunit: http://www.phpunit.de/manual/current/en/textui.html#textui.clioptions. I see no reports in the PHPunit issues list to say that they do not work in general, so probably something in the Moodle bootstrap system is getting in the way.

        Show
        Tim Hunt added a comment - Those settings are a standard part of PHPunit: http://www.phpunit.de/manual/current/en/textui.html#textui.clioptions . I see no reports in the PHPunit issues list to say that they do not work in general, so probably something in the Moodle bootstrap system is getting in the way.
        Hide
        Petr Škoda added a comment -

        Arrgggh, this was one of the nastiest hacks I ever did in PHP...

        Show
        Petr Škoda added a comment - Arrgggh, this was one of the nastiest hacks I ever did in PHP...
        Hide
        Tim Hunt added a comment -

        That is, indeed, a fairly nasty hack. However, I suggest you tone down the class/method names a little bit.

        Show
        Tim Hunt added a comment - That is, indeed, a fairly nasty hack. However, I suggest you tone down the class/method names a little bit.
        Hide
        Petr Škoda added a comment -

        This point is to use very weird method name so that it never collides with upstream...

        Show
        Petr Škoda added a comment - This point is to use very weird method name so that it never collides with upstream...
        Hide
        Petr Škoda added a comment -

        done

        Show
        Petr Škoda added a comment - done
        Hide
        Tim Hunt added a comment -

        Indeed. And thanks for making it work. A belated +1 from me.

        Show
        Tim Hunt added a comment - Indeed. And thanks for making it work. A belated +1 from me.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Petr, I've tried the --debug option with the default printer and it seems to work, getting "Starting test 'xxxxx" messages. But our printer does not observe that option.

        Same for the --colors option, I get red "F"s and final "FAILURES!" for failed tests using the default printer but no colors at all using our printer.

        BUT I only get them working when ALL the tests are executed, not if I specify some dir/class.

        After applying the dirty hack... I get --debug and --colors working with our Hinted printer... BOTH running ALL tests and individual ones.

        The question are:

        1) why does the default printer work for ALL tests and not for individual? It seems to indicate that, in some way, sometimes, it's able to "get" those CLI options.
        2) if the default printer is able to get those CLI options... why our printer does not? Isn't the default printer handled with handlePrinter() too?
        3) Should we report this issue to https://github.com/sebastianbergmann/phpunit/issues and then put some note in code pointing to it? Just to be able to take out the hack in the future.

        I'll keep this open for some hours...ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Petr, I've tried the --debug option with the default printer and it seems to work, getting "Starting test 'xxxxx" messages. But our printer does not observe that option. Same for the --colors option, I get red "F"s and final "FAILURES!" for failed tests using the default printer but no colors at all using our printer. BUT I only get them working when ALL the tests are executed, not if I specify some dir/class. After applying the dirty hack... I get --debug and --colors working with our Hinted printer... BOTH running ALL tests and individual ones. The question are: 1) why does the default printer work for ALL tests and not for individual? It seems to indicate that, in some way, sometimes, it's able to "get" those CLI options. 2) if the default printer is able to get those CLI options... why our printer does not? Isn't the default printer handled with handlePrinter() too? 3) Should we report this issue to https://github.com/sebastianbergmann/phpunit/issues and then put some note in code pointing to it? Just to be able to take out the hack in the future. I'll keep this open for some hours...ciao
        Hide
        Petr Škoda added a comment -

        No idea why default printer breaks. Custom printer handling is very hacky there imho, I am going to try to fix the printer support and create a new issue for it upstream.

        Show
        Petr Škoda added a comment - No idea why default printer breaks. Custom printer handling is very hacky there imho, I am going to try to fix the printer support and create a new issue for it upstream.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Oki, after chat with Petr let's make this land, thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Oki, after chat with Petr let's make this land, thanks!
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Integrated (23 & master), thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Integrated (23 & master), thanks!
        Hide
        Frédéric Massart added a comment -

        Passed. Thanks!

        Show
        Frédéric Massart added a comment - Passed. Thanks!
        Hide
        Eloy Lafuente (stronk7) added a comment -

        YEAR!*

        CAF*, TOT!*

        • Your effort amazingly resulted. (unbelievable :-P)
        • Closing as fixed.
        • Tons of thanks.
        Show
        Eloy Lafuente (stronk7) added a comment - YEAR!* CAF*, TOT!* Your effort amazingly resulted. (unbelievable :-P) Closing as fixed. Tons of thanks.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: