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))
def test_copy_checked_in_metadata(self): # Ensure that ini metadata files are copied from the checked-in dir to # the output dir as expected. expectations = TestExpectations(self.port) 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/a/b/c.html": "", "src/a/b/c.html.ini": "", "src/a/d/e.html": "", "src/a/d/e.html.ini": "checked-in", "src/a/tox.ini": "", # Put one duplicate file in the output directory to simulate a test # with both legacy expectations and checked-in metadata "out/a/d/e.html.ini": "legacy", } mb.fs = MockFileSystem(files=mock_checked_in_files) # Ensure that the duplicate file starts out with the legacy content. duplicate_ini_file = "out/a/d/e.html.ini" self.assertEqual("legacy", mb.fs.read_text_file(duplicate_ini_file)) mb._copy_checked_in_metadata() # Ensure only the ini files are copied, not the tests self.assertEqual(3, len(mb.fs.written_files)) self.assertTrue("out/a/b/c.html.ini" in mb.fs.written_files) self.assertTrue("out/a/d/e.html.ini" in mb.fs.written_files) self.assertTrue("out/a/tox.ini" in mb.fs.written_files) # Also ensure that the content of the duplicate file was overwritten # with the checked-in contents. self.assertEqual("checked-in", mb.fs.read_text_file(duplicate_ini_file))