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.
source code
 
__del__(self)
Clean up global variables.
source code
 
HasGlobalOption(self, option)
Return true if 'option' was specified as a global command.
source code
 
GetGlobalOption(self, option, default=None)
Return the value of global 'option', or 'default' if omitted.
source code
 
HasCommandOption(self, option)
Return true if command 'option' was specified.
source code
 
GetCommandOption(self, option, default=None)
Return the value of command 'option'.
source code
 
Execute(self)
Execute the command.
source code
 
GetDatabase(self)
Return the test database to use.
source code
 
GetDatabaseIfAvailable(self)
Return the test database to use.
source code
 
GetTargetFileName(self)
Return the path to the file containing target specifications.
source code
 
GetTargetsFromFile(self, file_name)
Return the 'Target's specified in 'file_name'.
source code
 
GetTargets(self)
Return the 'Target' objects specified by the user.
source code
 
GetTracer(self)
Return the 'Tracer' associated with this instance of QMTest.
source code
 
MakeContext(self)
Construct a 'Context' object for running tests.
source code
 
GetExecutablePath(self)
Return the path to the QMTest executable.
source code
 
GetFileResultStreamClass(self)
Return the 'ResultStream' class used for results files.
source code
 
GetTextResultStreamClass(self)
Return the 'ResultStream' class used for textual feedback.
source code
 
__GetAttributeOptions(self, expect_value=True)
Return the attributes specified on the command line.
source code
 
__GetAnnotateOptions(self)
Return all annotate options.
source code
 
__ExecuteCreate(self)
Create a new extension file.
source code
 
__ExecuteCreateTdb(self, db_path)
Handle the command for creating a new test database.
source code
 
__ExecuteCreateTarget(self)
Create a new target file.
source code
 
__ExecuteExtensions(self)
List the available extension classes.
source code
 
__ExecuteDescribe(self)
Describe an extension.
source code
 
__ExecuteList(self)
List the contents of the database.
source code
 
__ExecuteRegister(self)
Register a new extension class.
source code
 
__ExecuteSummarize(self)
Read in test run results and summarize.
source code
 
__ExecuteRemote(self)
Execute the 'remote' command.
source code
 
__ExecuteReport(self)
Execute a 'report' command.
source code
 
__ExecuteRun(self)
Execute a 'run' command.
source code
 
__ExecuteServer(self)
Process the server command.
source code
 
__WriteCommandHelp(self, command)
Write out help information about 'command'.
source code
 
__FilterTestsToRun(self, test_ids, expectations)
Return those tests from 'test_ids' that should be run.
source code
 
__CheckExtensionKind(self, kind)
Check that 'kind' is a valid extension kind.
source code
 
__CreateResultStreams(self, output_file, annotations, expectations)
Return the result streams to use.
source code
Class Variables [hide private]
  __extension_kinds_string = _make_comma_separated_string(base.e...
A string listing the available extension kinds.
  db_path_environment_variable = "QMTEST_DB_PATH"
The environment variable specifying the test database path.
  summary_formats = "brief", "full", "stats", "batch", "none"
Valid formats for result summaries.
  context_file_name = "context"
The default name of a context file.
  expectations_file_name = "expectations.qmr"
The default name of a file containing expectations.
  results_file_name = "results.qmr"
The default name of a file containing results.
  target_file_name = "targets"
The default name of a file containing targets.
  help_option_spec = "h", "help", None, "Display usage summary."
  version_option_spec = None, "version", None, "Display version ...
  db_path_option_spec = "D", "tdb", "PATH", "Path to the test da...
  extension_output_option_spec = "o", "output", "FILE", "Write t...
  extension_id_option_spec = "i", "id", "NAME", "Write the exten...
  output_option_spec = "o", "output", "FILE", "Write test result...
  no_output_option_spec = None, "no-output", None, "Don't genera...
  outcomes_option_spec = "O", "outcomes", "FILE", "Use expected ...
  expectations_option_spec = "e", "expectations", "FILE", "Use e...
  context_option_spec = "c", "context", "KEY=VALUE", "Add or ove...
  context_file_spec = "C", "load-context", "FILE", "Read context...
  daemon_option_spec = None, "daemon", None, "Run as a daemon."
  port_option_spec = "P", "port", "PORT", "Server port number."
  address_option_spec = "A", "address", "ADDRESS", "Local address."
  log_file_option_spec = None, "log-file", "PATH", "Log file name."
  no_browser_option_spec = None, "no-browser", None, "Do not ope...
  pid_file_option_spec = None, "pid-file", "PATH", "Process ID f...
  concurrent_option_spec = "j", "concurrency", "COUNT", "Execute...
  targets_option_spec = "T", "targets", "FILE", "Use FILE as the...
  random_option_spec = None, "random", None, "Run the tests in a...
  rerun_option_spec = None, "rerun", "FILE", "Rerun the tests th...
  seed_option_spec = None, "seed", "INTEGER", "Seed the random n...
  format_option_spec = "f", "format", "FORMAT", "Specify the sum...
  result_stream_spec = None, "result-stream", "CLASS-NAME", "Spe...
  annotation_option_spec = "a", "annotate", "NAME=VALUE", "Set a...
  tdb_class_option_spec = "c", "class", "CLASS-NAME", "Specify t...
  attribute_option_spec = "a", "attribute", "NAME", "Get an attr...
  set_attribute_option_spec = "a", "attribute", "KEY=VALUE", "Se...
  extension_kind_option_spec = "k", "kind", "EXTENSION-KIND", "S...
  report_output_option_spec = "o", "output", "FILE", "Write test...
  report_flat_option_spec = "f", "flat", None, """Generate a fla...
  results_option_spec = "R", "results", "DIRECTORY", "Read in al...
  list_long_option_spec = "l", "long", None, "Use a detailed out...
  list_details_option_spec = "d", "details", None, "Display deta...
  list_recursive_option_spec = "R", "recursive", None, "Recursiv...
  conflicting_option_specs = output_option_spec, no_output_optio...
  global_options_spec = [help_option_spec, version_option_spec, ...
  commands_spec = [("create", "Create (or update) an extension."...
  __version_output = "QMTest %s\n" "Copyright (C) 2002 - 2007 Co...
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.

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.

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.

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.

__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.

__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:
_make_comma_separated_string(base.extension_kinds, "or")

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)."

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 thread\
s."

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 wri\
tten 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 clas\
s."

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
        database directory tree in the report."""

results_option_spec

Value:
"R", "results", "DIRECTORY", "Read in all results (*.qmr) files from D\
IRECTORY."

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:
output_option_spec, no_output_option_spec, (concurrent_option_spec, ta\
rgets_option_spec), (extension_output_option_spec, extension_id_option\
_spec), (expectations_option_spec, outcomes_option_spec),

global_options_spec

Value:
[help_option_spec, version_option_spec, db_path_option_spec,]

commands_spec

Value:
[("create", "Create (or update) an extension.", "EXTENSION-KIND CLASS-\
NAME(ATTR1 = 'VAL1', ATTR2 = 'VAL2', ...)", """Create (or update) an e\
xtension.

         The EXTENSION-KIND indicates what kind of extension to
         create; it must be one of """+ __extension_kinds_string+ """.

         The CLASS-NAME indicates the name of the extension class, or
...

__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\n" "Copyright (C) 2002 - 2007 CodeSourcery, Inc.\n" "QMTest\
 comes with ABSOLUTELY NO WARRANTY\n" "For more information about QMTe\
st visit http://www.qmtest.com\n"