Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Side by Side Diff: media/tools/layout_tests/test_expectations_history.py

Issue 14316009: Update tools to reflect movement of TestExpectations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix equality test Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A module for the history of the test expectation file.""" 5 """A module for the history of the test expectation file."""
6 6
7 from datetime import datetime 7 from datetime import datetime
8 from datetime import timedelta 8 from datetime import timedelta
9 9
10 import re 10 import re
11 import sys 11 import sys
12 import time 12 import time
13 import pysvn 13 import pysvn
14 14
15 # Default Webkit SVN location for chromium test expectation file. 15 TEST_EXPECTATIONS_ROOT = 'http://src.chromium.org/blink/trunk/'
16 # A map from earliest revision to path.
16 # TODO(imasaki): support multiple test expectation files. 17 # TODO(imasaki): support multiple test expectation files.
17 DEFAULT_TEST_EXPECTATION_LOCATION = ( 18 TEST_EXPECTATIONS_LOCATIONS = {
18 'http://svn.webkit.org/repository/webkit/trunk/' 19 148348: 'LayoutTests/TestExpectations',
19 'LayoutTests/platform/chromium/TestExpectations') 20 119317: 'LayoutTests/platform/chromium/TestExpectations',
20 LEGACY_TEST_EXPECTATION_LOCATION = ( 21 0: 'LayoutTests/platform/chromium/test_expectations.txt'}
21 'http://svn.webkit.org/repository/webkit/trunk/' 22 TEST_EXPECTATIONS_DEFAULT_PATH = (
22 'LayoutTests/platform/chromium/test_expectations.txt') 23 TEST_EXPECTATIONS_ROOT + TEST_EXPECTATIONS_LOCATIONS[148348])
23 24
24 class TestExpectationsHistory(object): 25 class TestExpectationsHistory(object):
25 """A class to represent history of the test expectation file. 26 """A class to represent history of the test expectation file.
26 27
27 The history is obtained by calling PySVN.log()/diff() APIs. 28 The history is obtained by calling PySVN.log()/diff() APIs.
28 29
29 TODO(imasaki): Add more functionalities here like getting some statistics 30 TODO(imasaki): Add more functionalities here like getting some statistics
30 about the test expectation file. 31 about the test expectation file.
31 """ 32 """
32 33
33 @staticmethod 34 @staticmethod
35 def GetTestExpectationsPathForRevision(revision):
36 for i in sorted(TEST_EXPECTATIONS_LOCATIONS.keys(), reverse=True):
37 if revision >= i:
38 return TEST_EXPECTATIONS_ROOT + TEST_EXPECTATIONS_LOCATIONS[i]
39
40 @staticmethod
34 def GetDiffBetweenTimes(start, end, testname_list, 41 def GetDiffBetweenTimes(start, end, testname_list,
35 te_location=DEFAULT_TEST_EXPECTATION_LOCATION): 42 te_location=TEST_EXPECTATIONS_DEFAULT_PATH):
36 """Get difference between time period for the specified test names. 43 """Get difference between time period for the specified test names.
37 44
38 Given the time period, this method first gets the revision number. Then, 45 Given the time period, this method first gets the revision number. Then,
39 it gets the diff for each revision. Finally, it keeps the diff relating to 46 it gets the diff for each revision. Finally, it keeps the diff relating to
40 the test names and returns them along with other information about 47 the test names and returns them along with other information about
41 revision. 48 revision.
42 49
43 Args: 50 Args:
44 start: A timestamp specifying start of the time period to be 51 start: A timestamp specifying start of the time period to be
45 looked at. 52 looked at.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 # Prepend at the beginning of logs. 87 # Prepend at the beginning of logs.
81 logs.insert(0, logs_before_time_period[len(logs_before_time_period)-1]) 88 logs.insert(0, logs_before_time_period[len(logs_before_time_period)-1])
82 break 89 break
83 gobackdays *= 2 90 gobackdays *= 2
84 91
85 for i in xrange(len(logs) - 1): 92 for i in xrange(len(logs) - 1):
86 old_rev = logs[i].revision.number 93 old_rev = logs[i].revision.number
87 new_rev = logs[i + 1].revision.number 94 new_rev = logs[i + 1].revision.number
88 # Parsing the actual diff. 95 # Parsing the actual diff.
89 96
90 # test_expectations.txt was renamed to TestExpectations at r119317. 97 new_path = TestExpectationsHistory.GetTestExpectationsPathForRevision(
91 new_path = DEFAULT_TEST_EXPECTATION_LOCATION 98 new_rev);
92 if new_rev < 119317: 99 old_path = TestExpectationsHistory.GetTestExpectationsPathForRevision(
93 new_path = LEGACY_TEST_EXPECTATION_LOCATION 100 old_rev);
94 old_path = DEFAULT_TEST_EXPECTATION_LOCATION
95 if old_rev < 119317:
96 old_path = LEGACY_TEST_EXPECTATION_LOCATION
97 101
98 text = client.diff('/tmp', 102 text = client.diff('/tmp',
99 url_or_path=old_path, 103 url_or_path=old_path,
100 revision1=pysvn.Revision( 104 revision1=pysvn.Revision(
101 pysvn.opt_revision_kind.number, old_rev), 105 pysvn.opt_revision_kind.number, old_rev),
102 url_or_path2=new_path, 106 url_or_path2=new_path,
103 revision2=pysvn.Revision( 107 revision2=pysvn.Revision(
104 pysvn.opt_revision_kind.number, new_rev)) 108 pysvn.opt_revision_kind.number, new_rev))
105 lines = text.split('\n') 109 lines = text.split('\n')
106 target_lines = [] 110 target_lines = []
107 for line in lines: 111 for line in lines:
108 for testname in testname_list: 112 for testname in testname_list:
109 matches = re.findall(testname, line) 113 matches = re.findall(testname, line)
110 if matches: 114 if matches:
111 if line[0] == '+' or line[0] == '-': 115 if line[0] == '+' or line[0] == '-':
112 target_lines.append(line) 116 target_lines.append(line)
113 if target_lines: 117 if target_lines:
114 # Needs to convert to normal date string for presentation. 118 # Needs to convert to normal date string for presentation.
115 result_list.append(( 119 result_list.append((
116 old_rev, new_rev, logs[i + 1].author, 120 old_rev, new_rev, logs[i + 1].author,
117 datetime.fromtimestamp( 121 datetime.fromtimestamp(
118 logs[i + 1].date).strftime('%Y-%m-%d %H:%M:%S'), 122 logs[i + 1].date).strftime('%Y-%m-%d %H:%M:%S'),
119 logs[i + 1].message, target_lines)) 123 logs[i + 1].message, target_lines))
120 return result_list 124 return result_list
OLDNEW
« no previous file with comments | « media/tools/layout_tests/test_expectations.py ('k') | media/tools/layout_tests/test_expectations_history_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698