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

moodle_progress behat formatter fails with --dry-run

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      OPTIONAL: This step (ZERO) is only needed to test the solution if the issue has not been integrated and the v1.29.2 version of the behat extension does not exist yet)

      ZERO) Edit your composer.json to use the patched behat extension:

           "repositories" : [
               {
                   "type": "vcs",
      -            "url": "https://github.com/moodlehq/moodle-behat-extension"
      +            "url": "https://github.com/stronk7/moodle-behat-extension"
               }
           ],
           "require-dev": {
               "phpunit/phpunit": "3.7.*",
               "phpunit/dbUnit": "1.2.*",
      -        "moodlehq/behat-extension": "1.29.0"
      +        "moodlehq/behat-extension": "dev-MDL-48356"
           }
       }
      

      1) Init the behat installation

      2) run any tag/name, for example: --tags='@mod_choice' (with Firefox)

      3) Verify the "Moodle 2.9dev (Build:...." information is printed at the beginning and also the "Server OS "xxxx", Browser: "firefox"" one.

      4) The run ends ok with the number of scenarios and steps at the end.

      5) run the same test with Chrome

      6) Verify that all the information in 4) is printed and also the "Browser specific fixes have been applied..." is shown.

      7) The run ends ok with the number of scenarios and steps at the end

      8) Run the same test with --dry-run and Chrome.

      9) Verify that all the information in 6) is printed (including the "Browser specific..." phrase). Also verify that all the steps are skipped and that, at the end, the number of scenarios and steps is shown (all skipped).

      Note the number of steps can be smaller with dry-runs, np with that. But number of scenarios must match. (11 right now for @mod_choice).

      Show
      OPTIONAL: This step (ZERO) is only needed to test the solution if the issue has not been integrated and the v1.29.2 version of the behat extension does not exist yet) ZERO) Edit your composer.json to use the patched behat extension: "repositories" : [ { "type": "vcs", - "url": "https://github.com/moodlehq/moodle-behat-extension" + "url": "https://github.com/stronk7/moodle-behat-extension" } ], "require-dev": { "phpunit/phpunit": "3.7.*", "phpunit/dbUnit": "1.2.*", - "moodlehq/behat-extension": "1.29.0" + "moodlehq/behat-extension": "dev-MDL-48356" } } 1) Init the behat installation 2) run any tag/name, for example: --tags='@mod_choice' (with Firefox) 3) Verify the "Moodle 2.9dev (Build:...." information is printed at the beginning and also the "Server OS "xxxx", Browser: "firefox"" one. 4) The run ends ok with the number of scenarios and steps at the end. 5) run the same test with Chrome 6) Verify that all the information in 4) is printed and also the "Browser specific fixes have been applied..." is shown. 7) The run ends ok with the number of scenarios and steps at the end 8) Run the same test with --dry-run and Chrome. 9) Verify that all the information in 6) is printed (including the "Browser specific..." phrase). Also verify that all the steps are skipped and that, at the end, the number of scenarios and steps is shown (all skipped). Note the number of steps can be smaller with dry-runs, np with that. But number of scenarios must match. (11 right now for @mod_choice).
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      While working on MDL-48190 and other related issues, it was detected that the moodle_formatter is failing badly when --dry-run is used.

      The main cause is that, with dry runs... CFG and friends are not available and the formatter requires it (dirroot) and, worse yet, behat_util includes a lot of stuff with way more dependencies (MOODLE_INTERNAL, and more CFG variables).

      Initially I tried injecting dirrot:

                       'context' => array(
      -                    'class' => 'behat_init_context'
      +                    'class' => 'behat_init_context',
      +                    'parameters' => array(
      +                        'dirroot' => $CFG->dirroot
      +                    ),
      

      as the correct way to make the formatter aware of such dependency event-> getContextParameters(), and it worked ok but, as said, just to find that there were a lot more of dependencies there.

      So, finally, thought that the best way to solve this issue, was to, simply, skip any execution of all that stuff if CFG was not set. That way dry-run simply runs ok (not that it's very useful to use such format for dry-runs, but...).

      Ciao

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stronk7 Eloy Lafuente (stronk7)
                Reporter:
                stronk7 Eloy Lafuente (stronk7)
                Peer reviewer:
                Rajesh Taneja
                Participants:
                Component watchers:
                Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: