Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Drush exit with code other than 0 when simpletest fails #212

Closed
alberto56 opened this issue Oct 25, 2013 · 4 comments
Closed

Make Drush exit with code other than 0 when simpletest fails #212

alberto56 opened this issue Oct 25, 2013 · 4 comments

Comments

@alberto56
Copy link

Hi,

https://drupal.org/node/1802948 has been marked as fixed back in July, and I am using the latest commit:

commit 2e154c9992cab2ec4b350f5f8f94ab69c077a2ec
Author: Moshe Weitzman <weitzman@tejasa.com>
Date:   Mon Oct 21 13:30:56 2013 -0400
Fix #202. Remove inaccurate and unneeded site_name from the success message 

Drush seems to exit with code 0 in this circumstance. Here is my output

drush test-run alwaysfails
alwaysfails: basic test 3 passes, 1 fail, 0 exceptions, and 1 debug message [error]
No leftover tables to remove.                                        [status]
No temporary directories to remove.                                  [status]
Removed 1 test result.                                               [status]
 Group  Class  Name 

echo $?
0

I'm wondering if we can get this to exit with a code other than 0. This is what git does, for example:

git clone not-a-repo
fatal: repository 'not-a-repo' does not exist
echo $?
128

Thanks for your work,

Albert

@alberto56
Copy link
Author

Here is a workaround:

For now, in order to make sure Jenkins fails I have to test for the presence of [error], like this:

MYTESTGROUP=demo
echo $(drush test-run $MYTESTGROUP) | grep -v '\[error\]'

grep -v tells grep to find anything that does not contain the string [error] based on the output of drush test-run. If grep comes up empty-handed it will exit with the error code 1, hence triggering a fail in Jenkins.

@weitzman
Copy link
Member

Fix committed to master.

@helmo
Copy link
Contributor

helmo commented Jun 14, 2014

Had to look this one up ... it' s pull request #189

@alberto56
Copy link
Author

If you're stuck using Drush 6.0, here is a workaround (I realized my workaround in my comment above does not work at all!):

drush test-run MyTestGroup 2>test-results.txt
cat test-results.txt #display results to user
# Following is a workaround to https://github.com/drush-ops/drush/issues/212
# in case we're using drush 6.0 (fixed in drush 6.6, maybe before)
# The following line will try to find the string [error] in the test results,
# if it does, we will exit with the error code 1
cat test-results.txt | grep '\[error\]' && exit 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants