Exemple #1
0
    def test_expectation_overwrites_checked_in_metadata(self):
        """Test an entry in an expectation overwriting checked-in metadata.

        When an expectation has no annotation to use checked-in metadata then
        the expectation will overwrite any checked-in metadata."""
        test_name = "external/wpt/test.html"
        expectations = _make_expectation(self.port, test_name, "TIMEOUT")
        mb = WPTMetadataBuilder(expectations, self.port)
        # Set the metadata builder to use mock filesystem populated with some
        # test data
        mb.checked_in_metadata_dir = "src"
        mb.metadata_output_dir = "out"
        mock_checked_in_files = {
            "src/external/wpt/test.html": "",
            "src/external/wpt/test.html.ini": "checked-in metadata",
        }
        mb.fs = MockFileSystem(files=mock_checked_in_files)

        mb._build_metadata_and_write()
        # Ensure that the data written to the metadata file is the translated
        # status, not the checked-in contents.
        resulting_ini_file = os.path.join("out", "test.html.ini")
        self.assertEqual(
            "[test.html]\n  blink_expect_any_subtest_status: True # wpt_metadata_builder.py\n  expected: [TIMEOUT]\n",
            mb.fs.read_text_file(resulting_ini_file))
Exemple #2
0
    def test_same_metadata_file_for_variants(self):
        """Variants of a test all go in the same metadata file."""
        test_name1 = "external/wpt/variant.html?foo=bar/abc"
        test_name2 = "external/wpt/variant.html?foo=baz"
        expectation_dict = OrderedDict()
        _append_to_expectation_dict(expectation_dict, "TestExpectations",
                                    test_name1, "FAILURE")
        _append_to_expectation_dict(expectation_dict, "TestExpectations",
                                    test_name2, "TIMEOUT")
        expectations = _make_expectation_with_dict(self.port, expectation_dict)
        metadata_builder = WPTMetadataBuilder(expectations, self.port)
        metadata_builder.metadata_output_dir = "out"
        metadata_builder.fs = MockFileSystem()
        metadata_builder._build_metadata_and_write()

        # Both the tests go into the same metadata file, named without any
        # variants.
        metadata_file = os.path.join("out", "variant.html.ini")
        # Inside the metadata file, we have separate entries for each variant
        self.assertEqual(
            "[variant.html?foo=baz]\n  blink_expect_any_subtest_status: True # wpt_metadata_builder.py\n"
            "  expected: [TIMEOUT]\n"
            "[variant.html?foo=bar/abc]\n  blink_expect_any_subtest_status: True # wpt_metadata_builder.py\n"
            "  expected: [FAIL, ERROR]\n",
            metadata_builder.fs.read_text_file(metadata_file))