示例#1
0
 def test_is_all_pass_testharness_result_positive_cases(self):
     self.assertTrue(
         testharness_results.is_all_pass_testharness_result(
             'This is a testharness.js-based test.\n'
             ' PASS: foo bar \n'
             ' Harness: the test ran to completion.'))
     self.assertTrue(
         testharness_results.is_all_pass_testharness_result(
             'This is a testharness.js-based test.\n'
             'PASS \'grid\' with: grid-template-areas: "a b"\n'
             '"c d";\n'
             'Harness: the test ran to completion.\n'))
示例#2
0
 def _is_all_pass_testharness_result(self, path):
     """Checks if a baseline is an all-PASS testharness.js result."""
     # TODO(robertma): Find an appropriate constant for this (or make one).
     if not path.endswith('-expected.txt'):
         return False
     content = self._filesystem.read_text_file(path)
     return is_all_pass_testharness_result(content)
    def __init__(self, fs, path, is_reftest=False):
        """Constructs the digest for a result.

        Args:
            fs: An instance of common.system.FileSystem.
            path: The path to a result file. If None is provided, the result is
                an *implicit* extra result.
            is_reftest: Whether the test is a reftest.
        """
        self.path = path
        if path is None:
            self.sha = self._IMPLICIT_EXTRA_RESULT
            self.is_extra_result = True
            return

        assert fs.exists(path)
        if path.endswith('.txt'):
            content = fs.read_text_file(path)
            self.is_extra_result = not content or is_all_pass_testharness_result(
                content)
            # Unfortunately, we may read the file twice, once in text mode
            # and once in binary mode.
            self.sha = fs.sha1(path)
            return

        if path.endswith('.png') and is_reftest:
            self.is_extra_result = True
            self.sha = ''
            return

        self.is_extra_result = not fs.read_binary_file(path)
        self.sha = fs.sha1(path)
 def _is_all_pass_testharness_text_not_needing_baseline(self, text_result):
     return (
         text_result
         and testharness_results.is_all_pass_testharness_result(text_result)
         and
         # An all-pass testharness test doesn't need the test baseline unless
         # if it is overriding a fallback one.
         not self._port.fallback_expected_filename(self._test_name, '.txt'))
示例#5
0
 def test_is_all_pass_testharness_result_negative_cases(self):
     self.assertFalse(
         testharness_results.is_all_pass_testharness_result(
             'This is a testharness.js-based test.\n'
             'CONSOLE WARNING: This is a warning.\n'
             'Test ran to completion.'))
     self.assertFalse(
         testharness_results.is_all_pass_testharness_result(
             'This is a testharness.js-based test.\n'
             ' PASS: foo bar \n'
             'FAIL  \n'
             ' Harness: the test ran to completion.'))
     self.assertFalse(
         testharness_results.is_all_pass_testharness_result(
             'This is a testharness.js-based test.\n'
             'Harness Error. harness_status.status = 1\n'
             'PASS foo bar\n'
             'Harness: the test ran to completion.'))
示例#6
0
 def test_all_pass_testharness_result(fs, path):
     # TODO(robertma): Find an appropriate constant for this (or make one).
     if not path.endswith('-expected.txt'):
         return False
     content = fs.read_text_file(path)
     return is_all_pass_testharness_result(content)
示例#7
0
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Check if a web test expected file is an all-PASS testharness result.

web_tests/PRESUBMIT.py uses this script to identify generic all-PASS
testharness baselines, which are redundant because run_web_tests.py assumes
all-PASS results for testharness tests when baselines are not found.
"""

import sys

from blinkpy.web_tests.models.testharness_results import is_all_pass_testharness_result

paths = []

for path in sys.argv[1:]:
    content = open(path, 'r').read()
    if is_all_pass_testharness_result(content):
        paths.append(path)

if len(paths) > 0:
    sys.stderr.write(
        '* The following files are passing testharness results without console error messages, they should be removed:\n '
    )
    sys.stderr.write('\n '.join(paths))
    sys.stderr.write('\n')
    sys.exit(
        "ERROR: found passing testharness results without console error messages."
    )