Command to run one simplestest on command line

Bevan - September 17, 2009 - 17:57
Project:Drush
Version:All-Versions-HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

This patch allows the user to run a single simpletest test case and get results on the command line. Example usage and output;

> drush
Execute a drush command. Run `drush help [command]` to view command-specific help.

Examples:
drush dl cck zen                          Download CCK module and Zen theme.                 
drush --uri=http://example.com status     Show status command for the example.com multi-site.
drush help --pipe                         A space delimited list of commands                 

Options:
-r <path>, --root=<path>                  Drupal root directory to use (default: current directory)            
-l <uri> , --uri=<uri>                    URI of the drupal site to use (only needed in multisite environments)
-v, --verbose                             Display extra information about the command.                         
-d, --debug                               Display even more information, including internal messages.          
-q, --quiet                               Hide all output                                                      
-y, --yes                                 Assume 'yes' as answer to all prompts                                
-s, --simulate                            Simulate all relevant actions (don't actually change the system)     
-i, --include                             A list of paths to search for drush commands                         
-c, --config                              Specify a config file to use. See example.drushrc.php                
-u, --user                                Specify a user to login with. May be a name or a number.             
-b, --backend                             Hide all output and return structured data (internal use only).      
-p, --pipe                                Emit a compact representation of the command for scripting.          

Commands:
help                  Print this help message. Use --filter to limit command list to one command file (e.g.
                       --filter=pm)                                                                         
cron                  Run all cron hooks.                                                                  
updatedb              Execute the update.php process from the command line                                 
status                Provides a birds-eye view of the current Drupal installation, if any.                
script                Run php script(s).                                                                   
cache clear           Clear all caches.                                                                    
watchdog show         Shows recent watchdog log messages. Optionally filter for a specific type.           
watchdog delete       Delete all messages or only those of a specified type.                               
sync                  Rsync the Drupal tree to/from another server using ssh.                              
eval                  Evaluate arbitrary php code after bootstrapping Drupal.                              
enable                Enable one or more modules.                                                          
disable               Disable one or more modules.                                                         
uninstall             Uninstall one or more modules.                                                       
statusmodules         Show module enabled/disabled status                                                  
refresh               Refresh update status information                                                    
updatecode            Update your project code                                                             
update                Update your project code and apply any database updates required (update.php)        
info                  Release information for a project                                                    
dl                    Download core Drupal and projects like CCK, Zen, etc.                                
test                  Run a specified test and outputs the results on the command line.                    
test mail             Run all tests and mail the results to your team.                                     
test clean            Delete leftover tables and files from prior test runs.                               
sql conf              Print database connection details.                                                   
sql connect           A string for connecting to the DB.                                                   
sql dump              Exports the Drupal DB as SQL using mysqldump.                                        
sql query             Execute a query against the site database.                                           
sql load              Copy source database to target database.                                             
sql cli               Open a SQL command-line interface using Drupal’s credentials.                        
coder                 Run code reviews                           
generate users        Creates users.                             
generate taxonomy     Creates taxonomy.                          
generate content      Creates content.                           
soql show tables      List tables in salesforce.                 
soql describe         Describe an individual table in salesforce.
soql                  Execute a SOQL query.                      

> drush test
Available test cases                      
AdminMenuPermissionsTestCase              
AdminMenuModulesTestCase                  
AdminMenuLinksTestCase                    
CapchaTestCase                            
CapchaAdminTestCase                       
CaptchaAdminTest                          
CABrandTest                               
CACiviMailTest                            
CACustomBlocksTest                        
CAErrorReportingTest                      
CAFilesTest                               
CAGoogleAnalyticsTest                     
CAHtaccessTest                            
CALipsumTest                              
CAModulesTest                             
CAPanelsTest                              
CAPerfTest                                
CASvnTest                                 
CATinymceTest                             
CAUpdateStatusTest                        
CAViewsTest                               
CoderTestCase                             
CoderUpgrade6xTest                        
CoderCommentTest                          
CoderI18NTest                             
CoderSecurityTest                         
CoderSQLTest                              
CoderStyleTest                            
ContentCrudTestCase                       
ContentCrudBasicTest                      
ContentCrudSingleToMultipleTest           
ContentCrudMultipleToSingleTest           
ContentUICrud                             
ContentOptionWidgetTest                   
ContentProfileTest                        
ContentTaxonomyTestCase                   
ContentTaxonomyTest                       
ContentTaxonomyAutocompleteTest           
ContentTaxonomyAutocompletePermissionsTest
DateAPITestCase                           
DateRepeatTestCase                        
FileFieldTestCase                         
FileFieldRevisionTestCase                 
FileFieldDisplayTestCase                  
FileFieldValidateTestCase                 
FileFieldPathTestCase                     
SignificantFiguresTestCase                
GMapSimpleAPITest                         
GMapMacroTest                             
GoogleAnalyticsBasicTest                  
ImageCacheUrlTests                        
ImageFieldTestCase                        
ImageFieldDisplayTestCase                 
ImageFieldValidateTestCase                
LinkContentCrudTest                       
MollomWebTestCase                         
MollomAccessTestCase                      
MollomFallbackTestCase                    
MollomUserFormsTestCase                   
MollomCommentFormTestCase                 
MollomContactFormTestCase                 
MollomResellerTestCase                    
PathRedirectUnitTest                      
PathRedirectPathautoUnitTest              
PathRedirectFunctionalTest                
PathautoTestCase                          
SimpleTestFunctionalTest                  
SimpleTestMailCaptureTestCase             
BlockTestCase                             
TokenTestCase                             
WebformTestCase                           
WebformComponentsTestCase                 
WebformPermissionsTestCase                
WebformSubmissionTestCase                 

> drush test FooBar
Test case FooBar not found.  Perhaps you spelled it wrong or need to enable the module?                      [error]
Use the drush test command with no arguments to see a list of available test cases.  E.g.

        drush test

> drush test  SignificantFiguresTestCase
64 tests passed.
> drush test  SignificantFiguresTestCase
Status  Message                                                            
pass    Got 0 instead of 0 rounding 3450000 to 0 SF.                       
pass    Got 3,000,000 instead of 3,000,000 rounding 3450000 to 1 SF.       
pass    Got 3,500,000 instead of 3,500,000 rounding 3450000 to 2 SF.       
pass    Got 3,450,000 instead of 3,450,000 rounding 3450000 to 3 SF.       
pass    Got 3,450,000 instead of 3,450,000 rounding 3450000 to 4 SF.       
pass    Got 3,450,000.0 instead of 3,450,000.0 rounding 3450000 to 8 SF.   
pass    Got 0 instead of 0 rounding 345 to 0 SF.                           
pass    Got 300 instead of 300 rounding 345 to 1 SF.                       
pass    Got 350 instead of 350 rounding 345 to 2 SF.                       
pass    Got 345 instead of 345 rounding 345 to 3 SF.                       
pass    Got 345.0 instead of 345.0 rounding 345 to 4 SF.                   
pass    Got 345.00000 instead of 345.00000 rounding 345 to 8 SF.           
pass    Got 0 instead of 0 rounding 345.45 to 0 SF.                        
pass    Got 300 instead of 300 rounding 345.45 to 1 SF.                    
pass    Got 350 instead of 350 rounding 345.45 to 2 SF.                    
pass    Got 345 instead of 345 rounding 345.45 to 3 SF.                    
pass    Got 345.5 instead of 345.5 rounding 345.45 to 4 SF.                
pass    Got 345.45 instead of 345.45 rounding 345.45 to 5 SF.              
pass    Got 345.450 instead of 345.450 rounding 345.45 to 6 SF.            
pass    Got 0 instead of 0 rounding 0.345 to 0 SF.                         
pass    Got 0.3 instead of 0.3 rounding 0.345 to 1 SF.                     
pass    Got 0.35 instead of 0.35 rounding 0.345 to 2 SF.                   
pass    Got 0.345 instead of 0.345 rounding 0.345 to 3 SF.                 
pass    Got 0.3450 instead of 0.3450 rounding 0.345 to 4 SF.               
pass    Got 0.34500000 instead of 0.34500000 rounding 0.345 to 8 SF.       
pass    Got 0 instead of 0 rounding 0.00345 to 0 SF.                       
pass    Got 0.003 instead of 0.003 rounding 0.00345 to 1 SF.               
pass    Got 0.0035 instead of 0.0035 rounding 0.00345 to 2 SF.             
pass    Got 0.00345 instead of 0.00345 rounding 0.00345 to 3 SF.           
pass    Got 0.003450 instead of 0.003450 rounding 0.00345 to 4 SF.         
FAIL    Got 0.00345000 instead of 0.0034000 rounding 0.00345 to 8 SF.      
pass    Got 0 instead of 0 rounding -3450000 to 0 SF.                      
pass    Got -3,000,000 instead of -3,000,000 rounding -3450000 to 1 SF.    
pass    Got -3,500,000 instead of -3,500,000 rounding -3450000 to 2 SF.    
pass    Got -3,450,000 instead of -3,450,000 rounding -3450000 to 3 SF.    
pass    Got -3,450,000 instead of -3,450,000 rounding -3450000 to 4 SF.    
pass    Got -3,450,000.0 instead of -3,450,000.0 rounding -3450000 to 8 SF.
pass    Got 0 instead of 0 rounding -345 to 0 SF.                          
pass    Got -300 instead of -300 rounding -345 to 1 SF.                    
pass    Got -350 instead of -350 rounding -345 to 2 SF.                    
pass    Got -345 instead of -345 rounding -345 to 3 SF.                    
pass    Got -345.0 instead of -345.0 rounding -345 to 4 SF.                
pass    Got -345.00000 instead of -345.00000 rounding -345 to 8 SF.        
pass    Got 0 instead of 0 rounding -345.45 to 0 SF.                       
pass    Got -300 instead of -300 rounding -345.45 to 1 SF.                 
pass    Got -350 instead of -350 rounding -345.45 to 2 SF.                 
pass    Got -345 instead of -345 rounding -345.45 to 3 SF.                 
pass    Got -345.5 instead of -345.5 rounding -345.45 to 4 SF.             
pass    Got -345.45 instead of -345.45 rounding -345.45 to 5 SF.           
pass    Got -345.450 instead of -345.450 rounding -345.45 to 6 SF.         
pass    Got 0 instead of 0 rounding -0.345 to 0 SF.                        
pass    Got -0.3 instead of -0.3 rounding -0.345 to 1 SF.                  
pass    Got -0.35 instead of -0.35 rounding -0.345 to 2 SF.                
pass    Got -0.345 instead of -0.345 rounding -0.345 to 3 SF.              
pass    Got -0.3450 instead of -0.3450 rounding -0.345 to 4 SF.            
pass    Got -0.34500000 instead of -0.34500000 rounding -0.345 to 8 SF.    
pass    Got 0 instead of 0 rounding -0.00345 to 0 SF.                      
pass    Got -0.003 instead of -0.003 rounding -0.00345 to 1 SF.            
pass    Got -0.0035 instead of -0.0035 rounding -0.00345 to 2 SF.          
pass    Got -0.00345 instead of -0.00345 rounding -0.00345 to 3 SF.        
pass    Got -0.003450 instead of -0.003450 rounding -0.00345 to 4 SF.      
FAIL    Got -0.00345000 instead of -0.0034000 rounding -0.00345 to 8 SF.   
pass    Got 0 instead of 0 rounding 0 to 2 SF.                             
pass    Got 0 instead of 0 rounding 0 to -2 SF.                            

AttachmentSize
drush simpletest one.patch4.31 KB

#1

moshe weitzman - September 17, 2009 - 18:13
Status:needs review» postponed (maintainer needs more info)

Thanks. I've gone back and forth about including simpletest runner in drush.

run-tests.sh is much more capable and is supported better (for d6 it is in simpletest project. in core for d7). Feel free to explain the reasoning, but for now I don't see much reason to duplicate it here.

#2

Bevan - September 17, 2009 - 20:02
Title:Run one simplestest case.» Command to run one simplestest on command line

10 good reasons to use this instead simpletest's run-tests.php, and include it in drush;

  1. run-tests.sh has no documentation (that I could find – and I looked)
  2. run-tests.sh is complex enough to need documentation
  3. run-tests.sh is yet another freakin tool to learn
  4. drush test is simple
  5. drush test is self-documenting by the nature of drush
  6. drush test doesn't need additional documentation
  7. drush test is way more convenient when you are writing tests (as opposed to running them in bulk)
  8. drush test will run anywhere drush is working and simpletest is installed – no extra config or installation
  9. drush test is designed for the test-writer/developer
  10. drush test is discoverable via drush

#3

Dave Reid - October 23, 2009 - 23:11

+1 for this living in drush. run-tests.sh has never worked properly for me.

 
 

Drupal is a registered trademark of Dries Buytaert.