The Gaudi Framework  v28r2p1 (f1a77ff4)
GaudiTesting.Run Namespace Reference

Functions

def basic_report (results)
 
def quiet_report (results)
 
def ctest_report (results)
 
def pprint_report (results)
 
def main ()
 

Function Documentation

def GaudiTesting.Run.basic_report (   results)
Report function taking the dictionary from BasicTest.run() and display
stdout and stderr from it.

Definition at line 11 of file Run.py.

11 def basic_report(results):
12  '''
13  Report function taking the dictionary from BasicTest.run() and display
14  stdout and stderr from it.
15  '''
16  print '=== stdout ==='
17  print results.get('stdout', '')
18  print '=== stderr ==='
19  print results.get('stderr', '')
20  print '=== result ==='
21  print results.get('Status')
22  if results.get('Status') != 'passed' and 'Causes' in results:
23  print ' ', 'unexpected ' + ', '.join(results['Causes'])
24 
25 
def basic_report(results)
Definition: Run.py:11
def GaudiTesting.Run.ctest_report (   results)
Report function taking the dictionary from BasicTest.run() and report data
from it in a CTest-friendly way.

Definition at line 33 of file Run.py.

33 def ctest_report(results):
34  '''
35  Report function taking the dictionary from BasicTest.run() and report data
36  from it in a CTest-friendly way.
37  '''
38  # It's weird, I know, but it tells CTest not to cut the output.
39  print 'CTEST_FULL_OUTPUT'
40  print results.get('stdout', '')
41  handler = {'Environment': lambda v: '\n'.join('{0}={1}'.format(*item)
42  for item in sorted(v.iteritems())),
43  'Causes': lambda v: 'unexpected ' + ', '.join(v)}
44  id_handler = lambda v: str(v)
45  ignore = set(['Status', 'Name', 'stdout', 'Exit Code'])
46  template = ('<DartMeasurement type="text/string" name="{0}">{1}</DartMeasurement>')
47 
48  for key in results:
49  if key in ignore:
50  continue
51  hndlr = handler.get(key, id_handler)
52  data = XSS.escape(GT.sanitize_for_xml(hndlr(results[key])))
53  sys.stdout.write(template.format(key, data))
54 
55 
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
def ctest_report(results)
Definition: Run.py:33
def GaudiTesting.Run.main ( )
Main function of the script.

Definition at line 65 of file Run.py.

65 def main():
66  '''
67  Main function of the script.
68  '''
69  from optparse import OptionParser, OptionGroup
70  parser = OptionParser()
71 
72  parser.add_option('--report', action='store',
73  choices=[n.replace('_report', '')
74  for n in globals() if n.endswith('_report')],
75  help='choose a report method [default %default]')
76  parser.add_option('--common-tmpdir', action='store',
77  help='directory to be used as common temporary directory')
78  parser.add_option('-C', '--workdir', action='store',
79  help='directory to change to before starting the test')
80 
81  parser.add_option('--skip-return-code', type='int',
82  help='return code to use to flag a test as skipped '
83  '[default %default]')
84 
85  verbosity_opts = OptionGroup(parser, 'Verbosity Level',
86  'set the verbosity level of messages')
87  verbosity_opts.add_option('--silent',
88  action='store_const', dest='log_level',
89  const=logging.CRITICAL,
90  help='only critical error messages')
91  verbosity_opts.add_option('--quiet',
92  action='store_const', dest='log_level',
93  const=logging.ERROR,
94  help='error messages')
95  verbosity_opts.add_option('--warning',
96  action='store_const', dest='log_level',
97  const=logging.WARNING,
98  help='warning and error messages')
99  verbosity_opts.add_option('--verbose',
100  action='store_const', dest='log_level',
101  const=logging.INFO,
102  help='progress information messages')
103  verbosity_opts.add_option('--debug',
104  action='store_const', dest='log_level',
105  const=logging.DEBUG,
106  help='debugging messages')
107  parser.add_option_group(verbosity_opts)
108 
109 
110  parser.set_defaults(log_level=logging.WARNING,
111  report='basic',
112  workdir=os.curdir,
113  skip_return_code=0)
114 
115 
116  opts, args = parser.parse_args()
117  if len(args) != 1:
118  parser.error('only one test allowed')
119  filename = args[0]
120 
121  logging.basicConfig(level=opts.log_level)
122 
123  if opts.common_tmpdir:
124  if not os.path.isdir(opts.common_tmpdir):
125  os.makedirs(opts.common_tmpdir)
126  GT.BaseTest._common_tmpdir = opts.common_tmpdir
127 
128  os.chdir(opts.workdir)
129 
130  # FIXME: whithout this, we get some spurious '\x1b[?1034' in the std out on SLC6
131  if "slc6" in (os.environ.get('BINARY_TAG', '') or
132  os.environ.get('CMTCONFIG', '')):
133  os.environ['TERM'] = 'dumb'
134 
135  # Testing the file beginning with "Test" or if it is a qmt file and doing the test
136  logging.debug('processing %s', filename)
137  if filename.endswith('_test.py') :
138  indexFilePart= filename.rfind("/")
139  fileToImport = filename[indexFilePart+1:]
140  sys.path.append(GT.RationalizePath(filename)[:-len(fileToImport)-1])
141  imp = __import__(fileToImport[:-3])
142  fileToExec = imp.Test()
143  results = fileToExec.run()
144  elif filename.endswith(".qmt"):
145  from QMTTest import QMTTest
146  fileToTest = QMTTest(filename)
147  results = fileToTest.run()
148 
149  report = globals()[opts.report + '_report']
150  report(results)
151 
152  if results.get('Status') == 'failed':
153  logging.debug('test failed: unexpected %s',
154  ', '.join(results['Causes']))
155  return int(results.get('Exit Code', '1'))
156  elif results.get('Status') == 'skipped':
157  return opts.skip_return_code
158  return 0
159 
def main()
Definition: Run.py:65
def GaudiTesting.Run.pprint_report (   results)
Report function taking the dictionary from BasicTest.run() and print it with
the pprint module.

Definition at line 56 of file Run.py.

56 def pprint_report(results):
57  '''
58  Report function taking the dictionary from BasicTest.run() and print it with
59  the pprint module.
60  '''
61  from pprint import pprint
62  pprint(results)
63 
64 
def pprint_report(results)
Definition: Run.py:56
def GaudiTesting.Run.quiet_report (   results)
Do not report anything from the result of the test.

Definition at line 26 of file Run.py.

26 def quiet_report(results):
27  '''
28  Do not report anything from the result of the test.
29  '''
30  pass
31 
32 
def quiet_report(results)
Definition: Run.py:26