| OLD | NEW |
| (Empty) |
| 1 # Copyright (C) 2009 Google Inc. All rights reserved. | |
| 2 # Copyright (C) 2012 Intel Corporation. All rights reserved. | |
| 3 # | |
| 4 # Redistribution and use in source and binary forms, with or without | |
| 5 # modification, are permitted provided that the following conditions are | |
| 6 # met: | |
| 7 # | |
| 8 # * Redistributions of source code must retain the above copyright | |
| 9 # notice, this list of conditions and the following disclaimer. | |
| 10 # * Redistributions in binary form must reproduce the above | |
| 11 # copyright notice, this list of conditions and the following disclaimer | |
| 12 # in the documentation and/or other materials provided with the | |
| 13 # distribution. | |
| 14 # * Neither the name of Google Inc. nor the names of its | |
| 15 # contributors may be used to endorse or promote products derived from | |
| 16 # this software without specific prior written permission. | |
| 17 # | |
| 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | |
| 30 import unittest | |
| 31 | |
| 32 from webkitpy.common.system.outputcapture import OutputCapture | |
| 33 from webkitpy.layout_tests.port.test import TestPort | |
| 34 from webkitpy.tool.commands.queries import * | |
| 35 from webkitpy.tool.mocktool import MockTool, MockOptions | |
| 36 | |
| 37 | |
| 38 class PrintExpectationsTest(unittest.TestCase): | |
| 39 def run_test(self, tests, expected_stdout, platform='test-win-xp', **args): | |
| 40 options = MockOptions(all=False, csv=False, full=False, platform=platfor
m, | |
| 41 include_keyword=[], exclude_keyword=[], paths=Fals
e).update(**args) | |
| 42 tool = MockTool() | |
| 43 tool.port_factory.all_port_names = lambda: TestPort.ALL_BASELINE_VARIANT
S | |
| 44 command = PrintExpectations() | |
| 45 command.bind_to_tool(tool) | |
| 46 | |
| 47 oc = OutputCapture() | |
| 48 try: | |
| 49 oc.capture_output() | |
| 50 command.execute(options, tests, tool) | |
| 51 finally: | |
| 52 stdout, _, _ = oc.restore_output() | |
| 53 self.assertMultiLineEqual(stdout, expected_stdout) | |
| 54 | |
| 55 def test_basic(self): | |
| 56 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], | |
| 57 ('// For test-win-xp\n' | |
| 58 'failures/expected/image.html [ ImageOnlyFailure ]\n' | |
| 59 'failures/expected/text.html [ Failure ]\n')) | |
| 60 | |
| 61 def test_multiple(self): | |
| 62 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], | |
| 63 ('// For test-win-win7\n' | |
| 64 'failures/expected/image.html [ ImageOnlyFailure ]\n' | |
| 65 'failures/expected/text.html [ Failure ]\n' | |
| 66 '\n' | |
| 67 '// For test-win-xp\n' | |
| 68 'failures/expected/image.html [ ImageOnlyFailure ]\n' | |
| 69 'failures/expected/text.html [ Failure ]\n'), | |
| 70 platform='test-win-*') | |
| 71 | |
| 72 def test_full(self): | |
| 73 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], | |
| 74 ('// For test-win-xp\n' | |
| 75 'Bug(test) failures/expected/image.html [ ImageOnlyFailur
e ]\n' | |
| 76 'Bug(test) failures/expected/text.html [ Failure ]\n'), | |
| 77 full=True) | |
| 78 | |
| 79 def test_exclude(self): | |
| 80 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], | |
| 81 ('// For test-win-xp\n' | |
| 82 'failures/expected/text.html [ Failure ]\n'), | |
| 83 exclude_keyword=['image']) | |
| 84 | |
| 85 def test_include(self): | |
| 86 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], | |
| 87 ('// For test-win-xp\n' | |
| 88 'failures/expected/image.html\n'), | |
| 89 include_keyword=['image']) | |
| 90 | |
| 91 def test_csv(self): | |
| 92 self.run_test(['failures/expected/text.html', 'failures/expected/image.h
tml'], | |
| 93 ('test-win-xp,failures/expected/image.html,Bug(test),,IMAG
E\n' | |
| 94 'test-win-xp,failures/expected/text.html,Bug(test),,FAIL\
n'), | |
| 95 csv=True) | |
| 96 | |
| 97 def test_paths(self): | |
| 98 self.run_test([], | |
| 99 ('/mock-checkout/tests/TestExpectations\n' | |
| 100 'tests/platform/test/TestExpectations\n' | |
| 101 'tests/platform/test-win-xp/TestExpectations\n'), | |
| 102 paths=True) | |
| 103 | |
| 104 class PrintBaselinesTest(unittest.TestCase): | |
| 105 def setUp(self): | |
| 106 self.oc = None | |
| 107 self.tool = MockTool() | |
| 108 self.test_port = self.tool.port_factory.get('test-win-xp') | |
| 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 | |
| 111 | |
| 112 def tearDown(self): | |
| 113 if self.oc: | |
| 114 self.restore_output() | |
| 115 | |
| 116 def capture_output(self): | |
| 117 self.oc = OutputCapture() | |
| 118 self.oc.capture_output() | |
| 119 | |
| 120 def restore_output(self): | |
| 121 stdout, stderr, logs = self.oc.restore_output() | |
| 122 self.oc = None | |
| 123 return (stdout, stderr, logs) | |
| 124 | |
| 125 def test_basic(self): | |
| 126 command = PrintBaselines() | |
| 127 command.bind_to_tool(self.tool) | |
| 128 self.capture_output() | |
| 129 command.execute(MockOptions(all=False, include_virtual_tests=False, csv=
False, platform=None), ['passes/text.html'], self.tool) | |
| 130 stdout, _, _ = self.restore_output() | |
| 131 self.assertMultiLineEqual(stdout, | |
| 132 ('// For test-win-xp\n' | |
| 133 'passes/text-expected.png\n' | |
| 134 'passes/text-expected.txt\n')) | |
| 135 | |
| 136 def test_multiple(self): | |
| 137 command = PrintBaselines() | |
| 138 command.bind_to_tool(self.tool) | |
| 139 self.capture_output() | |
| 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() | |
| 142 self.assertMultiLineEqual(stdout, | |
| 143 ('// For test-win-win7\n' | |
| 144 'passes/text-expected.png\n' | |
| 145 'passes/text-expected.txt\n' | |
| 146 '\n' | |
| 147 '// For test-win-xp\n' | |
| 148 'passes/text-expected.png\n' | |
| 149 'passes/text-expected.txt\n')) | |
| 150 | |
| 151 def test_csv(self): | |
| 152 command = PrintBaselines() | |
| 153 command.bind_to_tool(self.tool) | |
| 154 self.capture_output() | |
| 155 command.execute(MockOptions(all=False, platform='*xp', csv=True, include
_virtual_tests=False), ['passes/text.html'], self.tool) | |
| 156 stdout, _, _ = self.restore_output() | |
| 157 self.assertMultiLineEqual(stdout, | |
| 158 ('test-win-xp,passes/text.html,None,png,passes/text-ex
pected.png,None\n' | |
| 159 'test-win-xp,passes/text.html,None,txt,passes/text-ex
pected.txt,None\n')) | |
| OLD | NEW |