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

Side by Side Diff: webkit/tools/layout_tests/layout_package/failure_finder_test.py

Issue 160054: Adds a new unit tests for layout tests formatting script.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/bin/env/python
2 # Copyright (c) 2006-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 import os
7
8 from failure_finder import FailureFinder
9
10 TEST_BUILDER_OUTPUT = """090723 10:38:22 test_shell_thread.py:289
11 ERROR chrome/fast/forms/textarea-metrics.html failed:
12 Text diff mismatch
13 Simplified text diff mismatch
14 090723 10:38:21 test_shell_thread.py:289
15 ERROR chrome/fast/dom/xss-DENIED-javascript-variations.html failed:
16 Text diff mismatch
17 Simplified text diff mismatch
18 090723 10:37:58 test_shell_thread.py:289
19 ERROR LayoutTests/plugins/bindings-test.html failed:
20 Text diff mismatch
21 Simplified text diff mismatch
22 ------------------------------------------------------------------------------
23 Expected to crash, but passed (1):
24 chrome/fast/forms/textarea-metrics.html
25
26 Regressions: Unexpected failures (2):
27 chrome/fast/dom/xss-DENIED-javascript-variations.html = FAIL
28 LayoutTests/plugins/bindings-test.html = FAIL
29 ------------------------------------------------------------------------------
30 """
31
32 WEBKIT_BUILDER_NUMBER = "9800"
33 WEBKIT_FAILURES = (
34 ["LayoutTests/fast/backgrounds/animated-svg-as-mask.html",
35 "LayoutTests/fast/backgrounds/background-clip-text.html",
36 "LayoutTests/fast/backgrounds/mask-composite.html",
37 "LayoutTests/fast/backgrounds/repeat/mask-negative-offset-repeat.html",
38 "LayoutTests/fast/backgrounds/svg-as-background-3.html",
39 "LayoutTests/fast/backgrounds/svg-as-background-6.html",
40 "LayoutTests/fast/backgrounds/svg-as-mask.html",
41 "LayoutTests/fast/block/float/013.html",
42 "LayoutTests/fast/block/float/nested-clearance.html",
43 "LayoutTests/fast/block/positioning/047.html"])
44
45 CHROMIUM_BASELINE = "chrome/fast/forms/basic-buttons.html"
46 EXPECTED_CHROMIUM_LOCAL_BASELINE = "./chrome/fast/forms/basic-buttons.html"
47 EXPECTED_CHROMIUM_URL_BASELINE = ("http://src.chromium.org/viewvc/chrome/"
48 "trunk/src/webkit/data/layout_tests/chrome/"
49 "fast/forms/basic-buttons.html")
50
51 WEBKIT_BASELINE = "LayoutTests/fast/forms/11423.html"
52 EXPECTED_WEBKIT_LOCAL_BASELINE = "./LayoutTests/fast/forms/11423.html"
53 EXPECTED_WEBKIT_URL_BASELINE = ("http://svn.webkit.org/repository/webkit/trunk/"
54 "LayoutTests/fast/forms/11423.html")
55
56 TEST_ZIP_FILE = ("http://build.chromium.org/buildbot/layout_test_results/"
57 "webkit-rel/21432/layout-test-results.zip")
58
59 EXPECTED_REVISION = "20861"
60 EXPECTED_BUILD_NAME = "webkit-rel"
61
62 class FailureFinderTest(object):
63
64 def runTests(self):
65 all_tests_passed = True
66
67 tests = ["testWhitespaceInBuilderName",
68 "testGetLastBuild",
69 "testFindMatchesInBuilderOutput",
70 "testScrapeBuilderOutput",
71 "testGetChromiumBaseline",
72 "testGetWebkitBaseline",
73 "testZipDownload",
74 "testTranslateBuildToZip",
75 "testFull"]
76
77 for test in tests:
78 print test
79 result = eval(test + "()")
80 if result:
81 print "PASS"
82 else:
83 all_tests_passed = False
84 print "FAIL"
85 return all_tests_passed
86
87 def _getBasicFailureFinder():
88 return FailureFinder(None, "Webkit", False, "", ".", 10, False)
89
90 def _testLastBuild(failure_finder):
91 try:
92 last_build = failure_finder.GetLastBuild()
93 # Verify that last_build is not empty and is a number.
94 build = int(last_build)
95 return (build > 0)
96 except:
97 return False
98
99 def testGetLastBuild():
100 test = _getBasicFailureFinder()
101 return _testLastBuild(test)
102
103 def testWhitespaceInBuilderName():
104 test = _getBasicFailureFinder()
105 test.SetPlatform("Webkit (webkit.org)")
106 return _testLastBuild(test)
107
108 def testScrapeBuilderOutput():
109
110 # Try on the default builder.
111 test = _getBasicFailureFinder()
112 test.build = "9800"
113 output = test._ScrapeBuilderOutput()
114 if not output:
115 return False
116
117 # Try on a crazy builder on the FYI waterfall.
118 test = _getBasicFailureFinder()
119 test.build = "1766"
120 test.SetPlatform("Webkit Linux (webkit.org)")
121 output = test._ScrapeBuilderOutput()
122 if not output:
123 return False
124
125 return True
126
127 def testFindMatchesInBuilderOutput():
128 test = _getBasicFailureFinder()
129 test.exclude_known_failures = True
130 matches = test._FindMatchesInBuilderOutput(TEST_BUILDER_OUTPUT)
131 # Verify that we found x matches.
132 if len(matches) != 2:
133 print "Did not find all unexpected failures."
134 return False
135
136 test.exclude_known_failures = False
137 matches = test._FindMatchesInBuilderOutput(TEST_BUILDER_OUTPUT)
138 if len(matches) != 3:
139 print "Did not find all failures."
140 return False
141 return True
142
143 def _testBaseline(test_name, expected_local, expected_url):
144 test = _getBasicFailureFinder()
145 # Test baseline that is obviously in Chromium's tree.
146 local, url = test._GetBaseline(test_name, ".", False)
147 try:
148 os.remove(local)
149 if (local != expected_local or url != expected_url):
150 return False
151 except:
152 return False
153 return True
154
155 def testGetChromiumBaseline():
156 return _testBaseline(CHROMIUM_BASELINE, EXPECTED_CHROMIUM_LOCAL_BASELINE,
157 EXPECTED_CHROMIUM_URL_BASELINE)
158
159 def testGetWebkitBaseline():
160 return _testBaseline(WEBKIT_BASELINE, EXPECTED_WEBKIT_LOCAL_BASELINE,
161 EXPECTED_WEBKIT_URL_BASELINE)
162
163 # TODO(gwilson): implement support for using local log files instead of
164 # scraping the buildbots.
165 def testUseLocalOutput():
166 return True
167
168 def testZipDownload():
169 test = _getBasicFailureFinder()
170 try:
171 test._DownloadFile(TEST_ZIP_FILE, "test.zip", "b") # "b" -> binary
172 os.remove("test.zip")
173 return True
174 except:
175 return False
176
177 def testTranslateBuildToZip():
178 test = _getBasicFailureFinder()
179 test.build = WEBKIT_BUILDER_NUMBER
180 revision, build_name = test._GetRevisionAndBuildFromArchiveStep()
181 if revision != EXPECTED_REVISION or build_name != EXPECTED_BUILD_NAME:
182 return False
183 return True
184
185 def testFull():
186 """ Verifies that the entire system works end-to-end. """
187 test = _getBasicFailureFinder()
188 test.build = WEBKIT_BUILDER_NUMBER
189 test.dont_download = True # Dry run only, no downloading needed.
190 failures = test.GetFailures()
191 # Verify that the max failures parameter works.
192 if not failures or len(failures) > 10:
193 "Got no failures or too many failures."
194 return False
195
196 # Verify the failures match the list of expected failures.
197 for failure in failures:
198 if not (failure.test_path in WEBKIT_FAILURES):
199 print "Found a failure I did not expect to see."
200 return False
201
202 return True
203
204 if __name__ == "__main__":
205 fft = FailureFinderTest()
206 result = fft.runTests()
207 if result:
208 print "All tests passed."
209 else:
210 print "Not all tests passed."
OLDNEW
« no previous file with comments | « webkit/tools/layout_tests/layout_package/failure_finder.py ('k') | webkit/tools/layout_tests/test_output_formatter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698