1f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# Copyright (C) 2010 Google Inc. All rights reserved. 2f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# 3f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# Redistribution and use in source and binary forms, with or without 4f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# modification, are permitted provided that the following conditions are 5f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# met: 6f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# 7f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# * Redistributions of source code must retain the above copyright 8f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# notice, this list of conditions and the following disclaimer. 9f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# * Redistributions in binary form must reproduce the above 10f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# copyright notice, this list of conditions and the following disclaimer 11f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# in the documentation and/or other materials provided with the 12f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# distribution. 13f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# * Neither the name of Google Inc. nor the names of its 14f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# contributors may be used to endorse or promote products derived from 15f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# this software without specific prior written permission. 16f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# 17f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 29f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochimport unittest 30f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 31f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochfrom webkitpy.common.system import filesystem_mock 32f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochfrom webkitpy.layout_tests.port import base 33f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochfrom webkitpy.layout_tests.port.webkit import WebKitPort 34f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochfrom webkitpy.tool.commands import rebaselineserver 35f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochfrom webkitpy.tool.mocktool import MockSCM 36f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 37f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 38f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochclass RebaselineTestTest(unittest.TestCase): 39f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_rebaseline_update(self): 40f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 41f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 42f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 43f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/text-expected.txt', 44f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 45f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 46f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-actual.txt', 47f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 48f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 49f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 50f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='none', 51f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=True, 52f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 53f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/text...', 54f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updating baselines for mac', 55f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated text-expected.txt', 56f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 57f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 58f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_rebaseline_new(self): 59f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 60f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 61f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 62f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 63f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 64f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-actual.txt', 65f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 66f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 67f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 68f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='none', 69f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=True, 70f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 71f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/text...', 72f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updating baselines for mac', 73f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated text-expected.txt', 74f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 75f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 76f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_rebaseline_move_no_op_1(self): 77f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 78f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 79f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 80f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/win/fast/text-expected.txt', 81f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 82f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 83f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-actual.txt', 84f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 85f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 86f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 87f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='mac-leopard', 88f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=True, 89f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 90f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/text...', 91f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updating baselines for mac', 92f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated text-expected.txt', 93f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 94f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 95f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_rebaseline_move_no_op_2(self): 96f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 97f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 98f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 99f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/text-expected.checksum', 100f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 101f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 102f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-actual.txt', 103f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 104f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 105f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 106f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='mac-leopard', 107f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=True, 108f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 109f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/text...', 110f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Moving current mac baselines to mac-leopard', 111f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' No current baselines to move', 112f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updating baselines for mac', 113f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated text-expected.txt', 114f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 115f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 116f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_rebaseline_move(self): 117f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 118f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 119f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 120f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/text-expected.txt', 121f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 122f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 123f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-actual.txt', 124f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 125f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 126f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 127f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='mac-leopard', 128f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=True, 129f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 130f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/text...', 131f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Moving current mac baselines to mac-leopard', 132f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Moved text-expected.txt', 133f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updating baselines for mac', 134f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated text-expected.txt', 135f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 136f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 137f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_rebaseline_move_only_images(self): 138f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 139f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 140f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/image-expected.txt', 141f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/image-expected.txt', 142f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/image-expected.png', 143f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/image-expected.checksum', 144f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 145f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 146f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/image-actual.png', 147f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/image-actual.checksum', 148f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 149f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/image.html', 150f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 151f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='mac-leopard', 152f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=True, 153f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 154f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/image...', 155f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Moving current mac baselines to mac-leopard', 156f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Moved image-expected.checksum', 157f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Moved image-expected.png', 158f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updating baselines for mac', 159f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated image-expected.checksum', 160f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated image-expected.png', 161f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 162f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 163f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_rebaseline_move_already_exist(self): 164f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 165f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 166f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 167f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac-leopard/fast/text-expected.txt', 168f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/text-expected.txt', 169f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 170f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 171f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-actual.txt', 172f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 173f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 174f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 175f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='mac-leopard', 176f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=False, 177f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 178f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/text...', 179f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Moving current mac baselines to mac-leopard', 180f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Already had baselines in mac-leopard, could not move existing mac ones', 181f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 182f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 183f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_image_rebaseline(self): 184f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertRebaseline( 185f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 186f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/image-expected.txt', 187f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/image-expected.png', 188f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/image-expected.checksum', 189f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 190f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_files=( 191f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/image-actual.png', 192f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/image-actual.checksum', 193f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 194f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/image.html', 195f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target='mac', 196f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to='none', 197f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_success=True, 198f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_log=[ 199f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'Rebaselining fast/image...', 200f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updating baselines for mac', 201f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated image-expected.checksum', 202f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ' Updated image-expected.png', 203f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ]) 204f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 205f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def _assertRebaseline(self, test_files, results_files, test_name, baseline_target, baseline_move_to, expected_success, expected_log): 206f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch log = [] 207f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_config = get_test_config(test_files, results_files) 208f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch success = rebaselineserver._rebaseline_test( 209f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name, 210f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_target, 211f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch baseline_move_to, 212f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_config, 213f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch log=lambda l: log.append(l)) 214f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self.assertEqual(expected_log, log) 215f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self.assertEqual(expected_success, success) 216f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 217f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 218f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochclass GetActualResultFilesTest(unittest.TestCase): 219f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test(self): 220f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_config = get_test_config(result_files=( 221f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-actual.txt', 222f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast2/text-actual.txt', 223f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text2-actual.txt', 224f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-notactual.txt', 225f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch )) 226f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self.assertEqual( 227f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ('text-actual.txt',), 228f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch rebaselineserver._get_actual_result_files( 229f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text.html', test_config)) 230f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 231f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 232f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochclass GetBaselinesTest(unittest.TestCase): 233f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_no_baselines(self): 234f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertBaselines( 235f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=(), 236f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/missing.html', 237f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_baselines={}) 238f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 239f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_text_baselines(self): 240f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertBaselines( 241f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 242f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 243f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/text-expected.txt', 244f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 245f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 246f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_baselines={ 247f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'mac': {'.txt': True}, 248f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'base': {'.txt': False}, 249f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch }) 250f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 251f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_image_and_text_baselines(self): 252f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertBaselines( 253f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 254f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/image-expected.txt', 255f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/image-expected.png', 256f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/mac/fast/image-expected.checksum', 257f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/win/fast/image-expected.png', 258f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/win/fast/image-expected.checksum', 259f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 260f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/image.html', 261f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_baselines={ 262f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'base': {'.txt': True}, 263f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'mac': {'.checksum': True, '.png': True}, 264f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'win': {'.checksum': False, '.png': False}, 265f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch }) 266f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 267f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def test_extra_baselines(self): 268f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._assertBaselines( 269f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_files=( 270f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'fast/text-expected.txt', 271f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 'platform/nosuchplatform/fast/text-expected.txt', 272f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ), 273f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name='fast/text.html', 274f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch expected_baselines={'base': {'.txt': True}}) 275f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 276f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def _assertBaselines(self, test_files, test_name, expected_baselines): 277f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch actual_baselines = rebaselineserver._get_test_baselines( 278f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch test_name, get_test_config(test_files)) 279f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self.assertEqual(expected_baselines, actual_baselines) 280f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 281f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 282f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochdef get_test_config(test_files=[], result_files=[]): 283f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch layout_tests_directory = base.Port().layout_tests_dir() 284f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_directory = '/WebKitBuild/Debug/layout-test-results' 285f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch mock_filesystem = filesystem_mock.MockFileSystem() 286f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch for file in test_files: 287f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch file_path = mock_filesystem.join(layout_tests_directory, file) 288f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch mock_filesystem.files[file_path] = '' 289f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch for file in result_files: 290f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch file_path = mock_filesystem.join(results_directory, file) 291f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch mock_filesystem.files[file_path] = '' 292f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 293f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch class TestMacPort(WebKitPort): 294f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch def __init__(self): 295f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch WebKitPort.__init__(self, filesystem=mock_filesystem) 296f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch self._name = 'mac' 297f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 298f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return rebaselineserver.TestConfig( 299f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch TestMacPort(), 300f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch layout_tests_directory, 301f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch results_directory, 302f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ('mac', 'mac-leopard', 'win', 'linux'), 303f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch mock_filesystem, 304f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch MockSCM()) 305