Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultaneous support for Python 2 and Python 3 #46

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions testing/src/build_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class BuildOutputXMLParsing(object):
XML parsing utilities for dealing with the Boost Build output
XML format.
'''

def get_child_data( self, root, tag = None, id = None, name = None, strip = False, default = None ):
return self.get_data(self.get_child(root,tag=tag,id=id,name=name),strip=strip,default=default)

def get_data( self, node, strip = False, default = None ):
data = None
if node:
Expand All @@ -45,10 +45,10 @@ def get_data( self, node, strip = False, default = None ):
if strip:
data = data.strip()
return data

def get_child( self, root, tag = None, id = None, name = None, type = None ):
return self.get_sibling(root.firstChild,tag=tag,id=id,name=name,type=type)

def get_sibling( self, sibling, tag = None, id = None, name = None, type = None ):
n = sibling
while n:
Expand All @@ -72,7 +72,7 @@ def get_sibling( self, sibling, tag = None, id = None, name = None, type = None
return None

class BuildOutputProcessor(BuildOutputXMLParsing):

def __init__(self, inputs):
self.test = {}
self.target_to_test = {}
Expand All @@ -81,7 +81,7 @@ def __init__(self, inputs):
self.timestamps = []
for input in inputs:
self.add_input(input)

def add_input(self, input):
'''
Add a single build XML output file to our data.
Expand All @@ -101,7 +101,7 @@ def add_input(self, input):
(x_f[1])(node)
elif event == xml.dom.pulldom.END_ELEMENT:
context.pop()

def x_name_(self, *context, **kwargs):
node = None
names = [ ]
Expand All @@ -119,7 +119,7 @@ def x_name_(self, *context, **kwargs):
if hasattr(self,name):
return (name,getattr(self,name))
return None

def x_build_test(self, node):
'''
Records the initial test information that will eventually
Expand All @@ -142,7 +142,7 @@ def x_build_test(self, node):
# Add a lookup for the test given the test target.
self.target_to_test[self.test[test_name]['target']] = test_name
return None

def x_build_targets_target( self, node ):
'''
Process the target dependency DAG into an ancestry tree so we can look up
Expand All @@ -165,7 +165,7 @@ def x_build_targets_target( self, node ):
self.parent[child_jam_target] = jam_target
dep_node = self.get_sibling(dep_node.nextSibling,tag='dependency')
return None

def x_build_action( self, node ):
'''
Given a build action log, process into the corresponding test log and
Expand Down Expand Up @@ -231,14 +231,14 @@ def x_build_action( self, node ):
if action_type == 'result':
test['result'] = action['result']
return None

def x_build_timestamp( self, node ):
'''
The time-stamp goes to the corresponding attribute in the result.
'''
self.timestamps.append(self.get_data(node).strip())
return None

def get_test( self, node, type = None ):
'''
Find the test corresponding to an action. For testing targets these
Expand Down Expand Up @@ -269,24 +269,24 @@ def get_test( self, node, type = None ):
test = self.test[lib]
else:
target_name_ = self.target[target]['name']
if self.target_to_test.has_key(target_name_):
if target_name_ in self.target_to_test:
test = self.test[self.target_to_test[target_name_]]
else:
test = None
return (base,test)

#~ The command executed for the action. For run actions we omit the command
#~ as it's just noise.
def get_action_command( self, action_node, action_type ):
if action_type != 'run':
return self.get_child_data(action_node,tag='command')
else:
return ''

#~ The command output.
def get_action_output( self, action_node, action_type ):
return self.get_child_data(action_node,tag='output',default='')

#~ Some basic info about the action.
def get_action_info( self, action_node, action_type ):
info = {}
Expand All @@ -311,17 +311,17 @@ def get_action_info( self, action_node, action_type ):
return info

class BuildConsoleSummaryReport(object):

HEADER = '\033[35m\033[1m'
INFO = '\033[34m'
OK = '\033[32m'
WARNING = '\033[33m'
FAIL = '\033[31m'
ENDC = '\033[0m'

def __init__(self, bop, opt):
self.bop = bop

def generate(self):
self.summary_info = {
'total' : 0,
Expand All @@ -332,11 +332,11 @@ def generate(self):
self.print_test_log()
self.print_summary()
self.header_print("======================================================================")

@property
def failed(self):
return len(self.summary_info['failed']) > 0

def print_test_log(self):
self.header_print("Tests run..")
self.header_print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
Expand All @@ -359,7 +359,7 @@ def print_test_log(self):
self.fail_print("[FAIL] {0}",k)
for action in test['actions']:
self.print_action(succeed, action)

def print_action(self, test_succeed, action):
'''
Print the detailed info of failed or always print tests.
Expand All @@ -376,7 +376,7 @@ def print_action(self, test_succeed, action):
p("")
for line in output.splitlines():
p("{0}",line.encode('utf-8'))

def print_summary(self):
self.header_print("")
self.header_print("Testing summary..")
Expand All @@ -387,27 +387,27 @@ def print_summary(self):
self.fail_print("Failed: {0}",len(self.summary_info['failed']))
for test in self.summary_info['failed']:
self.fail_print(" {0}/{1}",test['library'],test['test-name'])

def p_print(self, format, *args, **kargs):
print format.format(*args,**kargs)
print(format.format(*args,**kargs))

def info_print(self, format, *args, **kargs):
print self.INFO+format.format(*args,**kargs)+self.ENDC
print(self.INFO+format.format(*args,**kargs)+self.ENDC)

def header_print(self, format, *args, **kargs):
print self.HEADER+format.format(*args,**kargs)+self.ENDC
print(self.HEADER+format.format(*args,**kargs)+self.ENDC)

def ok_print(self, format, *args, **kargs):
print self.OK+format.format(*args,**kargs)+self.ENDC
print(self.OK+format.format(*args,**kargs)+self.ENDC)

def warn_print(self, format, *args, **kargs):
print self.WARNING+format.format(*args,**kargs)+self.ENDC
print(self.WARNING+format.format(*args,**kargs)+self.ENDC)

def fail_print(self, format, *args, **kargs):
print self.FAIL+format.format(*args,**kargs)+self.ENDC
print(self.FAIL+format.format(*args,**kargs)+self.ENDC)

class Main(object):

def __init__(self,args=None):
op = optparse.OptionParser(
usage="%prog [options] input+")
Expand Down
Loading