OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """dedup-tests -- print test results duplicated between win and linux. | |
7 | |
8 Because the outputs are very similar, we fall back on Windows outputs | |
9 if there isn't an expected output for Linux layout tests. This means | |
10 that any file that is duplicated between the Linux and Windows directories | |
11 is redundant. | |
12 | |
13 This command dumps out all such files. You can use it like: | |
14 dedup-tests.py # print out the bad files | |
15 dedup-tests.py | xargs git rm # delete the bad files | |
16 """ | |
17 | |
18 import collections | |
19 import os.path | |
20 import subprocess | |
21 import sys | |
22 | |
23 # A map of file hash => set of all files with that hash. | |
24 hashes = collections.defaultdict(set) | |
25 | |
26 # Fill in the map. | |
27 cmd = ['git', 'ls-tree', '-r', 'HEAD', 'webkit/data/layout_tests/'] | |
28 try: | |
29 git = subprocess.Popen(cmd, stdout=subprocess.PIPE) | |
30 except OSError, e: | |
31 if e.errno == 2: # No such file or directory. | |
32 print >> sys.stderr, "Error: 'No such file' when running git." | |
33 print >> sys.stderr, "This script requires git." | |
34 sys.exit(1) | |
35 raise e | |
36 | |
37 for line in git.stdout: | |
38 attrs, file = line.strip().split('\t') | |
39 _, _, hash = attrs.split(' ') | |
40 hashes[hash].add(file) | |
41 | |
42 # Dump out duplicated files. | |
43 for cluster in hashes.values(): | |
44 if len(cluster) < 2: | |
45 continue | |
46 for file in cluster: | |
47 if '/chromium-linux/' in file: | |
48 if file.replace('/chromium-linux/', '/chromium-win/') in cluster: | |
49 print file | |
OLD | NEW |