Package qm :: Package test :: Package classes :: Module dg_test :: Class DGTest
[hide private]
[frames] | no frames]

Class DGTest
source code

         object --+                
                  |                
extension.Extension --+            
                      |            
      runnable.Runnable --+        
                          |        
                  test.Test --+    
                              |    
   dejagnu_base.DejaGNUBase --+    
                              |    
       dejagnu_test.DejaGNUTest --+
                                  |
                                 DGTest

A 'DGTest' is a test using the DejaGNU 'dg' driver.

This test class emulates the 'dg.exp' source file in the DejaGNU distribution.

Nested Classes [hide private]
DGException The exception class raised by 'DGTest'.

Inherited from dejagnu_test.DejaGNUTest: BuildExecutable

Inherited from test.Test: OutcomeField, TestField

Inherited from runnable.Runnable: ResourceField

Inherited from extension.Extension: Type, __metaclass__


Instance Methods [hide private]
  _RunDGTest(self, tool_flags, default_options, context, result, path=None, default_kind=None, keep_output=None)
Run a 'dg' test.
  _RunDGToolPortion(self, path, tool_flags, context, result)
Perform the tool-running portions of a DG test.
  _RunDGExecutePortion(self, file, context, result)
Perform the executable-running portions of a DG test.
  _ExecuteFinalCommand(self, command, args, context, result)
Run a command specified with 'dg-final'.
  _PruneOutput(self, output)
Remove unintersting messages from 'output'.
  _RunTool(self, path, kind, options, context, result)
Run the tool being tested.
  _DGdo(self, line_num, args, context)
Emulate the 'dg-do' command.
  _DGfinal(self, line_num, args, context)
Emulate the 'dg-final' command.
  _DGoptions(self, line_num, args, context)
Emulate the 'dg-options' command.
  _DGbogus(self, line_num, args, context)
Emulate the 'dg-bogus' command.
  _DGwarning(self, line_num, args, context)
Emulate the 'dg-warning' command.
  _DGerror(self, line_num, args, context)
Emulate the 'dg-error' command.
  _DGexcess_errors(self, line_num, args, context)
Emulate the 'dg-excess-errors' command.
  __ExpectDiagnostic(self, kind, line_num, args, context)
Register an expected diagnostic.
  _ParseTargetSelector(self, selector, context)
Parse the target 'selector'.

Inherited from test.Test: GetTargetGroup, Run

Inherited from runnable.Runnable: GetAttachments, GetDatabase, GetId, __init__

Inherited from extension.Extension: GetClassName, GetExplicitArguments, MakeDomDocument, MakeDomElement, Write, __getattr__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Class Variables [hide private]
__dg_command_regexp A regular expression matching commands embedded in the source file.
KIND_PREPROCESS  
KIND_COMPILE  
KIND_ASSEMBLE  
KIND_LINK  
KIND_RUN  
keep_output  
_default_kind The default test kind.
__test_kinds The kinds of tests supported by 'dg.exp'.
__DIAG_BOGUS  
__DIAG_ERROR  
__DIAG_WARNING  
__diagnostic_descriptions A map from dg diagnostic kinds to descriptive strings.
_argument_dictionary  
_argument_list  

Inherited from dejagnu_test.DejaGNUTest: ERROR, FAIL, KFAIL, KPASS, PASS, RESULT_PREFIX, UNRESOLVED, UNSUPPORTED, UNTESTED, WARNING, XFAIL, XPASS, arguments, dejagnu_outcomes, executable_timeout, outcome_map, source_file

Inherited from test.Test: PREREQUISITES_FIELD_ID, kind, prerequisites, target_group

Inherited from runnable.Runnable: EXTRA_DATABASE, EXTRA_ID, RESOURCE_FIELD_ID, resources

Inherited from object: __class__


Method Details [hide private]

_RunDGTest(self, tool_flags, default_options, context, result, path=None, default_kind=None, keep_output=None)

source code 

Run a 'dg' test.

'tool_flags' -- A list of strings giving a set of options to be provided to the tool being tested.

'default_options' -- A list of strings giving a default set of options to be provided to the tool being tested. These options can be overridden by an embedded 'dg-options' command in the test itself.

'context' -- The 'Context' in which this test is running.

'result' -- The 'Result' of the test execution.

'path' -- The path to the test file. If 'None', the main test file path is used.

'default_kind' -- The kind of test to perform. If this value is 'None', then 'self._default_kind' is used.

'keep_output' -- True if the output file should be retained after the test is complete. Otherwise, it is removed.

This function emulates 'dg-test'.

_RunDGToolPortion(self, path, tool_flags, context, result)

