Package qm :: Package test :: Module cmdline :: Class QMTest
[hide private]
[frames] | no frames]

Class QMTest
source code

An instance of QMTest.

Instance Methods [hide private]
  __init__(self, argument_list, path)
Construct a new QMTest.
  __del__(self)
Clean up global variables.
  HasGlobalOption(self, option)
Return true if 'option' was specified as a global command.
  GetGlobalOption(self, option, default=None)
Return the value of global 'option', or 'default' if omitted.
  HasCommandOption(self, option)
Return true if command 'option' was specified.
  GetCommandOption(self, option, default=None)
Return the value of command 'option'.
  Execute(self)
Execute the command.
  GetDatabase(self)
Return the test database to use.
  GetDatabaseIfAvailable(self)
Return the test database to use.
  GetTargetFileName(self)
Return the path to the file containing target specifications.
  GetTargetsFromFile(self, file_name)
Return the 'Target's specified in 'file_name'.
  GetTargets(self)
Return the 'Target' objects specified by the user.
  GetTracer(self)
Return the 'Tracer' associated with this instance of QMTest.
  MakeContext(self)
Construct a 'Context' object for running tests.
  GetExecutablePath(self)
Return the path to the QMTest executable.
  GetFileResultStreamClass(self)
Return the 'ResultStream' class used for results files.
  GetTextResultStreamClass(self)
Return the 'ResultStream' class used for textual feedback.
  __GetAttributeOptions(self, expect_value=True)
Return the attributes specified on the command line.
  __GetAnnotateOptions(self)
Return all annotate options.
  __ExecuteCreate(self)
Create a new extension file.
  __ExecuteCreateTdb(self, db_path)
Handle the command for creating a new test database.
  __ExecuteCreateTarget(self)
Create a new target file.
  __ExecuteExtensions(self)
List the available extension classes.
  __ExecuteDescribe(self)
Describe an extension.
  __ExecuteList(self)
List the contents of the database.
  __ExecuteRegister(self)
Register a new extension class.
  __ExecuteSummarize(self)
Read in test run results and summarize.
  __ExecuteRemote(self)
Execute the 'remote' command.
  __ExecuteReport(self)
Execute a 'report' command.
  __ExecuteRun(self)
Execute a 'run' command.
  __ExecuteServer(self)
Process the server command.
  __WriteCommandHelp(self, command)
Write out help information about 'command'.
  __FilterTestsToRun(self, test_ids, expectations)
Return those tests from 'test_ids' that should be run.
  __CheckExtensionKind(self, kind)
Check that 'kind' is a valid extension kind.
  __CreateResultStreams(self, output_file, annotations, expectations)
Return the result streams to use.

Class Variables [hide private]
__extension_kinds_string A string listing the available extension kinds.
db_path_environment_variable The environment variable specifying the test database path.
summary_formats Valid formats for result summaries.
context_file_name The default name of a context file.
expectations_file_name The default name of a file containing expectations.
results_file_name The default name of a file containing results.
target_file_name The default name of a file containing targets.
help_option_spec  
version_option_spec  
db_path_option_spec  
extension_output_option_spec  
extension_id_option_spec  
output_option_spec  
no_output_option_spec  
outcomes_option_spec  
expectations_option_spec  
context_option_spec  
context_file_spec  
daemon_option_spec  
port_option_spec  
address_option_spec  
log_file_option_spec  
no_browser_option_spec  
pid_file_option_spec  
concurrent_option_spec  
targets_option_spec  
random_option_spec  
rerun_option_spec  
seed_option_spec  
format_option_spec  
result_stream_spec  
annotation_option_spec  
tdb_class_option_spec  
attribute_option_spec  
set_attribute_option_spec  
extension_kind_option_spec  
report_output_option_spec  
report_flat_option_spec  
results_option_spec  
list_long_option_spec  
list_details_option_spec  
list_recursive_option_spec  
conflicting_option_specs  
global_options_spec  
commands_spec  
__version_output The string printed when the --version option is used.

