-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpr-test-case-plot-all.py
More file actions
executable file
·108 lines (85 loc) · 3.26 KB
/
pr-test-case-plot-all.py
File metadata and controls
executable file
·108 lines (85 loc) · 3.26 KB
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
105
106
107
108
#!/usr/bin/env python3
import os, optparse, sys, json, datetime, ntpath
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
DEFAULT_OUTPUT_DIRECTORY = os.getcwd ()
def main (option):
with open (option.file, "r") as f:
allTestCase = json.load (f)
fig, axs = plt.subplots (2,
1,
sharex=True,
figsize=(10,7),
gridspec_kw={'height_ratios': [3,1]})
fig.subplots_adjust (hspace=0.05)
yearPlot = None
dates = []
passingCurrent = []
passingDelta = []
failedDelta = []
totalTests = []
for date in sorted (allTestCase):
dates.append (datetime.datetime.strptime (date,"%Y-%m-%d"))
try:
dataPoint = allTestCase[date]["passing"]["current"]
except:
dataPoint = 0
passingCurrent.append (dataPoint)
try:
dataPoint = allTestCase[date]["passing"]["delta"]
if not dataPoint:
dataPoint = 0
except:
dataPoint = 0
passingDelta.append (dataPoint)
try:
dataPoint = allTestCase[date]["failed"]["delta"]
if not dataPoint:
dataPoint = 0
except:
dataPoint = 0
failedDelta.append (dataPoint)
try:
dataPoint = allTestCase[date]["failed"]["current"]
if not dataPoint:
dataPoint = 0
except:
dataPoint = 0
totalTests.append (dataPoint + passingCurrent[-1])
axs[0].plot (dates, passingCurrent, linewidth=2, label="Passed test cases")
axs[0].plot (dates, totalTests, linewidth=1, label="Total test cases")
axs[1].plot (dates, passingDelta, linewidth=2, label="Passed (Δ)")
axs[1].plot (dates, failedDelta, linewidth=1, label="Failed (Δ)")
for ax in axs:
ax.xaxis.set_major_locator (mdates.MonthLocator (bymonth=(1, 7)))
ax.xaxis.set_minor_locator (mdates.MonthLocator ())
ax.grid (True)
axs[0].set (title="Rust GCC Test Cases")
axs[0].set (ylabel="Test Cases")
axs[0].legend ()
axs[1].set (xlabel="Date", ylabel="Deltas (Δ)")
axs[1].legend ()
for label in axs[1].get_xticklabels(which='major'):
label.set(rotation=30, horizontalalignment='right')
print ("saving image:", option.output)
plt.savefig (option.output)
if __name__ == "__main__":
cwd = os.getcwd ()
parser = optparse.OptionParser ()
parser.add_option ("-f", "--file",
type = "string",
dest = "file",
default = None,
help = "all-test-case.json to graph can't be empty")
parser.add_option ("-o", "--output",
type = "string",
dest = "output",
default = DEFAULT_OUTPUT_DIRECTORY,
help = ("Output directory, Default: %s" %DEFAULT_OUTPUT_DIRECTORY))
option, arg = parser.parse_args ()
if not option.file or not os.path.isfile (option.file):
parser.print_help ()
sys.exit (1)
fileName = ntpath.basename (option.file).replace (".json", ".png")
option.output = os.path.join (option.output, fileName)
main (option)