Commit 4b287a61 authored by Philip Jägenstedt's avatar Philip Jägenstedt Committed by Commit Bot

Always start from WPT_BASE_MANIFEST.json when updating MANIFEST.json

This will avoid full manifest rebuilds for Chromium developers when
the manifest version changes.

Bug: 876717
Change-Id: I6d552ad03936fb07cf559d0f072508e5ea2184a4
Reviewed-on: https://chromium-review.googlesource.com/1185009
Commit-Queue: Philip Jägenstedt <foolip@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585271}
parent defd3adc
......@@ -122,4 +122,4 @@ class MockHost(MockSystemHost):
filesystem.maybe_make_directory(filesystem.join(external_dir, 'wpt'))
manifest_base_path = filesystem.join(external_dir, 'WPT_BASE_MANIFEST.json')
filesystem.files[manifest_base_path] = '{}'
filesystem.files[manifest_base_path] = '{"manifest": "base"}'
......@@ -172,7 +172,7 @@ class WPTManifest(object):
@staticmethod
def ensure_manifest(host):
"""Generates the MANIFEST.json file if it does not exist."""
"""Updates the MANIFEST.json file, or generates if it does not exist."""
finder = PathFinder(host.filesystem)
manifest_path = finder.path_from_layout_tests('external', 'wpt', 'MANIFEST.json')
base_manifest_path = finder.path_from_layout_tests('external', 'WPT_BASE_MANIFEST.json')
......@@ -181,11 +181,15 @@ class WPTManifest(object):
_log.error('Manifest base not found at "%s".', base_manifest_path)
host.filesystem.write_text_file(base_manifest_path, '{}')
if not host.filesystem.exists(manifest_path):
_log.debug('Manifest not found, copying from base "%s".', base_manifest_path)
host.filesystem.copyfile(base_manifest_path, manifest_path)
# Unconditionally replace MANIFEST.json with WPT_BASE_MANIFEST.json even
# if the former exists, to avoid regenerating the manifest from scratch
# when the manifest version changes. Remove the destination first as
# copyfile will fail if the two files are hardlinked or symlinked.
if host.filesystem.exists(manifest_path):
host.filesystem.remove(manifest_path)
host.filesystem.copyfile(base_manifest_path, manifest_path)
wpt_path = manifest_path = finder.path_from_layout_tests('external', 'wpt')
wpt_path = finder.path_from_layout_tests('external', 'wpt')
WPTManifest.generate_manifest(host, wpt_path)
_log.debug('Manifest generation completed.')
......
......@@ -19,6 +19,7 @@ class WPTManifestUnitTest(unittest.TestCase):
self.assertFalse(host.filesystem.exists(manifest_path))
WPTManifest.ensure_manifest(host)
self.assertTrue(host.filesystem.exists(manifest_path))
self.assertEqual(host.filesystem.written_files, {manifest_path: '{"manifest": "base"}'})
webkit_base = '/mock-checkout/third_party/WebKit'
self.assertEqual(
......@@ -39,11 +40,12 @@ class WPTManifestUnitTest(unittest.TestCase):
host = MockHost()
manifest_path = '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt/MANIFEST.json'
host.filesystem.write_text_file(manifest_path, '{}')
self.assertTrue(host.filesystem.exists(manifest_path))
host.filesystem.write_text_file(manifest_path, '{"manifest": "NOT base"}')
self.assertTrue(host.filesystem.exists(manifest_path))
WPTManifest.ensure_manifest(host)
self.assertTrue(host.filesystem.exists(manifest_path))
self.assertEqual(host.filesystem.written_files, {manifest_path: '{"manifest": "base"}'})
webkit_base = '/mock-checkout/third_party/WebKit'
self.assertEqual(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment