OLD | NEW |
| (Empty) |
1 # Copyright (c) 2010, Google Inc. All rights reserved. | |
2 # | |
3 # Redistribution and use in source and binary forms, with or without | |
4 # modification, are permitted provided that the following conditions are | |
5 # met: | |
6 # | |
7 # * Redistributions of source code must retain the above copyright | |
8 # notice, this list of conditions and the following disclaimer. | |
9 # * Redistributions in binary form must reproduce the above | |
10 # copyright notice, this list of conditions and the following disclaimer | |
11 # in the documentation and/or other materials provided with the | |
12 # distribution. | |
13 # * Neither the name of Google Inc. nor the names of its | |
14 # contributors may be used to endorse or promote products derived from | |
15 # this software without specific prior written permission. | |
16 # | |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | |
29 import unittest | |
30 | |
31 from webkitpy.common.net.layouttestresults import LayoutTestResults | |
32 | |
33 | |
34 class LayoutTestResultsTest(unittest.TestCase): | |
35 # The real files have no whitespace, but newlines make this much more readab
le. | |
36 example_full_results_json = """ADD_RESULTS({ | |
37 "tests": { | |
38 "fast": { | |
39 "dom": { | |
40 "prototype-inheritance.html": { | |
41 "expected": "PASS", | |
42 "actual": "TEXT", | |
43 "is_unexpected": true | |
44 }, | |
45 "prototype-banana.html": { | |
46 "expected": "FAIL", | |
47 "actual": "PASS", | |
48 "is_unexpected": true | |
49 }, | |
50 "prototype-taco.html": { | |
51 "expected": "PASS", | |
52 "actual": "PASS TEXT", | |
53 "is_unexpected": true | |
54 }, | |
55 "prototype-chocolate.html": { | |
56 "expected": "FAIL", | |
57 "actual": "IMAGE+TEXT" | |
58 }, | |
59 "prototype-strawberry.html": { | |
60 "expected": "PASS", | |
61 "actual": "IMAGE PASS", | |
62 "is_unexpected": true | |
63 }, | |
64 "prototype-crashy.html": { | |
65 "expected": "PASS", | |
66 "actual": "CRASH", | |
67 "is_unexpected": true | |
68 }, | |
69 "prototype-newtest.html": { | |
70 "expected": "PASS", | |
71 "actual": "MISSING", | |
72 "is_unexpected": true, | |
73 "is_missing_text": true | |
74 } | |
75 } | |
76 }, | |
77 "svg": { | |
78 "dynamic-updates": { | |
79 "SVGFEDropShadowElement-dom-stdDeviation-attr.html": { | |
80 "expected": "PASS", | |
81 "actual": "IMAGE", | |
82 "has_stderr": true, | |
83 "is_unexpected": true | |
84 } | |
85 } | |
86 } | |
87 }, | |
88 "skipped": 450, | |
89 "num_regressions": 15, | |
90 "layout_tests_dir": "/b/build/slave/Webkit_Mac10_5/build/src/third_party/Web
Kit/LayoutTests", | |
91 "version": 3, | |
92 "num_passes": 77, | |
93 "has_pretty_patch": false, | |
94 "fixable": 1220, | |
95 "num_flaky": 0, | |
96 "chromium_revision": "1234", | |
97 "has_wdiff": false, | |
98 "builder_name": "mock_builder_name" | |
99 });""" | |
100 | |
101 def test_results_from_string(self): | |
102 self.assertIsNone(LayoutTestResults.results_from_string(None)) | |
103 self.assertIsNone(LayoutTestResults.results_from_string("")) | |
104 | |
105 def test_was_interrupted(self): | |
106 self.assertTrue(LayoutTestResults.results_from_string( | |
107 'ADD_RESULTS({"tests":{},"interrupted":true});').run_was_interrupted
()) | |
108 self.assertFalse(LayoutTestResults.results_from_string( | |
109 'ADD_RESULTS({"tests":{},"interrupted":false});').run_was_interrupte
d()) | |
110 | |
111 def test_chromium_revision(self): | |
112 self.assertEqual(LayoutTestResults.results_from_string(self.example_full
_results_json).chromium_revision(), 1234) | |
113 | |
114 def test_actual_results(self): | |
115 results = LayoutTestResults.results_from_string(self.example_full_result
s_json) | |
116 self.assertEqual(results.result_for_test("fast/dom/prototype-banana.html
").actual_results(), "PASS") | |
117 self.assertEqual(results.result_for_test("fast/dom/prototype-taco.html")
.actual_results(), "PASS TEXT") | |
118 self.assertFalse(results.result_for_test("nonexistant.html")) | |
119 | |
120 def test_didnt_run_as_expected_results(self): | |
121 results = LayoutTestResults.results_from_string(self.example_full_result
s_json) | |
122 self.assertEqual( | |
123 [r.test_name() for r in results.didnt_run_as_expected_results()], | |
124 [ | |
125 'fast/dom/prototype-banana.html', | |
126 'fast/dom/prototype-crashy.html', | |
127 'fast/dom/prototype-inheritance.html', | |
128 'fast/dom/prototype-newtest.html', | |
129 'fast/dom/prototype-strawberry.html', | |
130 'fast/dom/prototype-taco.html', | |
131 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-att
r.html', | |
132 ]) | |
OLD | NEW |