PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/src/qt/qtwebkit/Tools/Scripts/webkitpy/common/net/layouttestresults.py

https://gitlab.com/x33n/phantomjs
Python | 91 lines | 37 code | 16 blank | 38 comment | 6 complexity | 356daa5556fbfc99c798873e46220ddb MD5 | raw file
  1. # Copyright (c) 2010, Google Inc. All rights reserved.
  2. #
  3. # Redistribution and use in source and binary forms, with or without
  4. # modification, are permitted provided that the following conditions are
  5. # met:
  6. #
  7. # * Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # * Redistributions in binary form must reproduce the above
  10. # copyright notice, this list of conditions and the following disclaimer
  11. # in the documentation and/or other materials provided with the
  12. # distribution.
  13. # * Neither the name of Google Inc. nor the names of its
  14. # contributors may be used to endorse or promote products derived from
  15. # this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. import logging
  29. from webkitpy.common.net.resultsjsonparser import ResultsJSONParser
  30. from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup, SoupStrainer
  31. from webkitpy.layout_tests.models import test_results
  32. from webkitpy.layout_tests.models import test_failures
  33. _log = logging.getLogger(__name__)
  34. # FIXME: This should be unified with all the layout test results code in the layout_tests package
  35. # This doesn't belong in common.net, but we don't have a better place for it yet.
  36. def path_for_layout_test(test_name):
  37. return "LayoutTests/%s" % test_name
  38. # FIXME: This should be unified with ResultsSummary or other NRWT layout tests code
  39. # in the layout_tests package.
  40. # This doesn't belong in common.net, but we don't have a better place for it yet.
  41. class LayoutTestResults(object):
  42. @classmethod
  43. def results_from_string(cls, string):
  44. if not string:
  45. return None
  46. test_results = ResultsJSONParser.parse_results_json(string)
  47. if not test_results:
  48. return None
  49. return cls(test_results)
  50. def __init__(self, test_results):
  51. self._test_results = test_results
  52. self._failure_limit_count = None
  53. self._unit_test_failures = []
  54. # FIXME: run-webkit-tests should store the --exit-after-N-failures value
  55. # (or some indication of early exit) somewhere in the results.json
  56. # file. Until it does, callers should set the limit to
  57. # --exit-after-N-failures value used in that run. Consumers of LayoutTestResults
  58. # may use that value to know if absence from the failure list means PASS.
  59. # https://bugs.webkit.org/show_bug.cgi?id=58481
  60. def set_failure_limit_count(self, limit):
  61. self._failure_limit_count = limit
  62. def failure_limit_count(self):
  63. return self._failure_limit_count
  64. def test_results(self):
  65. return self._test_results
  66. def results_matching_failure_types(self, failure_types):
  67. return [result for result in self._test_results if result.has_failure_matching_types(*failure_types)]
  68. def tests_matching_failure_types(self, failure_types):
  69. return [result.test_name for result in self.results_matching_failure_types(failure_types)]
  70. def failing_test_results(self):
  71. return self.results_matching_failure_types(test_failures.ALL_FAILURE_CLASSES)
  72. def failing_tests(self):
  73. return [result.test_name for result in self.failing_test_results()] + self._unit_test_failures
  74. def add_unit_test_failures(self, unit_test_results):
  75. self._unit_test_failures = unit_test_results