Better display of 'solar changes test' results

This commit is contained in:
Przemyslaw Kaminski
2015-09-03 10:03:44 +02:00
parent f5c26a071d
commit e9343862cc
2 changed files with 36 additions and 6 deletions

View File

@@ -1,25 +1,28 @@
import imp
import networkx as nx
import os
import traceback
from log import log
from solar.core import resource
from solar.core import signals
def test_all():
results = {}
conn_graph = signals.detailed_connection_graph()
#srt = nx.topological_sort(conn_graph)
for name in conn_graph:
print 'Trying {}'.format(name)
log.debug('Trying {}'.format(name))
r = resource.load(name)
script_path = os.path.join(r.metadata['base_path'], 'test.py')
if not os.path.exists(script_path):
print 'WARNING: resource {} has no tests'.format(name)
log.warning('resource {} has no tests'.format(name))
continue
print 'File {} found'.format(script_path)
log.debug('File {} found'.format(script_path))
with open(script_path) as f:
module = imp.load_module(
@@ -29,4 +32,15 @@ def test_all():
('', 'r', imp.PY_SOURCE)
)
module.test(r)
try:
module.test(r)
results[name] = {
'status': 'ok',
}
except:
results[name] = {
'status': 'error',
'message': traceback.format_exc(),
}
return results