forked from canonical/hwcert-jenkins-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob-summary
executable file
·104 lines (91 loc) · 3.35 KB
/
job-summary
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
import json
import os
import sys
if len(sys.argv) < 2:
print('Usage:')
print(
'\t{} [JSON_RESULT_FILE [OLD_JSON_RESULT_FILE]]'.format(sys.argv[0]))
sys.exit(1)
if not os.path.exists(sys.argv[1]):
print('No results file found!')
print('Usually this means that the run failed to complete. ',
'Check the output in the jenkins job for more details')
sys.exit(0)
with open(sys.argv[1]) as result_file:
result_data = json.load(result_file)
# Get all results from the file
if type(result_data) is list:
# Old style json report
results = [x for x in result_data if 'results' in x.keys()][0]['results']
fails = [x.get('id') for x in results if x.get('status') == 'failed']
passes = [x.get('id') for x in results if x.get('status') == 'passed']
skips = [x.get('id') for x in results if x.get('status') == 'not supported']
elif type(result_data) is dict:
# New style json report for submission service
results = result_data.get('results')
fails = [x.get('id') for x in results if x.get('status') == 'fail']
passes = [x.get('id') for x in results if x.get('status') == 'pass']
skips = [x.get('id') for x in results if x.get('status') == 'skip']
if os.path.exists('c3link'):
print('\n')
with open('c3link') as c3link:
print('Full results at: {}'.format(c3link.read()))
print('Summary')
print('-------')
print('pass:\t{}'.format(len(passes)))
print('fail:\t{}'.format(len(fails)))
print('skip:\t{}'.format(len(skips)))
print('total:\t{}'.format(len(results)))
print('\n')
if len(fails) == 0:
print('All tests passed!')
else:
print('Failed tests:')
for result in fails:
print(result)
if len(sys.argv) > 2 and os.path.exists(sys.argv[2]):
with open(sys.argv[2]) as result_file:
result_data = json.load(result_file)
# Get all results from the previous result file
if type(result_data) is list:
# Old style json report
oldresults = [
x for x in result_data if 'results' in x.keys()][0]['results']
oldfails = [
x.get('id') for x in oldresults if x.get('status') == 'failed']
oldpasses = [
x.get('id') for x in oldresults if x.get('status') == 'passed']
oldskips = [
x.get('id') for x in oldresults
if x.get('status') == 'not supported']
elif type(result_data) is dict:
# New style json report for submission service
oldresults = result_data.get('results')
oldfails = [
x.get('id') for x in oldresults if x.get('status') == 'fail']
oldpasses = [
x.get('id') for x in oldresults if x.get('status') == 'pass']
oldskips = [
x.get('id') for x in oldresults if x.get('status') == 'skip']
print('\n\nNew failed tests:')
newfails = [x for x in fails if x not in oldfails]
if not newfails:
print('None')
else:
for result in newfails:
print(result)
print('\n\nNew passing tests:')
newpasses = [x for x in passes if x not in oldpasses]
if not newpasses:
print('None')
else:
for result in newpasses:
print(result)
print('\n\nNew skipped tests:')
newskips = [x for x in skips if x not in oldskips]
if not newskips:
print('None')
else:
for result in newskips:
print(result)