Bug 1161270 - Add source manifest to reftest manifest representation in moz.build.;r=gps,roc
authorChris Manchester <cmanchester@mozilla.com>
Mon, 11 May 2015 16:35:39 -0700
changeset 243536 77c19e3e5a440a3ba36140f91be123cf87c7b821
parent 243535 7a5258332448e586e3ca42dfc2b8f4ff772acbb6
child 243537 8df1ea116b91c96d7cc2c855c0d9d17777bb0b39
push id59688
push usercmanchester@mozilla.com
push dateTue, 12 May 2015 17:22:37 +0000
treeherdermozilla-inbound@77c19e3e5a44 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, roc
bugs1161270
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1161270 - Add source manifest to reftest manifest representation in moz.build.;r=gps,roc
layout/tools/reftest/reftest/__init__.py
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/frontend/data/test-manifest-emitted-includes/included-reftest.list
python/mozbuild/mozbuild/test/frontend/data/test-manifest-emitted-includes/moz.build
python/mozbuild/mozbuild/test/frontend/data/test-manifest-emitted-includes/reftest.list
python/mozbuild/mozbuild/test/frontend/test_emitter.py
--- a/layout/tools/reftest/reftest/__init__.py
+++ b/layout/tools/reftest/reftest/__init__.py
@@ -40,25 +40,26 @@ class ReftestManifest(object):
     We currently only capture file information because that is the only thing
     tools require.
     """
     def __init__(self):
         self.path = None
         self.dirs = set()
         self.files = set()
         self.manifests = set()
+        self.tests = set()
 
     def load(self, path):
         """Parse a reftest manifest file."""
-        normalized = os.path.normpath(os.path.abspath(path))
-        self.manifests.add(normalized)
+        normalized_path = os.path.normpath(os.path.abspath(path))
+        self.manifests.add(normalized_path)
         if not self.path:
-            self.path = normalized
+            self.path = normalized_path
 
-        mdir = os.path.dirname(normalized)
+        mdir = os.path.dirname(normalized_path)
         self.dirs.add(mdir)
 
         with open(path, 'r') as fh:
             urlprefix = ''
             for line in fh:
                 line = line.decode('utf-8')
 
                 # Entire line is a comment.
@@ -118,8 +119,9 @@ class ReftestManifest(object):
                     # Discarding data isn't correct for a parser. But retaining
                     # all data isn't currently a requirement.
                     if RE_PROTOCOL.match(f):
                         continue
 
                     test = os.path.normpath(os.path.join(mdir, urlprefix + f))
                     self.files.add(test)
                     self.dirs.add(os.path.dirname(test))
+                    self.tests.add((test, normalized_path))
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -1125,21 +1125,21 @@ class TreeMetadataEmitter(LoggingMixin):
         # reftest manifests don't come from manifest parser. But they are
         # similar enough that we can use the same emitted objects. Note
         # that we don't perform any installs for reftests.
         obj = TestManifest(context, manifest_full_path, manifest,
                 flavor=flavor, install_prefix='%s/' % flavor,
                 relpath=mozpath.join(manifest_reldir,
                     mozpath.basename(manifest_path)))
 
-        for test in sorted(manifest.files):
+        for test, source_manifest in sorted(manifest.tests):
             obj.tests.append({
                 'path': test,
                 'here': mozpath.dirname(test),
-                'manifest': manifest_full_path,
+                'manifest': source_manifest,
                 'name': mozpath.basename(test),
                 'head': '',
                 'tail': '',
                 'support-files': '',
                 'subsuite': '',
             })
 
         yield obj
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/frontend/data/test-manifest-emitted-includes/included-reftest.list
@@ -0,0 +1,1 @@
+!= reftest2.html reftest2-ref.html
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/frontend/data/test-manifest-emitted-includes/moz.build
@@ -0,0 +1,1 @@
+REFTEST_MANIFESTS += ['reftest.list']
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/frontend/data/test-manifest-emitted-includes/reftest.list
@@ -0,0 +1,2 @@
+== reftest1.html reftest1-ref.html
+include included-reftest.list
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -463,16 +463,34 @@ class TestEmitterBasic(unittest.TestCase
         expected = [
             mozpath.normpath(mozpath.join(o.install_prefix, "subdir/common.ini")),
             mozpath.normpath(mozpath.join(o.install_prefix, "subdir/mochitest.ini")),
             mozpath.normpath(mozpath.join(o.install_prefix, "subdir/test_foo.html")),
         ]
         paths = sorted([v[0] for v in o.installs.values()])
         self.assertEqual(paths, expected)
 
+    def test_test_manifest_includes(self):
+        """Ensure that manifest objects from the emitter list a correct manifest.
+        """
+        reader = self.reader('test-manifest-emitted-includes')
+        [obj] = self.read_topsrcdir(reader)
+
+        # Expected manifest leafs for our tests.
+        expected_manifests = {
+            'reftest1.html': 'reftest.list',
+            'reftest1-ref.html': 'reftest.list',
+            'reftest2.html': 'included-reftest.list',
+            'reftest2-ref.html': 'included-reftest.list',
+        }
+
+        for t in obj.tests:
+            self.assertTrue(t['manifest'].endswith(expected_manifests[t['name']]))
+
+
     def test_test_manifest_keys_extracted(self):
         """Ensure all metadata from test manifests is extracted."""
         reader = self.reader('test-manifest-keys-extracted')
 
         objs = [o for o in self.read_topsrcdir(reader)
                 if isinstance(o, TestManifest)]
 
         self.assertEqual(len(objs), 8)