Skip to content

Commit 9cc86f1

Browse files
authored
Merge pull request #2661 from jsiirola/compare-update
Improve compare.py handling of nosetests/pytest output
2 parents 6d9db0f + 57ca6d0 commit 9cc86f1

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

scripts/performance/compare.py

+39
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,56 @@ def combine(*results):
136136
for result in results:
137137
for dataset in result[1:]:
138138
for test, result in dataset.items():
139+
if "::" not in test:
140+
# Convert nosetests results in to pytest format
141+
path, test = test.split(':')
142+
test = '/'.join(path.split('.')) + '.py::' \
143+
+ '::'.join(test.split('.'))
139144
if test not in ans:
140145
ans[test] = {}
141146
testdata = ans[test]
142147
for metric, value in result.items():
143148
if type(value) is dict:
144149
continue
145150
testdata.setdefault(metric, []).append(value)
151+
# Nosetests and pytest would give different test names (based on
152+
# where they started including path elements). We will assume that
153+
# tests should be uniquely declared by the test file, class, and
154+
# test name. So, any two tests where one name ends with the
155+
# complete name of the other will be assumed to be the same test and
156+
# combined.
157+
for base in list(ans):
158+
for test in ans:
159+
if test == base:
160+
break
161+
if test.endswith(base):
162+
testdata = ans[test]
163+
otherdata = ans.pop(base)
164+
for metric, value in otherdata.items():
165+
testdata.setdefault(metric, []).append(value)
166+
break
146167
return ans
147168

148169
def compare(base_data, test_data):
149170
"""Compare two data sets (generated by compare())"""
171+
# Nosetests and pytest would give different test names (based on
172+
# where they started including path elements). We will assume that
173+
# tests should be uniquely declared by the test file, class, and
174+
# test name. So, any two tests where one name ends with the
175+
# complete name of the other will be assumed to be the same test.
176+
# We will make both to the "more specific" (longer) name before
177+
# comparing.
178+
for base in list(base_data):
179+
for test in test_data:
180+
if base == test:
181+
break
182+
if test.endswith(base):
183+
base_data[test] = base_data.pop(base)
184+
break
185+
if base.endswith(test):
186+
test_data[base] = test_data.pop(test)
187+
break
188+
150189
fields = set()
151190
for testname, base in base_data.items():
152191
if testname not in test_data:

0 commit comments

Comments
 (0)