Method Details [hide private]

__init__(self, argument_list, path)
(Constructor)

source code 

Construct a new QMTest.

Parses the argument list but does not execute the command.

'argument_list' -- The arguments to QMTest, not including the initial argv[0].

'path' -- The path to the QMTest executable.

__del__(self)
(Destructor)

source code 
Clean up global variables.

HasGlobalOption(self, option)

source code 

Return true if 'option' was specified as a global command.

'command' -- The long name of the option, but without the preceding "--".

returns -- True if the option is present.

GetGlobalOption(self, option, default=None)

source code 
Return the value of global 'option', or 'default' if omitted.

HasCommandOption(self, option)

source code 
Return true if command 'option' was specified.

GetCommandOption(self, option, default=None)

source code 

Return the value of command 'option'.

'option' -- The long form of an command-specific option.

'default' -- The default value to be returned if the 'option' was not specified. This option should be the kind of an option that takes an argument.

returns -- The value specified by the option, or 'default' if the option was not specified.

Execute(self)

source code 

Execute the command.

returns -- 0 if the command was executed successfully. 1 if there was a problem or if any tests run had unexpected outcomes.

GetDatabase(self)

source code 

Return the test database to use.

returns -- The 'Database' to use for this execution. Raises an exception if no 'Database' is available.

GetDatabaseIfAvailable(self)

source code 

Return the test database to use.

returns -- The 'Database' to use for this execution, or 'None' if no 'Database' is available.

GetTargetFileName(self)

source code 

Return the path to the file containing target specifications.

returns -- The path to the file containing target specifications.

GetTargetsFromFile(self, file_name)

source code 

Return the 'Target's specified in 'file_name'.

returns -- A list of the 'Target' objects specified in the target specification file 'file_name'.

GetTargets(self)

source code 

Return the 'Target' objects specified by the user.

returns -- A sequence of 'Target' objects.

GetTracer(self)

source code 

Return the 'Tracer' associated with this instance of QMTest.

returns -- The 'Tracer' associated with this instance of QMTest.

MakeContext(self)

source code 
Construct a 'Context' object for running tests.

GetExecutablePath(self)

source code 

Return the path to the QMTest executable.

returns -- A string giving the path to the QMTest executable. This is the path that should be used to invoke QMTest recursively. Returns 'None' if the path to the QMTest executable is uknown.

GetFileResultStreamClass(self)

source code 

Return the 'ResultStream' class used for results files.

returns -- The 'ResultStream' class used for results files.

GetTextResultStreamClass(self)

source code 

Return the 'ResultStream' class used for textual feedback.

returns -- the 'ResultStream' class used for textual feedback.

__GetAttributeOptions(self, expect_value=True)

source code 

Return the attributes specified on the command line.

'expect_value' -- True if the attribute is to be parsed as an assignment.

returns -- A dictionary. If expect_value is True, it maps attribute names (strings) to values (strings). Else it contains the raw attribute strings, mapping to None. There is an entry for each attribute specified with '--attribute' on the command line.

__GetAnnotateOptions(self)

source code 

Return all annotate options.

returns -- A dictionary containing the annotation name / value pairs.

__ExecuteCreate(self)

source code 
Create a new extension file.

__ExecuteCreateTdb(self, db_path)

source code 

Handle the command for creating a new test database.

'db_path' -- The path at which to create the new test database.

__ExecuteCreateTarget(self)

source code 
Create a new target file.

__ExecuteExtensions(self)

source code 
List the available extension classes.

__ExecuteDescribe(self)

source code 
Describe an extension.

__ExecuteList(self)

source code 
List the contents of the database.

__ExecuteRegister(self)

source code 
Register a new extension class.

__ExecuteSummarize(self)

source code 
Read in test run results and summarize.

__ExecuteRemote(self)

source code 
Execute the 'remote' command.

__ExecuteReport(self)

source code 
Execute a 'report' command.

