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 def run_test(self, tests, expected_stdout, platform='test-win-xp', **args): | 39 def run_test(self, tests, expected_stdout, platform='test-win-win7', **args)
: |
40 options = MockOptions(all=False, csv=False, full=False, platform=platfor
m, | 40 options = MockOptions(all=False, csv=False, full=False, platform=platfor
m, |
41 include_keyword=[], exclude_keyword=[], paths=Fals
e).update(**args) | 41 include_keyword=[], exclude_keyword=[], paths=Fals
e).update(**args) |
42 tool = MockTool() | 42 tool = MockTool() |
43 tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VARIANT
S | 43 tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VARIANT
S |
44 command = PrintExpectations() | 44 command = PrintExpectations() |
45 command.bind_to_tool(tool) | 45 command.bind_to_tool(tool) |
46 | 46 |
47 oc = OutputCapture() | 47 oc = OutputCapture() |
48 try: | 48 try: |
49 oc.capture_output() | 49 oc.capture_output() |
50 command.execute(options, tests, tool) | 50 command.execute(options, tests, tool) |
51 finally: | 51 finally: |
52 stdout, _, _ = oc.restore_output() | 52 stdout, _, _ = oc.restore_output() |
53 self.assertMultiLineEqual(stdout, expected_stdout) | 53 self.assertMultiLineEqual(stdout, expected_stdout) |
54 | 54 |
55 def test_basic(self): | 55 def test_basic(self): |
56 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], | 56 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], |
57 ('// For test-win-xp\n' | 57 ('// For test-win-win7\n' |
58 'failures/expected/text.html [ Failure ]\n' | 58 'failures/expected/text.html [ Failure ]\n' |
59 'failures/expected/timeout.html [ Timeout ]\n')) | 59 'failures/expected/timeout.html [ Timeout ]\n')) |
60 | 60 |
61 def test_multiple(self): | 61 def test_multiple(self): |
62 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], | 62 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], |
63 ('// For test-win-win7\n' | 63 ('// For test-win-win10\n' |
64 'failures/expected/text.html [ Failure ]\n' | 64 'failures/expected/text.html [ Failure ]\n' |
65 'failures/expected/timeout.html [ Timeout ]\n' | 65 'failures/expected/timeout.html [ Timeout ]\n' |
66 '\n' | 66 '\n' |
67 '// For test-win-xp\n' | 67 '// For test-win-win7\n' |
68 'failures/expected/text.html [ Failure ]\n' | 68 'failures/expected/text.html [ Failure ]\n' |
69 'failures/expected/timeout.html [ Timeout ]\n'), | 69 'failures/expected/timeout.html [ Timeout ]\n'), |
70 platform='test-win-*') | 70 platform='test-win-*') |
71 | 71 |
72 def test_full(self): | 72 def test_full(self): |
73 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], | 73 self.run_test(['failures/expected/text.html', 'failures/expected/timeout
.html'], |
74 ('// For test-win-xp\n' | 74 ('// For test-win-win7\n' |
75 'Bug(test) failures/expected/text.html [ Failure ]\n' | 75 'Bug(test) failures/expected/text.html [ Failure ]\n' |
76 'Bug(test) failures/expected/timeout.html [ Timeout ]\n')
, | 76 'Bug(test) failures/expected/timeout.html [ Timeout ]\n')
, |
77 full=True) | 77 full=True) |
78 | 78 |
79 def test_exclude(self): | 79 def test_exclude(self): |
80 self.run_test(['failures/expected/text.html', 'failures/expected/crash.h
tml'], | 80 self.run_test(['failures/expected/text.html', 'failures/expected/crash.h
tml'], |
81 ('// For test-win-xp\n' | 81 ('// For test-win-win7\n' |
82 'failures/expected/text.html [ Failure ]\n'), | 82 'failures/expected/text.html [ Failure ]\n'), |
83 exclude_keyword=['crash']) | 83 exclude_keyword=['crash']) |
84 | 84 |
85 def test_include(self): | 85 def test_include(self): |
86 self.run_test(['failures/expected/text.html', 'failures/expected/crash.h
tml'], | 86 self.run_test(['failures/expected/text.html', 'failures/expected/crash.h
tml'], |
87 ('// For test-win-xp\n' | 87 ('// For test-win-win7\n' |
88 'failures/expected/crash.html\n'), | 88 'failures/expected/crash.html\n'), |
89 include_keyword=['crash']) | 89 include_keyword=['crash']) |
90 | 90 |
91 def test_csv(self): | 91 def test_csv(self): |
92 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], | 92 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], |
93 ('test-win-xp,failures/expected/image.html,Bug(test),,FAIL
\n' | 93 ('test-win-win7,failures/expected/image.html,Bug(test),,FA
IL\n' |
94 'test-win-xp,failures/expected/text.html,Bug(test),,FAIL\
n'), | 94 'test-win-win7,failures/expected/text.html,Bug(test),,FAI
L\n'), |
95 csv=True) | 95 csv=True) |
96 | 96 |
97 def test_paths(self): | 97 def test_paths(self): |
98 self.run_test([], | 98 self.run_test([], |
99 ('/mock-checkout/LayoutTests/TestExpectations\n' | 99 ('/mock-checkout/LayoutTests/TestExpectations\n' |
100 'LayoutTests/platform/test/TestExpectations\n' | 100 'LayoutTests/platform/test/TestExpectations\n' |
101 'LayoutTests/platform/test-win-xp/TestExpectations\n'), | 101 'LayoutTests/platform/test-win-win7/TestExpectations\n'), |
102 paths=True) | 102 paths=True) |
103 | 103 |
104 class PrintBaselinesTest(unittest.TestCase): | 104 class PrintBaselinesTest(unittest.TestCase): |
105 def setUp(self): | 105 def setUp(self): |
106 self.oc = None | 106 self.oc = None |
107 self.tool = MockTool() | 107 self.tool = MockTool() |
108 self.test_port = self.tool.port_factory.get('test-win-xp') | 108 self.test_port = self.tool.port_factory.get('test-win-win7') |
109 self.tool.port_factory.get = lambda port_name=None: self.test_port | 109 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 | 110 self.tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VA
RIANTS |
111 | 111 |
112 def tearDown(self): | 112 def tearDown(self): |
113 if self.oc: | 113 if self.oc: |
114 self.restore_output() | 114 self.restore_output() |
115 | 115 |
116 def capture_output(self): | 116 def capture_output(self): |
117 self.oc = OutputCapture() | 117 self.oc = OutputCapture() |
118 self.oc.capture_output() | 118 self.oc.capture_output() |
119 | 119 |
120 def restore_output(self): | 120 def restore_output(self): |
121 stdout, stderr, logs = self.oc.restore_output() | 121 stdout, stderr, logs = self.oc.restore_output() |
122 self.oc = None | 122 self.oc = None |
123 return (stdout, stderr, logs) | 123 return (stdout, stderr, logs) |
124 | 124 |
125 def test_basic(self): | 125 def test_basic(self): |
126 command = PrintBaselines() | 126 command = PrintBaselines() |
127 command.bind_to_tool(self.tool) | 127 command.bind_to_tool(self.tool) |
128 self.capture_output() | 128 self.capture_output() |
129 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, platform=None), ['passes/text.html'], self.tool) | 129 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, platform=None), ['passes/text.html'], self.tool) |
130 stdout, _, _ = self.restore_output() | 130 stdout, _, _ = self.restore_output() |
131 self.assertMultiLineEqual(stdout, | 131 self.assertMultiLineEqual(stdout, |
132 ('// For test-win-xp\n' | 132 ('// For test-win-win7\n' |
133 'passes/text-expected.png\n' | 133 'passes/text-expected.png\n' |
134 'passes/text-expected.txt\n')) | 134 'passes/text-expected.txt\n')) |
135 | 135 |
136 def test_multiple(self): | 136 def test_multiple(self): |
137 command = PrintBaselines() | 137 command = PrintBaselines() |
138 command.bind_to_tool(self.tool) | 138 command.bind_to_tool(self.tool) |
139 self.capture_output() | 139 self.capture_output() |
140 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, platform='test-win-*'), ['passes/text.html'], self.tool) | 140 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, platform='test-win-*'), ['passes/text.html'], self.tool) |
141 stdout, _, _ = self.restore_output() | 141 stdout, _, _ = self.restore_output() |
142 self.assertMultiLineEqual(stdout, | 142 self.assertMultiLineEqual(stdout, |
143 ('// For test-win-win7\n' | 143 ('// For test-win-win10\n' |
144 'passes/text-expected.png\n' | 144 'passes/text-expected.png\n' |
145 'passes/text-expected.txt\n' | 145 'passes/text-expected.txt\n' |
146 '\n' | 146 '\n' |
147 '// For test-win-xp\n' | 147 '// For test-win-win7\n' |
148 'passes/text-expected.png\n' | 148 'passes/text-expected.png\n' |
149 'passes/text-expected.txt\n')) | 149 'passes/text-expected.txt\n')) |
150 | 150 |
151 def test_csv(self): | 151 def test_csv(self): |
152 command = PrintBaselines() | 152 command = PrintBaselines() |
153 command.bind_to_tool(self.tool) | 153 command.bind_to_tool(self.tool) |
154 self.capture_output() | 154 self.capture_output() |
155 command.execute(MockOptions(all=False, platform='*xp', csv=True, include
_virtual_tests=False), ['passes/text.html'], self.tool) | 155 command.execute(MockOptions(all=False, platform='*win7', csv=True, inclu
de_virtual_tests=False), ['passes/text.html'], self.tool) |
156 stdout, _, _ = self.restore_output() | 156 stdout, _, _ = self.restore_output() |
157 self.assertMultiLineEqual(stdout, | 157 self.assertMultiLineEqual(stdout, |
158 ('test-win-xp,passes/text.html,None,png,passes/text-ex
pected.png,None\n' | 158 ('test-win-win7,passes/text.html,None,png,passes/text-
expected.png,None\n' |
159 'test-win-xp,passes/text.html,None,txt,passes/text-ex
pected.txt,None\n')) | 159 'test-win-win7,passes/text.html,None,txt,passes/text-
expected.txt,None\n')) |
OLD | NEW |