jhedstrom / drupalextension

An integration layer between Behat, Mink Extension, and Drupal.
GNU General Public License v2.0
209 stars 192 forks source link

Allow verbose debugging of drush commands #251

Open generalconsensus opened 8 years ago

generalconsensus commented 8 years ago

This week I ran into a strange bug with where drush was unable to find the alias path due to missing double quotes. Example:

dev:
    paths:
        features: 'features'
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://lurp:derp@herp/
            goutte: ~
            selenium2:
              browser:              'chrome'
              capabilities:         { "browserName": "chrome", "browser": "chrome"}
              wd_host:              'http://127.0.0.1:8643/wd/hub'
            files_path: 'tests/behat/files/'
        Drupal\DrupalExtension\Extension:
            blackbox: ~
            text:
                log_out: "Log out"
                log_in: "Log in"
                password_field: "Password"
                username_field: "Username"
            selectors:
                logged_in_selector: "body.logged-in"
                login_form_selector: "form#user-login"
            api_driver: 'drush'
            drush:
              binary: '/usr/local/bin/drush'
              alias: 'hurp'
              global_options: '--alias-path=../../'

The global_options variable is great, but when it doesn't work it creates the following scenario that is particular hard to debug!

[dmcdermott@code workspace]$ sudo -u jenkins ./tests/behat/bin/behat -c ./tests/behat/behat.jenkins.yml ./tests/behat/features/herp/derp/organization.feature -p dev
Feature: Create organization content test

  @api @content @javascript
  Scenario: As an Administration user I want to make sure that Organization, Challenge and Grant content types are created properly # features/herp/derp/organization.feature:4
Array
(
    [binary] => /usr/local/bin/drush
)
1
Array
(
    [alias] => @hurp
)
1
Array
(
    [global] => --alias-path=../../
)
1
Array
(
    [command] => user-create
)
1
Array
(
    [string_options] =>  --password=mB8X9GrM1dzvOWPm --mail=vISMFI6V@example.com --nocolor=
)
1
    Given I am logged in as a user with the "administrator" role                                                                    # FeatureContext::assertAuthenticatedByRole()
      The drush command '@hurp user-create vISMFI6V' could not be found.[error]

It wasn't the COMMAND that was the problem but the need for the global_options variable to be encapsulated with double quotes. Definitely would want to add this to the documentation so no one has this problem in the future, but we might also want to allow the ability to call drush with '-v' to see more information on why this command wasn't working.

In the end what fixed this issue was the following:

dev:
    paths:
        features: 'features'
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://lurp:derp@herp/
            goutte: ~
            selenium2:
              browser:              'chrome'
              capabilities:         { "browserName": "chrome", "browser": "chrome"}
              wd_host:              'http://127.0.0.1:8643/wd/hub'
            files_path: 'tests/behat/files/'
        Drupal\DrupalExtension\Extension:
            blackbox: ~
            text:
                log_out: "Log out"
                log_in: "Log in"
                password_field: "Password"
                username_field: "Username"
            selectors:
                logged_in_selector: "body.logged-in"
                login_form_selector: "form#user-login"
            api_driver: 'drush'
            drush:
              binary: '/usr/local/bin/drush'
              alias: 'hurp'
              global_options: '--alias-path="../../"'
jhedstrom commented 8 years ago

Glad you tracked this down! PRs for documentation (see the doc directory) are always welcome. Also an option to change verbosity level of drush would be nice.

jhedstrom commented 8 years ago

Does adding -v to the global_options work here?