__ExecuteRun(self)

source code 
Execute a 'run' command.

__ExecuteServer(self)

source code 
Process the server command.

__WriteCommandHelp(self, command)

source code 

Write out help information about 'command'.

'command' -- The name of the command for which help information is required.

__FilterTestsToRun(self, test_ids, expectations)

source code 

Return those tests from 'test_ids' that should be run.

'test_ids' -- A sequence of test ids.

'expectations' -- An ExpectationDatabase.

returns -- Those elements of 'test_names' that are not to be skipped. If 'a' precedes 'b' in 'test_ids', and both 'a' and 'b' are present in the result, 'a' will precede 'b' in the result.

__CheckExtensionKind(self, kind)

source code 

Check that 'kind' is a valid extension kind.

'kind' -- A string giving the name of an extension kind. If the 'kind' does not name a valid extension kind, an appropriate exception is raised.

__CreateResultStreams(self, output_file, annotations, expectations)

source code 

Return the result streams to use.

'output_file' -- If not 'None', the name of a file to which the standard results file format should be written.

'annotations' -- A dictionary with annotations for this test run.

'expectations' -- An ExpectationDatabase.

returns -- A list of 'ResultStream' objects, as indicated by the user.

Class Variable Details [hide private]

__extension_kinds_string

A string listing the available extension kinds.
Value:
"'database', 'expectation_database', 'host', 'label', 'resource', 'res\
ult_reader', 'result_stream', 'run_database', 'suite', 'target', or 't\
est'"                                                                  
      

db_path_environment_variable

The environment variable specifying the test database path.
Value:
'QMTEST_DB_PATH'                                                       
      

summary_formats

Valid formats for result summaries.
Value:
('brief', 'full', 'stats', 'batch', 'none')                            
      

context_file_name

The default name of a context file.
Value:
'context'                                                              
      

expectations_file_name

The default name of a file containing expectations.
Value:
'expectations.qmr'                                                     
      

results_file_name

The default name of a file containing results.
Value:
'results.qmr'                                                          
      

target_file_name

The default name of a file containing targets.
Value:
'targets'                                                              
      

help_option_spec

Value:
('h', 'help', None, 'Display usage summary.')                          
      

version_option_spec

Value:
(None, 'version', None, 'Display version information.')                
      

db_path_option_spec

Value:
('D', 'tdb', 'PATH', 'Path to the test database.')                     
      

extension_output_option_spec

Value:
('o', 'output', 'FILE', 'Write the extension to FILE.')                
      

extension_id_option_spec

Value:
('i', 'id', 'NAME', 'Write the extension to the database as NAME.')    
      

output_option_spec

Value:
('o', 'output', 'FILE', 'Write test results to FILE (- for stdout).')  
      

no_output_option_spec

Value:
(None, 'no-output', None, "Don't generate test results.")              
      

outcomes_option_spec

Value:
('O', 'outcomes', 'FILE', 'Use expected outcomes in FILE.')            
      

expectations_option_spec

Value:
('e', 'expectations', 'FILE', 'Use expectations in FILE.')             
      

context_option_spec

Value:
('c', 'context', 'KEY=VALUE', 'Add or override a context property.')   
      

context_file_spec

Value:
('C', 'load-context', 'FILE', 'Read context from a file (- for stdin).\
')                                                                     
      

daemon_option_spec

Value:
(None, 'daemon', None, 'Run as a daemon.')                             
      

port_option_spec

Value:
('P', 'port', 'PORT', 'Server port number.')                           
      

address_option_spec

Value:
('A', 'address', 'ADDRESS', 'Local address.')                          
      

log_file_option_spec

Value:
(None, 'log-file', 'PATH', 'Log file name.')                           
      

no_browser_option_spec

Value:
(None, 'no-browser', None, 'Do not open a new browser window.')        
      

pid_file_option_spec

Value:
(None, 'pid-file', 'PATH', 'Process ID file name.')                    
      

concurrent_option_spec

