Bug 1583353 - [mozbuild.reader] Don't return root moz.build twice in 'all_mozbuild_paths', r=froydnj
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 05 Nov 2019 15:38:32 +0000
changeset 501567 8d28c3108fc018c92e3af80254cef8671961e038
parent 501566 776dc76ec598f7d400d24564ec5e9e44d106b006
child 501568 b96f1cf028b61ef4d8d647dba6a48b7b48213ec3
push id36796
push usermalexandru@mozilla.com
push dateWed, 13 Nov 2019 04:49:59 +0000
treeherdermozilla-central@48a708577712 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1583353
milestone72.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 1583353 - [mozbuild.reader] Don't return root moz.build twice in 'all_mozbuild_paths', r=froydnj Despite what the comment says, the finder *does* pick up the root moz.build. So we end up processing it twice. This was never caught before because we only ever used this function to read Sphinx related variables, of which the root moz.build contains none. Differential Revision: https://phabricator.services.mozilla.com/D51832
python/mozbuild/mozbuild/frontend/reader.py
python/mozbuild/mozbuild/test/frontend/test_reader.py
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -896,19 +896,16 @@ class BuildReader(object):
         """Iterator over all available moz.build files.
 
         This method has little to do with the reader. It should arguably belong
         elsewhere.
         """
         # In the future, we may traverse moz.build files by looking
         # for DIRS references in the AST, even if a directory is added behind
         # a conditional. For now, just walk the filesystem.
-        # The root doesn't get picked up by FileFinder.
-        yield 'moz.build'
-
         for path, f in self._relevant_mozbuild_finder.find('**/moz.build'):
             yield path
 
     def find_variables_from_ast(self, variables, path=None):
         """Finds all assignments to the specified variables by parsing
         moz.build abstract syntax trees.
 
         This function only supports two cases, as detailed below.
--- a/python/mozbuild/mozbuild/test/frontend/test_reader.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_reader.py
@@ -340,16 +340,24 @@ class TestBuildReader(unittest.TestCase)
 
         self.assertEqual([ctx.relsrcdir for ctx in paths['d1/every-level/a/file']],
                          ['', 'd1', 'd1/every-level', 'd1/every-level/a'])
         self.assertEqual([ctx.relsrcdir for ctx in paths['d1/every-level/b/file']],
                          ['', 'd1', 'd1/every-level', 'd1/every-level/b'])
         self.assertEqual([ctx.relsrcdir for ctx in paths['d2/file']],
                          ['', 'd2'])
 
+    def test_all_mozbuild_paths(self):
+        reader = self.reader('reader-relevant-mozbuild')
+
+        paths = list(reader.all_mozbuild_paths())
+        # Ensure no duplicate paths.
+        self.assertEqual(sorted(paths), sorted(set(paths)))
+        self.assertEqual(len(paths), 10)
+
     def test_files_bad_bug_component(self):
         reader = self.reader('files-info')
 
         with self.assertRaises(BuildReaderError):
             reader.files_info(['bug_component/bad-assignment/moz.build'])
 
     def test_files_bug_component_static(self):
         reader = self.reader('files-info')