Bug 1132771 - Add a test for reading all moz.build files in filesystem traversal mode; r=glandium
☠☠ backed out by ce21e7a57cf8 ☠ ☠
authorGregory Szorc <gps@mozilla.com>
Thu, 26 Feb 2015 09:49:49 -0800
changeset 261578 91d34d3107faa777264cdcc9c89456bf4c289466
parent 261577 6c44edc8208a54a9d5d830266cded7b409a776e1
child 261579 c3a0cb4b45b17efa64bd8419b08d23d59ffc2883
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1132771
milestone39.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 1132771 - Add a test for reading all moz.build files in filesystem traversal mode; r=glandium moz.build files should execute in filesystem traversal mode. Add a test that verifies this is true. This test performs a brute force filesystem scan to find relevant moz.build files. This can be a little slow. That's unfortunate. But it's a price we need to pay in order to ensure metadata extraction mode continues to work.
config/moz.build
config/tests/test_mozbuild_reading.py
--- a/config/moz.build
+++ b/config/moz.build
@@ -25,13 +25,14 @@ if CONFIG['HOST_OS_ARCH'] != 'WINNT':
 
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
     DEFINES['GKMEDIAS_SHARED_LIBRARY'] = True
 
 if CONFIG['MOZ_SHARED_ICU']:
     DEFINES['MOZ_SHARED_ICU'] = True
 
 PYTHON_UNIT_TESTS += [
+    'tests/test_mozbuild_reading.py',
     'tests/unit-expandlibs.py',
     'tests/unit-mozunit.py',
     'tests/unit-nsinstall.py',
     'tests/unit-printprereleasesuffix.py',
 ]
new file mode 100644
--- /dev/null
+++ b/config/tests/test_mozbuild_reading.py
@@ -0,0 +1,44 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import unicode_literals
+
+import os
+import unittest
+
+from mozunit import main
+
+from mozbuild.base import MozbuildObject
+from mozbuild.frontend.reader import BuildReader
+
+
+class TestMozbuildReading(unittest.TestCase):
+    # This hack is needed to appease running in automation.
+    def setUp(self):
+        self._old_env = dict(os.environ)
+        os.environ.pop('MOZCONFIG', None)
+        os.environ.pop('MOZ_OBJDIR', None)
+
+    def tearDown(self):
+        os.environ.clear()
+        os.environ.update(self._old_env)
+
+    def test_filesystem_traversal_reading(self):
+        """Reading moz.build according to filesystem traversal works.
+
+        We attempt to read every known moz.build file via filesystem traversal.
+
+        If this test fails, it means that metadata extraction will fail.
+        """
+        mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False)
+        config = mb.config_environment
+        reader = BuildReader(config)
+        all_paths = set(reader.all_mozbuild_paths())
+        paths, contexts = reader.read_relevant_mozbuilds(all_paths)
+        self.assertEqual(set(paths), all_paths)
+        self.assertGreaterEqual(len(contexts), len(paths))
+
+
+if __name__ == '__main__':
+    main()