Package qm :: Package test :: Package classes :: Module command :: Class ExecTestBase
[hide private]
[frames] | no frames]

Class ExecTestBase
source code

         object --+            
                  |            
extension.Extension --+        
                      |        
      runnable.Runnable --+    
                          |    
                  test.Test --+
                              |
                             ExecTestBase
Known Subclasses:
ExecTest, ShellCommandTest, ShellScriptTest

Check a program's output and exit code.

An 'ExecTestBase' runs a program and compares its standard output, standard error, and exit code with expected values. The program may be provided with command-line arguments and/or standard input.

The test passes if the standard output, standard error, and exit code are identical to the expected values.

Nested Classes [hide private]

Inherited from test.Test: OutcomeField, TestField

Inherited from runnable.Runnable: ResourceField

Inherited from extension.Extension: Type, __metaclass__


Instance Methods [hide private]
  MakeEnvironment(self, context)
Construct the environment for executing the target program.
  ValidateOutput(self, stdout, stderr, result)
Validate the output of the program.
  RunProgram(self, program, arguments, context, result)
Run the 'program'.
  __CompareText(self, s1, s2)
Compare 's1' and 's2', ignoring line endings.

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]
arguments  
_argument_dictionary  
_argument_list  
environment  
exit_code  
stderr  
stdin  
stdout  
timeout  

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]

MakeEnvironment(self, context)

source code 
Construct the environment for executing the target program.

ValidateOutput(self, stdout, stderr, result)

source code 

Validate the output of the program.

'stdout' -- A string containing the data written to the standard output stream.

'stderr' -- A string containing the data written to the standard error stream.

'result' -- A 'Result' object. It may be used to annotate the outcome according to the content of stderr.

returns -- A list of strings giving causes of failure.

RunProgram(self, program, arguments, context, result)

source code 

Run the 'program'.

'program' -- The path to the program to run.

'arguments' -- A list of the arguments to the program. This list must contain a first argument corresponding to 'argv[0]'.

'context' -- A 'Context' giving run-time parameters to the test.

'result' -- A 'Result' object. The outcome will be 'Result.PASS' when this method is called. The 'result' may be modified by this method to indicate outcomes other than 'Result.PASS' or to add annotations.

__CompareText(self, s1, s2)

source code 

Compare 's1' and 's2', ignoring line endings.

's1' -- A string.

's2' -- A string.

returns -- True if 's1' and 's2' are the same, ignoring differences in line endings.

Class Variable Details [hide private]

arguments

Value:
[<<class 'qm.fields.TextField'> stdin>,
 <<class 'qm.fields.SetField'> environment>,
 <<class 'qm.fields.IntegerField'> exit_code>,
 <<class 'qm.fields.TextField'> stdout>,
 <<class 'qm.fields.TextField'> stderr>,
 <<class 'qm.fields.IntegerField'> timeout>]                           
      

_argument_dictionary

Value:
{'environment': <<class 'qm.fields.SetField'> environment>,
 'exit_code': <<class 'qm.fields.IntegerField'> exit_code>,
 'prerequisites': <<class 'qm.fields.SetField'> prerequisites>,
 'resources': <<class 'qm.fields.SetField'> resources>,
 'stderr': <<class 'qm.fields.TextField'> stderr>,
 'stdin': <<class 'qm.fields.TextField'> stdin>,
 'stdout': <<class 'qm.fields.TextField'> stdout>,
 'target_group': <<class 'qm.test.test.TargetGroupField'> target_group\
...                                                                    
      

_argument_list

Value:
[<<class 'qm.fields.TextField'> stdin>,
 <<class 'qm.fields.IntegerField'> timeout>,
 <<class 'qm.fields.TextField'> stdout>,
 <<class 'qm.fields.SetField'> prerequisites>,
 <<class 'qm.test.test.TargetGroupField'> target_group>,
 <<class 'qm.fields.IntegerField'> exit_code>,
 <<class 'qm.fields.SetField'> environment>,
 <<class 'qm.fields.TextField'> stderr>,
...                                                                    
      

environment

Value:
[]                                                                     
      

exit_code

Value:
0                                                                     
      

stderr

Value:
''                                                                     
      

stdin

Value:
''                                                                     
      

stdout

Value:
''                                                                     
      

timeout

Value:
-1