-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypeBased.py
61 lines (55 loc) · 2.2 KB
/
typeBased.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
import sys
import random_select
import csv
import json
import re
from collections import Counter
BASE = '../pharo-projects-files'
def analyseMethodName(mName):
import re
m = re.search('.+\>\>\#test.+_amp(.*)', mName)
p = [x[0] if len(x) >0 else '' for x in m.group(1).split("_")]
return p[1:]
def main():
if len(sys.argv) < 2:
sys.exit("I need a file name")
file = sys.argv[1]
with open(file) as f:
csv_f = csv.reader(f)
next(csv_f) # skip the header
for row in csv_f:
# if row[1].startswith('WebGrammarTest'):
project = row[12]
cls = row[1]
kills = []
aamp_kills = []
with open(BASE + '/' + project + '/' + cls + '.json') as f:
jsonObj = json.loads(f.read())
with open(BASE + '/' + project + '/' + jsonObj['amplifiedClass'] + '.st') as f2:
stFile = f2.read()
for m in jsonObj['amplifiedMethods']:
if m.endswith('_amp'):
for junk in stFile.split('!'):
if junk.strip().startswith(m.split('#')[1]) and not junk.strip().startswith(m.split('#')[1] + "_"):
rx_sequence=re.compile(r"\<smallAmpCoveres\: '(.*)'\>",re.MULTILINE)
for match in rx_sequence.finditer(junk):
aamp_kills.append(match)
for m in jsonObj['amplifiedMethods']:
thisAmps = analyseMethodName(m)
#print(thisAmps)
if 'A' in thisAmps or 'T' in thisAmps:
with open(BASE + '/' + project + '/' + jsonObj['amplifiedClass'] + '.st') as f2:
stFile = f2.read()
for junk in stFile.split('!'):
if junk.strip().startswith(m.split('#')[1]) and not junk.strip().startswith(m.split('#')[1]+ "_"):
rx_sequence=re.compile(r"\<smallAmpCoveres\: '(.*)'\>",re.MULTILINE)
for match in rx_sequence.finditer(junk):
kills.append(match)
# print(match.group(0))
kills = {x.group(0) for x in kills}
aamp_kills = {x.group(0) for x in aamp_kills}
# print(kills)
# print( aamp_kills)
print(len(kills.difference( aamp_kills) ))
if __name__ == "__main__":
main()