Skip to content

Commit 7d3fe5e

Browse files
committed
Find crates that have never passed
1 parent 23ad908 commit 7d3fe5e

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

find-bad-crates.py

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import os
2+
import json
3+
import glob
4+
5+
RESULT_PATHS = 'result_paths.json'
6+
RESULTS = 'results.json'
7+
8+
if not os.path.exists(RESULT_PATHS):
9+
# starts are: ex, commitish, reg/gh, crate
10+
result_paths = glob.glob('work/ex/*/res/*/*/*/results.txt')
11+
with open(RESULT_PATHS, 'w') as f:
12+
f.write(json.dumps(result_paths))
13+
with open(RESULT_PATHS) as f:
14+
result_paths = json.load(f)
15+
16+
if not os.path.exists(RESULTS):
17+
results = {}
18+
for path in result_paths:
19+
with open(path) as f:
20+
pathdir = path[:-(len('results.txt')+1)]
21+
results[pathdir] = f.read()
22+
with open(RESULTS, 'w') as f:
23+
f.write(json.dumps(results))
24+
with open(RESULTS) as f:
25+
results = json.load(f)
26+
27+
sames = {}
28+
for pathdir, result in results.iteritems():
29+
assert result in ['build-fail', 'test-fail', 'test-pass', 'test-skipped']
30+
head, crate = os.path.split(pathdir)
31+
_, gh_or_reg = os.path.split(head)
32+
if gh_or_reg == 'gh':
33+
# e.g. pepyakin.chipster.9cd0c41e16b8e1a58381b3fb18ed412c92237f4e
34+
name = crate.rsplit('.', 1)[0]
35+
elif gh_or_reg == 'reg':
36+
# e.g. effect-monad-0.3.1
37+
name = crate.rsplit('-', 1)[0]
38+
else:
39+
assert False, pathdir
40+
41+
key = (gh_or_reg, name)
42+
cur = sames.get(key)
43+
if cur is None:
44+
sames[key] = (result, 1)
45+
else:
46+
cur_result, cur_count = cur
47+
if cur_result is None:
48+
# This one has already mismatched
49+
pass
50+
elif result != cur_result:
51+
sames[key] = (None, 0)
52+
else:
53+
sames[key] = (cur_result, cur_count + 1)
54+
55+
num_exs = len(glob.glob('work/ex/*'))
56+
# Can be more than this, crater sometimes decides to test multiple versions of a crate
57+
all_fails = 2 * num_exs
58+
59+
ghlines = []
60+
reglines = []
61+
for (gh_or_reg, name), (result, count) in sames.iteritems():
62+
if result is None:
63+
continue
64+
if result in ['test-pass', 'test-skipped']:
65+
continue
66+
if count != all_fails:
67+
continue
68+
69+
if result == 'build-fail':
70+
skipkind = 'skip'
71+
elif result == 'test-fail':
72+
skipkind = 'skip-tests'
73+
else:
74+
assert False, result
75+
if gh_or_reg == 'gh':
76+
if name.count('.') > 1:
77+
# Can't be bothered figuring this out - probably means the repo name has a dot
78+
continue
79+
org, repo = name.split('.')
80+
ghlines.append('"{}/{}" = {{ {} = true }}'.format(org, repo, skipkind))
81+
else:
82+
if name.count('.') > 1:
83+
# Can't be bothered figuring this out - probably means the crate version had
84+
# a -beta1 or something
85+
continue
86+
reglines.append('{} = {{ {} = true }}'.format(name, skipkind))
87+
#print '|'.join((gh_or_reg, name)), result, count
88+
ghlines.sort()
89+
reglines.sort()
90+
91+
open('ghlines.toml', 'w').write('\n'.join(ghlines))
92+
open('reglines.toml', 'w').write('\n'.join(reglines))

0 commit comments

Comments
 (0)