forked from llvm/llvm-project
- Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathtracking.py
executable file
·120 lines (102 loc) · 4.09 KB
/
tracking.py
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
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python
importos
importos.path
importdatetime
importre
importsys
sys.path.append(os.path.join(os.getcwd(), 'radarclient-python'))
defusage():
print"Run this from somewhere fancy"
print"Install pycurl and radarclient"
print"To install radarclient - while in the LLDB test repository do 'git clone https://your_od_username@swegit.apple.com/git/radarclient-python.git'"
print"To install pycurl - from anywhere, do 'sudo easy_install pycurl'"
sys.exit(1)
try:
fromradarclientimport*
except:
usage()
deffind_session_dir():
# Use heuristic to find the latest session directory.
name=datetime.datetime.now().strftime("%Y-%m-%d-")
dirs= [dfordinos.listdir(os.getcwd()) ifd.startswith(name)]
iflen(dirs) ==0:
print"No default session directory found, please specify it explicitly."
usage()
session_dir=max(dirs, key=os.path.getmtime)
ifnotsession_dirornotos.path.exists(session_dir):
print"No default session directory found, please specify it explicitly."
usage()
returnos.path.join(os.getcwd(), session_dir)
defprocess_no_bug(path, txt):
print'Failure %s has no bug tracking (says %s) - why?'% (path, txt)
defprocess_llvm_bug(path, pr):
print'Failure %s has an LLVM bug tracking: %s - why no radar?'% (path, pr.group(1))
defprocess_radar_bug(path, rdr):
rdr=get_radar_details(rdr.group(1))
ifnotrdr:
print'Failure %s claims to be tracked by rdar://%s but no such bug exists - consider filing one'% (path, rdr.group(1))
return
print'Failure %s has a radar bug tracking: rdar://%s %s - cool'% (path, rdr.id, rdr.title)
ifrdr.state!='Analyze':
print'This radar is not in Analyze anymore - Consider filing a new one, or editing the test case'
print' Assignee: %s %s'% (rdr.assignee.firstName, rdr.assignee.lastName)
print' Milestone: %s'% (rdr.milestone[u'name'] ifrdr.milestoneelse'None')
print' Priority: %s'% (rdr.priority)
global_radar_client=None
defget_radar_details(id):
globalglobal_radar_client
ifglobal_radar_clientisNone:
authentication_strategy=AuthenticationStrategySPNego()
system_identifier=ClientSystemIdentifier('lldb-test-tracker', '1.0')
global_radar_client=RadarClient(
authentication_strategy, system_identifier)
global_radar_client.problem_default_fields= [
'id',
'title',
'assignee',
'milestone',
'component',
'priority',
'fixOrder',
'state',
'substate',
'resolution',
'duplicateOfProblemID']
rdar=global_radar_client.radar_for_id(id)
ifrdar.state=='Verify'orrdar.state=='Closed'andrdar.resolution=='Duplicate':
returnget_radar_details(rdar.duplicateOfProblemID)
returnrdar
defprocess_xfail(path):
marker='expected failure (problem id:'
content=""
withopen(path, 'r') ascontent_file:
content=content_file.read()
name=os.path.basename(path)
try:
name=name[name.find('-') +1:]
name=name[name.find('-') +1:]
name=name[name.find('-') +1:]
name=name.replace('.log', '')
name=name[:name.rfind('.') -1]
finally:
pass
xfail_line=content[content.find(
'expected failure (problem id:') +len(marker):]
xfail_line=xfail_line[:xfail_line.find('\n')]
m1=re.search('rdar://([0-9]+)', xfail_line)
m2=re.search('rdar://problem/([0-9]+)', xfail_line)
m3=re.search('llvm.org/pr([0-9]+)', xfail_line)
ifm1isNoneandm2isNone:
ifm3isNone:
process_no_bug(name, xfail_line)
else:
process_llvm_bug(name, m3)
else:
process_radar_bug(name, m1ifm1elsem2)
print""
session_dir_path=find_session_dir()
importos
forroot, dirs, filesinos.walk(session_dir_path, topdown=False):
fornameinfiles:
ifname.startswith("ExpectedFailure"):
process_xfail(os.path.join(session_dir_path, name))