Deleted: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_expectations_editor.py (128384 => 128385)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_expectations_editor.py 2012-09-13 00:04:41 UTC (rev 128384)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_expectations_editor.py 2012-09-13 00:09:32 UTC (rev 128385)
@@ -1,167 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""A helper class for reading in and dealing with tests expectations
-for layout tests.
-"""
-
-import itertools
-import json
-import logging
-import re
-
-from webkitpy.layout_tests.models.test_configuration import TestConfiguration, TestConfigurationConverter
-from webkitpy.layout_tests.models import test_expectations
-
-_log = logging.getLogger(__name__)
-
-
-class BugManager(object):
- """A simple interface for managing bugs from TestExpectationsEditor."""
- def close_bug(self, bug_ids, reference_bug_ids=None):
- raise NotImplementedError("BugManager.close_bug")
-
- def create_bug(self):
- """Should return a newly created bug id in the form of r"BUG[^\d].*"."""
- raise NotImplementedError("BugManager.create_bug")
-
-
-class TestExpectationsEditor(object):
- """
- The editor assumes that the expectation data is error-free.
- """
-
- def __init__(self, expectation_lines, bug_manager):
- self._bug_manager = bug_manager
- self._expectation_lines = expectation_lines
- self._tests_with_directory_paths = set()
- # FIXME: Unify this with TestExpectationsModel.
- self._test_to_expectation_lines = {}
- for expectation_line in expectation_lines:
- for test in expectation_line.matching_tests:
- if test == expectation_line.path:
- self._test_to_expectation_lines.setdefault(test, []).append(expectation_line)
- else:
- self._tests_with_directory_paths.add(test)
-
- def remove_expectation(self, test, test_config_set, remove_flakes=False):
- """Removes existing expectations for {test} in the of test configurations {test_config_set}.
- If the test is flaky, the expectation is not removed, unless remove_flakes is True.
-
- In this context, removing expectations does not imply that the test is passing -- we are merely removing
- any information about this test from the expectations.
-
- We do not remove the actual expectation lines here. Instead, we adjust TestExpectationLine.matching_configurations.
- The serializer will figure out what to do:
- * An empty matching_configurations set means that the this line matches nothing and will serialize as None.
- * A matching_configurations set that can't be expressed as one line will be serialized as multiple lines.
-
- Also, we do only adjust matching_configurations for lines that match tests exactly, because expectation lines with
- better path matches are valid and always win.
-
- For example, the expectation with the path "fast/events/shadow/" will
- be ignored when removing expectations for the test "fast/event/shadow/awesome-crash.html", since we can just
- add a new expectation line for "fast/event/shadow/awesome-crash.html" to influence expected results.
- """
- expectation_lines = self._test_to_expectation_lines.get(test, [])
- for expectation_line in expectation_lines:
- if (not expectation_line.is_flaky() or remove_flakes) and expectation_line.matching_configurations & test_config_set:
- expectation_line.matching_configurations = expectation_line.matching_configurations - test_config_set
- if not expectation_line.matching_configurations:
- self._bug_manager.close_bug(expectation_line.parsed_bug_modifiers)
- return
-
- def update_expectation(self, test, test_config_set, expectation_set, parsed_bug_modifiers=None):
- """Updates expectations for {test} in the set of test configuration {test_config_set} to the values of {expectation_set}.
- If {parsed_bug_modifiers} is supplied, it is used for updated expectations. Otherwise, a new bug is created.
-
- Here, we treat updating expectations to PASS as special: if possible, the corresponding lines are completely removed.
- """
- # FIXME: Allow specifying modifiers (SLOW, SKIP, WONTFIX).
- updated_expectations = []
- expectation_lines = self._test_to_expectation_lines.get(test, [])
- remaining_configurations = test_config_set.copy()
- bug_ids = self._get_valid_bug_ids(parsed_bug_modifiers)
- new_expectation_line_insertion_point = len(self._expectation_lines)
- remove_expectations = expectation_set == set([test_expectations.PASS]) and test not in self._tests_with_directory_paths
-
- for expectation_line in expectation_lines:
- if expectation_line.matching_configurations == remaining_configurations:
- # Tweak expectations on existing line.
- if expectation_line.parsed_expectations == expectation_set:
- return updated_expectations
- self._bug_manager.close_bug(expectation_line.parsed_bug_modifiers, bug_ids)
- updated_expectations.append(expectation_line)
- if remove_expectations:
- expectation_line.matching_configurations = set()
- else:
- expectation_line.parsed_expectations = expectation_set
- expectation_line.parsed_bug_modifiers = bug_ids
- return updated_expectations
- elif expectation_line.matching_configurations >= remaining_configurations:
- # 1) Split up into two expectation lines:
- # * one with old expectations (existing expectation_line)
- # * one with new expectations (new expectation_line)
- # 2) Finish looking, since there will be no more remaining configs to test for.
- expectation_line.matching_configurations -= remaining_configurations
- updated_expectations.append(expectation_line)
- new_expectation_line_insertion_point = self._expectation_lines.index(expectation_line) + 1
- break
- elif expectation_line.matching_configurations <= remaining_configurations:
- # Remove existing expectation line.
- self._bug_manager.close_bug(expectation_line.parsed_bug_modifiers, bug_ids)
- expectation_line.matching_configurations = set()
- updated_expectations.append(expectation_line)
- else:
- intersection = expectation_line.matching_configurations & remaining_configurations
- if intersection:
- expectation_line.matching_configurations -= intersection
- updated_expectations.append(expectation_line)
- new_expectation_line_insertion_point = self._expectation_lines.index(expectation_line) + 1
-
- if not remove_expectations:
- new_expectation_line = self._create_new_line(test, bug_ids, remaining_configurations, expectation_set)
- updated_expectations.append(new_expectation_line)
- self._expectation_lines.insert(new_expectation_line_insertion_point, new_expectation_line)
-
- return updated_expectations
-
- def _get_valid_bug_ids(self, suggested_bug_ids):
- # FIXME: Flesh out creating a bug properly (title, etc.)
- return suggested_bug_ids or [self._bug_manager.create_bug()]
-
- def _create_new_line(self, name, bug_ids, config_set, expectation_set):
- new_line = test_expectations.TestExpectationLine()
- new_line.name = name
- new_line.parsed_bug_modifiers = bug_ids
- new_line.matching_configurations = config_set
- new_line.parsed_expectations = expectation_set
- # Ensure index integrity for multiple operations.
- self._test_to_expectation_lines.setdefault(name, []).append(new_line)
- return new_line
Deleted: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_expectations_editor_unittest.py (128384 => 128385)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_expectations_editor_unittest.py 2012-09-13 00:04:41 UTC (rev 128384)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_expectations_editor_unittest.py 2012-09-13 00:09:32 UTC (rev 128385)
@@ -1,343 +0,0 @@
-#!/usr/bin/python
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import unittest
-
-from webkitpy.common.host_mock import MockHost
-
-from webkitpy.layout_tests.controllers.test_expectations_editor import *
-from webkitpy.layout_tests.models.test_configuration import *
-from webkitpy.layout_tests.models.test_expectations import *
-from webkitpy.layout_tests.models.test_configuration import *
-
-
-class MockBugManager(object):
- def close_bug(self, bug_id, reference_bug_id=None):
- pass
-
- def create_bug(self):
- return "BUG_NEWLY_CREATED"
-
-
-class TestExpectationEditorTests(unittest.TestCase):
- WIN_RELEASE_CONFIGS = set([
- TestConfiguration('vista', 'x86', 'release'),
- TestConfiguration('win7', 'x86', 'release'),
- TestConfiguration('xp', 'x86', 'release'),
- ])
-
- RELEASE_CONFIGS = set([
- TestConfiguration('vista', 'x86', 'release'),
- TestConfiguration('win7', 'x86', 'release'),
- TestConfiguration('xp', 'x86', 'release'),
- TestConfiguration('vista', 'x86', 'release'),
- TestConfiguration('win7', 'x86', 'release'),
- TestConfiguration('xp', 'x86', 'release'),
- TestConfiguration('snowleopard', 'x86', 'release'),
- TestConfiguration('leopard', 'x86', 'release'),
- TestConfiguration('snowleopard', 'x86', 'release'),
- TestConfiguration('leopard', 'x86', 'release'),
- TestConfiguration('lucid', 'x86', 'release'),
- TestConfiguration('lucid', 'x86_64', 'release'),
- TestConfiguration('lucid', 'x86', 'release'),
- TestConfiguration('lucid', 'x86_64', 'release'),
- ])
-
- def __init__(self, testFunc):
- host = MockHost()
- self.test_port = host.port_factory.get('test-win-xp', None)
- self.full_test_list = ['failures/expected/keyboard.html', 'failures/expected/audio.html']
- unittest.TestCase.__init__(self, testFunc)
-
- def make_parsed_expectation_lines(self, in_string):
- parser = TestExpectationParser(self.test_port, self.full_test_list, allow_rebaseline_modifier=False)
- expectation_lines = parser.parse('path', in_string)
- for expectation_line in expectation_lines:
- self.assertFalse(expectation_line.is_invalid())
- return expectation_lines
-
- def assert_remove_roundtrip(self, in_string, test, expected_string, remove_flakes=False):
- test_config_set = set([self.test_port.test_configuration()])
- expectation_lines = self.make_parsed_expectation_lines(in_string)
- editor = TestExpectationsEditor(expectation_lines, MockBugManager())
- editor.remove_expectation(test, test_config_set, remove_flakes)
- converter = TestConfigurationConverter(self.test_port.all_test_configurations(), self.test_port.configuration_specifier_macros())
- result = TestExpectations.list_to_string(expectation_lines, converter)
- self.assertEquals(result, expected_string)
-
- def assert_update_roundtrip(self, in_string, test, expectation_set, expected_string, expected_update_count, remove_flakes=False, parsed_bug_modifiers=None, test_configs=None):
- test_config_set = test_configs or set([self.test_port.test_configuration()])
- expectation_lines = self.make_parsed_expectation_lines(in_string)
- editor = TestExpectationsEditor(expectation_lines, MockBugManager())
- updated_expectation_lines = editor.update_expectation(test, test_config_set, expectation_set, parsed_bug_modifiers=parsed_bug_modifiers)
- for updated_expectation_line in updated_expectation_lines:
- self.assertTrue(updated_expectation_line in expectation_lines)
- self.assertEquals(len(updated_expectation_lines), expected_update_count)
- converter = TestConfigurationConverter(self.test_port.all_test_configurations(), self.test_port.configuration_specifier_macros())
- result = TestExpectations.list_to_string(expectation_lines, converter)
- self.assertEquals(result, expected_string)
-
- def test_remove_expectation(self):
- self.assert_remove_roundtrip("""
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/hang.html', """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 MAC : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 MAC : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 WIN : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 XP : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX1 LINUX MAC VISTA WIN7 : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 WIN : failures/expected = PASS
-BUGX2 XP RELEASE : failures/expected/keyboard.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 WIN : failures/expected = PASS""")
-
- self.assert_remove_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = IMAGE
-BUGX2 XP DEBUG : failures/expected/keyboard.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX2 XP DEBUG : failures/expected/keyboard.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 WIN : failures/expected = TEXT""", 'failures/expected/keyboard.html', """
-BUGX1 WIN : failures/expected = TEXT""")
-
- self.assert_remove_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = IMAGE PASS
-BUGX2 XP DEBUG : failures/expected/keyboard.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX1 XP RELEASE : failures/expected/keyboard.html = PASS IMAGE
-BUGX2 XP DEBUG : failures/expected/keyboard.html = IMAGE""")
-
- self.assert_remove_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = IMAGE PASS
-BUGX2 XP DEBUG : failures/expected/keyboard.html = IMAGE""", 'failures/expected/keyboard.html', """
-BUGX2 XP DEBUG : failures/expected/keyboard.html = IMAGE""", remove_flakes=True)
-
- def test_remove_expectation_multiple(self):
- in_string = """
-BUGX1 WIN : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE"""
- expectation_lines = self.make_parsed_expectation_lines(in_string)
- converter = TestConfigurationConverter(self.test_port.all_test_configurations(), self.test_port.configuration_specifier_macros())
- editor = TestExpectationsEditor(expectation_lines, MockBugManager())
- test = "failures/expected/keyboard.html"
-
- editor.remove_expectation(test, set([TestConfiguration('xp', 'x86', 'release')]))
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.remove_expectation(test, set([TestConfiguration('xp', 'x86', 'debug')]))
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.remove_expectation(test, set([TestConfiguration('vista', 'x86', 'debug'), TestConfiguration('win7', 'x86', 'release')]))
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 VISTA RELEASE : failures/expected/keyboard.html = IMAGE
-BUGX1 WIN7 DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.remove_expectation(test, set([TestConfiguration('vista', 'x86', 'debug'), TestConfiguration('vista', 'x86', 'release')]))
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 WIN7 DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.remove_expectation(test, set(self.test_port.all_test_configurations()))
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- test = "failures/expected/audio.html"
-
- editor.remove_expectation(test, set(self.test_port.all_test_configurations()))
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), "")
-
- def test_update_expectation(self):
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUG_NEWLY_CREATED XP RELEASE : failures/expected/keyboard.html = IMAGE""", 1)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([PASS]), '', 1)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGX1 XP RELEASE : failures/expected = TEXT
-BUG_NEWLY_CREATED XP RELEASE : failures/expected/keyboard.html = IMAGE""", 1)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected = TEXT""", 'failures/expected/keyboard.html', set([PASS]), """
-BUGX1 XP RELEASE : failures/expected = TEXT
-BUG_NEWLY_CREATED XP RELEASE : failures/expected/keyboard.html = PASS""", 1)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([TEXT]), """
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 0)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGAWESOME XP RELEASE : failures/expected/keyboard.html = IMAGE""", 1, parsed_bug_modifiers=['BUGAWESOME'])
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUG_NEWLY_CREATED XP RELEASE : failures/expected/keyboard.html = IMAGE""", 1)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([PASS]), '', 1)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGAWESOME XP RELEASE : failures/expected/keyboard.html = IMAGE""", 1, parsed_bug_modifiers=['BUGAWESOME'])
-
- self.assert_update_roundtrip("""
-BUGX1 WIN : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = TEXT
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = TEXT
-BUG_NEWLY_CREATED XP RELEASE : failures/expected/keyboard.html = IMAGE""", 2)
-
- self.assert_update_roundtrip("""
-BUGX1 WIN : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([PASS]), """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = TEXT
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = TEXT""", 1)
-
- self.assert_update_roundtrip("""
-BUGX1 WIN : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = TEXT
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = TEXT
-BUG_NEWLY_CREATED XP RELEASE : failures/expected/keyboard.html = IMAGE""", 2)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUG_NEWLY_CREATED WIN RELEASE : failures/expected/keyboard.html = IMAGE""", 2, test_configs=self.WIN_RELEASE_CONFIGS)
-
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([PASS]), '', 1, test_configs=self.WIN_RELEASE_CONFIGS)
-
- self.assert_update_roundtrip("""
-BUGX1 RELEASE : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGX1 LINUX MAC RELEASE : failures/expected/keyboard.html = TEXT
-BUG_NEWLY_CREATED WIN RELEASE : failures/expected/keyboard.html = IMAGE""", 2, test_configs=self.WIN_RELEASE_CONFIGS)
-
- self.assert_update_roundtrip("""
-BUGX1 MAC : failures/expected/keyboard.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGX1 MAC : failures/expected/keyboard.html = TEXT
-BUG_NEWLY_CREATED WIN RELEASE : failures/expected/keyboard.html = IMAGE""", 1, test_configs=self.WIN_RELEASE_CONFIGS)
-
- def test_update_expectation_relative(self):
- self.assert_update_roundtrip("""
-BUGX1 XP RELEASE : failures/expected/keyboard.html = TEXT
-BUGX2 MAC : failures/expected/audio.html = TEXT""", 'failures/expected/keyboard.html', set([IMAGE]), """
-BUGAWESOME XP RELEASE : failures/expected/keyboard.html = IMAGE
-BUGX2 MAC : failures/expected/audio.html = TEXT""", 1, parsed_bug_modifiers=['BUGAWESOME'])
-
- def test_update_expectation_multiple(self):
- in_string = """
-BUGX1 WIN : failures/expected/keyboard.html = IMAGE
-BUGX2 WIN : failures/expected/audio.html = IMAGE"""
- expectation_lines = self.make_parsed_expectation_lines(in_string)
- converter = TestConfigurationConverter(self.test_port.all_test_configurations(), self.test_port.configuration_specifier_macros())
- editor = TestExpectationsEditor(expectation_lines, MockBugManager())
- test = "failures/expected/keyboard.html"
-
- editor.update_expectation(test, set([TestConfiguration('xp', 'x86', 'release')]), set([IMAGE_PLUS_TEXT]), ['BUG_UPDATE1'])
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 XP DEBUG : failures/expected/keyboard.html = IMAGE
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = IMAGE
-BUG_UPDATE1 XP RELEASE : failures/expected/keyboard.html = IMAGE+TEXT
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.update_expectation(test, set([TestConfiguration('xp', 'x86', 'debug')]), set([TEXT]), ['BUG_UPDATE2'])
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 VISTA WIN7 : failures/expected/keyboard.html = IMAGE
-BUG_UPDATE2 XP DEBUG : failures/expected/keyboard.html = TEXT
-BUG_UPDATE1 XP RELEASE : failures/expected/keyboard.html = IMAGE+TEXT
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.update_expectation(test, self.WIN_RELEASE_CONFIGS, set([CRASH]), ['BUG_UPDATE3'])
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 VISTA WIN7 DEBUG : failures/expected/keyboard.html = IMAGE
-BUG_UPDATE2 XP DEBUG : failures/expected/keyboard.html = TEXT
-BUG_UPDATE3 WIN RELEASE : failures/expected/keyboard.html = CRASH
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.update_expectation(test, self.RELEASE_CONFIGS, set([IMAGE_PLUS_TEXT]), ['BUG_UPDATE4'])
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUGX1 VISTA WIN7 DEBUG : failures/expected/keyboard.html = IMAGE
-BUG_UPDATE2 XP DEBUG : failures/expected/keyboard.html = TEXT
-BUG_UPDATE4 RELEASE : failures/expected/keyboard.html = IMAGE+TEXT
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
- editor.update_expectation(test, set(self.test_port.all_test_configurations()), set([TIMEOUT]), ['BUG_UPDATE5'])
- self.assertEquals(TestExpectations.list_to_string(expectation_lines, converter), """
-BUG_UPDATE5 : failures/expected/keyboard.html = TIMEOUT
-BUGX2 WIN : failures/expected/audio.html = IMAGE""")
-
-
-if __name__ == '__main__':
- unittest.main()
Modified: trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py (128384 => 128385)
--- trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py 2012-09-13 00:04:41 UTC (rev 128384)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py 2012-09-13 00:09:32 UTC (rev 128385)
@@ -97,79 +97,6 @@
self.assertRaises(KeyError, extrapolator.extrapolate_test_configurations, "Potato")
-class GardeningExpectationsUpdaterTest(unittest.TestCase):
- def __init__(self, testFunc):
- self.tool = MockTool()
- self.tool.executive = MockExecutive(should_log=True)
- self.tool.filesystem.files[TestPortFactory.path_to_test_expectations_file()] = ""
- unittest.TestCase.__init__(self, testFunc)
-
- def assert_update(self, failure_info_list, expectations_before=None, expectations_after=None, expected_exception=None):
- updater = GardeningExpectationsUpdater(self.tool, TestPortFactory.create())
- path_to_test_expectations_file = TestPortFactory.path_to_test_expectations_file()
- self.tool.filesystem.files[path_to_test_expectations_file] = expectations_before or ""
- if expected_exception:
- self.assertRaises(expected_exception, updater.update_expectations, (failure_info_list))
- else:
- updater.update_expectations(failure_info_list)
- self.assertEquals(self.tool.filesystem.files[path_to_test_expectations_file], expectations_after)
-
- def test_empty_expectations(self):
- failure_info_list = []
- expectations_before = ""
- expectations_after = ""
- self.assert_update(failure_info_list, expectations_before=expectations_before, expectations_after=expectations_after)
-
- def test_unknown_builder(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Bob", "failureTypeList": ["IMAGE"]}]
- self.assert_update(failure_info_list, expected_exception=KeyError)
-
- def test_empty_failure_type_list(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Webkit Win", "failureTypeList": []}]
- self.assert_update(failure_info_list, expected_exception=AssertionError)
-
- def test_empty_test_name(self):
- failure_info_list = [{"testName": "", "builderName": "Webkit Win", "failureTypeList": ["TEXT"]}]
- self.assert_update(failure_info_list, expected_exception=AssertionError)
-
- def test_unknown_failure_type(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Webkit Win", "failureTypeList": ["IMAGE", "EXPLODE"]}]
- expectations_before = ""
- expectations_after = "\nBUG_NEW XP RELEASE : failures/expected/image.html = IMAGE"
- self.assert_update(failure_info_list, expectations_before=expectations_before, expectations_after=expectations_after)
-
- def test_add_new_expectation(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Webkit Win", "failureTypeList": ["IMAGE"]}]
- expectations_before = ""
- expectations_after = "\nBUG_NEW XP RELEASE : failures/expected/image.html = IMAGE"
- self.assert_update(failure_info_list, expectations_before=expectations_before, expectations_after=expectations_after)
-
- def test_replace_old_expectation(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Webkit Win", "failureTypeList": ["IMAGE"]}]
- expectations_before = "BUG_OLD XP RELEASE : failures/expected/image.html = TEXT"
- expectations_after = "BUG_NEW XP RELEASE : failures/expected/image.html = IMAGE"
- self.assert_update(failure_info_list, expectations_before=expectations_before, expectations_after=expectations_after)
-
- def test_pass_expectation(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Webkit Win", "failureTypeList": ["PASS"]}]
- expectations_before = "BUG_OLD XP RELEASE : failures/expected/image.html = TEXT"
- expectations_after = ""
- self.assert_update(failure_info_list, expectations_before=expectations_before, expectations_after=expectations_after)
-
- def test_supplement_old_expectation(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Webkit Win", "failureTypeList": ["IMAGE"]}]
- expectations_before = "BUG_OLD XP RELEASE : failures/expected/text.html = TEXT"
- expectations_after = ("BUG_OLD XP RELEASE : failures/expected/text.html = TEXT\n"
- "BUG_NEW XP RELEASE : failures/expected/image.html = IMAGE")
- self.assert_update(failure_info_list, expectations_before=expectations_before, expectations_after=expectations_after)
-
- def test_spurious_updates(self):
- failure_info_list = [{"testName": "failures/expected/image.html", "builderName": "Webkit Win", "failureTypeList": ["IMAGE"]}]
- expectations_before = "BUG_OLDER MAC LINUX : failures/expected/image.html = IMAGE+TEXT\nBUG_OLD XP RELEASE : failures/expected/image.html = TEXT"
- expectations_after = "BUG_OLDER MAC LINUX : failures/expected/image.html = IMAGE+TEXT\nBUG_NEW XP RELEASE : failures/expected/image.html = IMAGE"
- self.assert_update(failure_info_list, expectations_before=expectations_before, expectations_after=expectations_after)
-
-
class GardeningServerTest(unittest.TestCase):
def _post_to_path(self, path, body=None, expected_stderr=None, expected_stdout=None, server=None):
handler = TestGardeningHTTPRequestHandler(server or MockServer())
@@ -203,8 +130,3 @@
expected_stderr = 'MOCK run_command: [\'echo\', \'rebaseline-json\'], cwd=/mock-checkout, input={"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}\n'
expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.html":{"MOCK builder": ["txt","png"]}}', expected_stderr=expected_stderr, expected_stdout=expected_stdout)
-
- def test_updateexpectations(self):
- expected_stderr = ""
- expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
- self._post_to_path("/updateexpectations", body="[]", expected_stderr=expected_stderr, expected_stdout=expected_stdout)