Value:
('j', 'concurrency', 'COUNT', 'Execute tests in COUNT concurrent threa\
ds.')                                                                  
      

targets_option_spec

Value:
('T', 'targets', 'FILE', 'Use FILE as the target specification file.') 
      

random_option_spec

Value:
(None, 'random', None, 'Run the tests in a random order.')             
      

rerun_option_spec

Value:
(None, 'rerun', 'FILE', 'Rerun the tests that failed.')                
      

seed_option_spec

Value:
(None, 'seed', 'INTEGER', 'Seed the random number generator.')         
      

format_option_spec

Value:
('f', 'format', 'FORMAT', 'Specify the summary format.')               
      

result_stream_spec

Value:
(None, 'result-stream', 'CLASS-NAME', 'Specify the results file format\
.')                                                                    
      

annotation_option_spec

Value:
('a',
 'annotate',
 'NAME=VALUE',
 'Set an additional annotation to be written to the result stream(s).'\
)                                                                      
      

tdb_class_option_spec

Value:
('c', 'class', 'CLASS-NAME', 'Specify the test database class.')       
      

attribute_option_spec

Value:
('a', 'attribute', 'NAME', 'Get an attribute of the extension class.') 
      

set_attribute_option_spec

Value:
('a', 'attribute', 'KEY=VALUE', 'Set an attribute of the extension cla\
ss.')                                                                  
      

extension_kind_option_spec

Value:
('k', 'kind', 'EXTENSION-KIND', 'Specify the kind of extension class.'\
)                                                                      
      

report_output_option_spec

Value:
('o', 'output', 'FILE', 'Write test report to FILE (- for stdout).')   
      

report_flat_option_spec

Value:
('f',
 'flat',
 None,
 'Generate a flat listing of test results, instead of reproducing the\\
n        database directory tree in the report.')                      
      

results_option_spec

Value:
('R',
 'results',
 'DIRECTORY',
 'Read in all results (*.qmr) files from DIRECTORY.')                  
      

list_long_option_spec

Value:
('l', 'long', None, 'Use a detailed output format.')                   
      

list_details_option_spec

Value:
('d', 'details', None, 'Display details for individual items.')        
      

list_recursive_option_spec

Value:
('R', 'recursive', None, 'Recursively list the contents of directories\
.')                                                                    
      

conflicting_option_specs

Value:
((('o', 'output', 'FILE', 'Write test results to FILE (- for stdout).'\
),
  (None, 'no-output', None, "Don't generate test results.")),
 (('j', 'concurrency', 'COUNT', 'Execute tests in COUNT concurrent thr\
eads.'),
  ('T', 'targets', 'FILE', 'Use FILE as the target specification file.\
')),
 (('o', 'output', 'FILE', 'Write the extension to FILE.'),
...                                                                    
      

global_options_spec

Value:
[('h', 'help', None, 'Display usage summary.'),
 (None, 'version', None, 'Display version information.'),
 ('D', 'tdb', 'PATH', 'Path to the test database.')]                   
      

commands_spec

Value:
[('create',
  'Create (or update) an extension.',
  "EXTENSION-KIND CLASS-NAME(ATTR1 = 'VAL1', ATTR2 = 'VAL2', ...)",
  'Create (or update) an extension.\n\n         The EXTENSION-KIND ind\
icates what kind of extension to\n         create; it must be one of \\
'database\', \'expectation_database\', \'host\', \'label\', \'resource\
\', \'result_reader\', \'result_stream\', \'run_database\', \'suite\',\
 \'target\', or \'test\'.\n\n         The CLASS-NAME indicates the nam\
...                                                                    
      

__version_output

The string printed when the --version option is used.

There is one fill-in, for a string, which should contain the version number.
Value:
'''QMTest %s
Copyright (C) 2002 - 2007 CodeSourcery, Inc.
QMTest comes with ABSOLUTELY NO WARRANTY
For more information about QMTest visit http://www.qmtest.com
'''