Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-34893

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

    Details

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

      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.

        Gliffy Diagrams

          Activity

          Hide
          salvetore Michael de Raadt added a comment -

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

          Show
          salvetore Michael de Raadt added a comment - David: Was it you that introduced these wonderful features? If not, please reassign to Petr.
          Hide
          timhunt 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
          timhunt 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
          skodak Petr Skoda added a comment -

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

          Show
          skodak Petr Skoda added a comment - Arrgggh, this was one of the nastiest hacks I ever did in PHP...
          Hide
          timhunt 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
          timhunt 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
          skodak Petr Skoda added a comment -

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

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

          done

          Show
          skodak Petr Skoda added a comment - done
          Hide
          timhunt Tim Hunt added a comment -

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

          Show
          timhunt Tim Hunt added a comment - Indeed. And thanks for making it work. A belated +1 from me.
          Hide
          stronk7 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
          stronk7 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
          skodak Petr Skoda 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
          skodak Petr Skoda 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
          stronk7 Eloy Lafuente (stronk7) added a comment -

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

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

          Integrated (23 & master), thanks!

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

          Passed. Thanks!

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

          YEAR!*

          CAF*, TOT!*

          • Your effort amazingly resulted. (unbelievable :-P)
          • Closing as fixed.
          • Tons of thanks.
          Show
          stronk7 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:
                Fix Release Date:
                10/Sep/12