source code 

Perform the tool-running portions of a DG test.

Calls '_RunTool' and processes its output.

returns -- The filename of the generated file.

_RunDGExecutePortion(self, file, context, result)

source code 

Perform the executable-running portions of a DG test.

If this is a "run" test, runs the executable generated by the tool and checks its output.

_ExecuteFinalCommand(self, command, args, context, result)

source code 

Run a command specified with 'dg-final'.

'command' -- A string giving the name of the command.

'args' -- A list of strings giving the arguments (if any) to that command.

'context' -- The 'Context' in which this test is running.

'result' -- The 'Result' of this test.

_PruneOutput(self, output)

source code 

Remove unintersting messages from 'output'.

'output' -- A string giving the output from the tool being tested.

returns -- A modified version of 'output'. This modified version does not contain tool output messages that are irrelevant for testing purposes.

_RunTool(self, path, kind, options, context, result)

source code 

Run the tool being tested.

'path' -- The path to the test file.

'kind' -- The kind of test to perform.

'options' -- A list of strings giving command-line options to provide to the tool.

'context' -- The 'Context' for the test execution.

'result' -- The QMTest 'Result' for the test.

returns -- A pair '(output, file)' where 'output' consists of any messages produced by the compiler, and 'file' is the name of the file produced by the compilation, if any.

_DGdo(self, line_num, args, context)

source code 

Emulate the 'dg-do' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGfinal(self, line_num, args, context)

source code 

Emulate the 'dg-final' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGoptions(self, line_num, args, context)

source code 

Emulate the 'dg-options' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGbogus(self, line_num, args, context)

source code 

Emulate the 'dg-bogus' command.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGwarning(self, line_num, args, context)

source code 

Emulate the 'dg-warning' command.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGerror(self, line_num, args, context)

source code 

Emulate the 'dg-error' command.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGexcess_errors(self, line_num, args, context)

source code 

Emulate the 'dg-excess-errors' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

__ExpectDiagnostic(self, kind, line_num, args, context)

source code 

Register an expected diagnostic.

'kind' -- The kind of diagnostic expected.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_ParseTargetSelector(self, selector, context)

source code 

Parse the target 'selector'.

'selector' -- A target selector.

'context' -- The 'Context' in which the test is running.

returns -- For a 'target' selector, 'S' if this test should be run, or 'N' if it should not. For an 'xfail' selector, 'F' if the test is expected to fail; 'P' if if not.

This function emulates dg-process-target.

Class Variable Details [hide private]

__dg_command_regexp

A regular expression matching commands embedded in the source file.
Value:
\{[ \t]+dg-([-a-z]+)[ \t]+(.*)[ \t]+\}[^\}]*$                          
      

KIND_PREPROCESS

Value:
'preprocess'                                                           
      

KIND_COMPILE

Value:
'compile'                                                              
      

KIND_ASSEMBLE

Value:
'assemble'                                                             
      

KIND_LINK

Value:
'link'                                                                 
      

KIND_RUN

Value:
'run'                                                                  
      

keep_output

Value:
'true'                                                                 
      

_default_kind

The default test kind.

This value can be overridden by a 'dg-do' command in the test file.
Value:
'compile'                                                              
      

__test_kinds

The kinds of tests supported by 'dg.exp'.
Value:
('preprocess', 'compile', 'assemble', 'link', 'run')                   
      

__DIAG_BOGUS

Value:
'bogus'                                                                
      

__DIAG_ERROR

Value:
'error'                                                                
      

__DIAG_WARNING

Value:
'warning'                                                              
      

__diagnostic_descriptions

A map from dg diagnostic kinds to descriptive strings.
Value:
{'bogus': 'bogus messages',
 'build': 'build failure',
 'error': 'errors',
 'warning': 'warnings'}                                                
      

_argument_dictionary

Value:
{'keep_output': <<class 'qm.fields.BooleanField'> keep_output>,
 'prerequisites': <<class 'qm.fields.SetField'> prerequisites>,
 'resources': <<class 'qm.fields.SetField'> resources>,
 'source_file': <<class 'qm.fields.AttachmentField'> source_file>,
 'target_group': <<class 'qm.test.test.TargetGroupField'> target_group\
>}                                                                     
      

_argument_list

Value:
[<<class 'qm.fields.SetField'> prerequisites>,
 <<class 'qm.fields.BooleanField'> keep_output>,
 <<class 'qm.test.test.TargetGroupField'> target_group>,
 <<class 'qm.fields.AttachmentField'> source_file>,
 <<class 'qm.fields.SetField'> resources>]