OLD | NEW |
1 # Copyright (C) 2009 Google Inc. All rights reserved. | 1 # Copyright (C) 2009 Google Inc. All rights reserved. |
2 # Copyright (C) 2012 Intel Corporation. All rights reserved. | 2 # Copyright (C) 2012 Intel Corporation. All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 import unittest | 30 import unittest |
31 | 31 |
32 from webkitpy.common.system.outputcapture import OutputCapture | 32 from webkitpy.common.system.outputcapture import OutputCapture |
33 from webkitpy.layout_tests.port.test import TestPort | 33 from webkitpy.layout_tests.port.test import TestPort |
34 from webkitpy.tool.commands.queries import * | 34 from webkitpy.tool.commands.queries import * |
35 from webkitpy.tool.mocktool import MockTool, MockOptions | 35 from webkitpy.tool.mocktool import MockTool, MockOptions |
36 | 36 |
37 | 37 |
38 class PrintExpectationsTest(unittest.TestCase): | 38 class PrintExpectationsTest(unittest.TestCase): |
| 39 |
39 def run_test(self, tests, expected_stdout, platform='test-win-win7', **args)
: | 40 def run_test(self, tests, expected_stdout, platform='test-win-win7', **args)
: |
40 options = MockOptions(all=False, csv=False, full=False, platform=platfor
m, | 41 options = MockOptions(all=False, csv=False, full=False, platform=platfor
m, |
41 include_keyword=[], exclude_keyword=[], paths=Fals
e).update(**args) | 42 include_keyword=[], exclude_keyword=[], paths=Fals
e).update(**args) |
42 tool = MockTool() | 43 tool = MockTool() |
43 tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VARIANT
S | 44 tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VARIANT
S |
44 command = PrintExpectations() | 45 command = PrintExpectations() |
45 command.bind_to_tool(tool) | 46 command.bind_to_tool(tool) |
46 | 47 |
47 oc = OutputCapture() | 48 oc = OutputCapture() |
48 try: | 49 try: |
(...skipping 11 matching lines...) Expand all Loading... |
60 | 61 |
61 def test_multiple(self): | 62 def test_multiple(self): |
62 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], | 63 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], |
63 ('// For test-win-win10\n' | 64 ('// For test-win-win10\n' |
64 'failures/expected/text.html [ Failure ]\n' | 65 'failures/expected/text.html [ Failure ]\n' |
65 'failures/expected/timeout.html [ Timeout ]\n' | 66 'failures/expected/timeout.html [ Timeout ]\n' |
66 '\n' | 67 '\n' |
67 '// For test-win-win7\n' | 68 '// For test-win-win7\n' |
68 'failures/expected/text.html [ Failure ]\n' | 69 'failures/expected/text.html [ Failure ]\n' |
69 'failures/expected/timeout.html [ Timeout ]\n'), | 70 'failures/expected/timeout.html [ Timeout ]\n'), |
70 platform='test-win-*') | 71 platform='test-win-*') |
71 | 72 |
72 def test_full(self): | 73 def test_full(self): |
73 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], | 74 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], |
74 ('// For test-win-win7\n' | 75 ('// For test-win-win7\n' |
75 'Bug(test) failures/expected/text.html [ Failure ]\n' | 76 'Bug(test) failures/expected/text.html [ Failure ]\n' |
76 'Bug(test) failures/expected/timeout.html [ Timeout ]\n')
, | 77 'Bug(test) failures/expected/timeout.html [ Timeout ]\n')
, |
77 full=True) | 78 full=True) |
78 | 79 |
79 def test_exclude(self): | 80 def test_exclude(self): |
80 self.run_test(['failures/expected/text.html', 'failures/expected/crash.h
tml'], | 81 self.run_test(['failures/expected/text.html', 'failures/expected/crash.h
tml'], |
(...skipping 13 matching lines...) Expand all Loading... |
94 'test-win-win7,failures/expected/text.html,Bug(test),,FAI
L\n'), | 95 'test-win-win7,failures/expected/text.html,Bug(test),,FAI
L\n'), |
95 csv=True) | 96 csv=True) |
96 | 97 |
97 def test_paths(self): | 98 def test_paths(self): |
98 self.run_test([], | 99 self.run_test([], |
99 ('/mock-checkout/LayoutTests/TestExpectations\n' | 100 ('/mock-checkout/LayoutTests/TestExpectations\n' |
100 'LayoutTests/platform/test/TestExpectations\n' | 101 'LayoutTests/platform/test/TestExpectations\n' |
101 'LayoutTests/platform/test-win-win7/TestExpectations\n'), | 102 'LayoutTests/platform/test-win-win7/TestExpectations\n'), |
102 paths=True) | 103 paths=True) |
103 | 104 |
| 105 |
104 class PrintBaselinesTest(unittest.TestCase): | 106 class PrintBaselinesTest(unittest.TestCase): |
| 107 |
105 def setUp(self): | 108 def setUp(self): |
106 self.oc = None | 109 self.oc = None |
107 self.tool = MockTool() | 110 self.tool = MockTool() |
108 self.test_port = self.tool.port_factory.get('test-win-win7') | 111 self.test_port = self.tool.port_factory.get('test-win-win7') |
109 self.tool.port_factory.get = lambda port_name=None: self.test_port | 112 self.tool.port_factory.get = lambda port_name=None: self.test_port |
110 self.tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VA
RIANTS | 113 self.tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VA
RIANTS |
111 | 114 |
112 def tearDown(self): | 115 def tearDown(self): |
113 if self.oc: | 116 if self.oc: |
114 self.restore_output() | 117 self.restore_output() |
115 | 118 |
116 def capture_output(self): | 119 def capture_output(self): |
117 self.oc = OutputCapture() | 120 self.oc = OutputCapture() |
118 self.oc.capture_output() | 121 self.oc.capture_output() |
119 | 122 |
120 def restore_output(self): | 123 def restore_output(self): |
121 stdout, stderr, logs = self.oc.restore_output() | 124 stdout, stderr, logs = self.oc.restore_output() |
122 self.oc = None | 125 self.oc = None |
123 return (stdout, stderr, logs) | 126 return (stdout, stderr, logs) |
124 | 127 |
125 def test_basic(self): | 128 def test_basic(self): |
126 command = PrintBaselines() | 129 command = PrintBaselines() |
127 command.bind_to_tool(self.tool) | 130 command.bind_to_tool(self.tool) |
128 self.capture_output() | 131 self.capture_output() |
129 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, platform=None), ['passes/text.html'], self.tool) | 132 command.execute(MockOptions(all=False, include_virtual_tests=False, |
| 133 csv=False, platform=None), ['passes/text.htm
l'], self.tool) |
130 stdout, _, _ = self.restore_output() | 134 stdout, _, _ = self.restore_output() |
131 self.assertMultiLineEqual(stdout, | 135 self.assertMultiLineEqual(stdout, |
132 ('// For test-win-win7\n' | 136 ('// For test-win-win7\n' |
133 'passes/text-expected.png\n' | 137 'passes/text-expected.png\n' |
134 'passes/text-expected.txt\n')) | 138 'passes/text-expected.txt\n')) |
135 | 139 |
136 def test_multiple(self): | 140 def test_multiple(self): |
137 command = PrintBaselines() | 141 command = PrintBaselines() |
138 command.bind_to_tool(self.tool) | 142 command.bind_to_tool(self.tool) |
139 self.capture_output() | 143 self.capture_output() |
140 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, platform='test-win-*'), ['passes/text.html'], self.tool) | 144 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, |
| 145 platform='test-win-*'), ['passes/text.html']
, self.tool) |
141 stdout, _, _ = self.restore_output() | 146 stdout, _, _ = self.restore_output() |
142 self.assertMultiLineEqual(stdout, | 147 self.assertMultiLineEqual(stdout, |
143 ('// For test-win-win10\n' | 148 ('// For test-win-win10\n' |
144 'passes/text-expected.png\n' | 149 'passes/text-expected.png\n' |
145 'passes/text-expected.txt\n' | 150 'passes/text-expected.txt\n' |
146 '\n' | 151 '\n' |
147 '// For test-win-win7\n' | 152 '// For test-win-win7\n' |
148 'passes/text-expected.png\n' | 153 'passes/text-expected.png\n' |
149 'passes/text-expected.txt\n')) | 154 'passes/text-expected.txt\n')) |
150 | 155 |
151 def test_csv(self): | 156 def test_csv(self): |
152 command = PrintBaselines() | 157 command = PrintBaselines() |
153 command.bind_to_tool(self.tool) | 158 command.bind_to_tool(self.tool) |
154 self.capture_output() | 159 self.capture_output() |
155 command.execute(MockOptions(all=False, platform='*win7', csv=True, inclu
de_virtual_tests=False), ['passes/text.html'], self.tool) | 160 command.execute(MockOptions(all=False, platform='*win7', csv=True, |
| 161 include_virtual_tests=False), ['passes/text.
html'], self.tool) |
156 stdout, _, _ = self.restore_output() | 162 stdout, _, _ = self.restore_output() |
157 self.assertMultiLineEqual(stdout, | 163 self.assertMultiLineEqual(stdout, |
158 ('test-win-win7,passes/text.html,None,png,passes/text-
expected.png,None\n' | 164 ('test-win-win7,passes/text.html,None,png,pass
es/text-expected.png,None\n' |
159 'test-win-win7,passes/text.html,None,txt,passes/text-
expected.txt,None\n')) | 165 'test-win-win7,passes/text.html,None,txt,pass
es/text-expected.txt,None\n')) |
OLD | NEW |