Bug 1335873 - Ignore MozconfigFindException when looking for a mozinfo.json, r=maja_zf
☠☠ backed out by d725ecdbe54e ☠ ☠
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 15 Feb 2017 16:37:58 -0500
changeset 394368 caacf82afba18ddcbab61f3cc486f9b98f98e279
parent 394367 99aabb33581ad1f67728f3f20a04888d6efafb03
child 394369 3c0a7527608aa6398f8177b08088da39592078d9
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1335873
milestone54.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 1335873 - Ignore MozconfigFindException when looking for a mozinfo.json, r=maja_zf This gets raised when trying to run the marionette-harness python tests without an objdir. It's safe to ignore because mozinfo.json will still be found via the 'dirs' variable which gets passed in from the marionette harness. MozReview-Commit-ID: Ata99evHxbd
testing/mozbase/mozinfo/mozinfo/mozinfo.py
testing/mozbase/mozinfo/tests/test.py
--- a/testing/mozbase/mozinfo/mozinfo/mozinfo.py
+++ b/testing/mozbase/mozinfo/mozinfo/mozinfo.py
@@ -213,24 +213,25 @@ def find_and_update_from_json(*dirs):
                  searched after first looking in the root of the objdir
                  if the current script is being run from a Mozilla objdir.
 
     Returns the full path to mozinfo.json if it was found, or None otherwise.
     """
     # First, see if we're in an objdir
     try:
         from mozbuild.base import MozbuildObject, BuildEnvironmentNotFoundException
+        from mozbuild.mozconfig import MozconfigFindException
         build = MozbuildObject.from_environment()
         json_path = _os.path.join(build.topobjdir, "mozinfo.json")
         if _os.path.isfile(json_path):
             update(json_path)
             return json_path
     except ImportError:
         pass
-    except BuildEnvironmentNotFoundException:
+    except (BuildEnvironmentNotFoundException, MozconfigFindException):
         pass
 
     for d in dirs:
         d = _os.path.abspath(d)
         json_path = _os.path.join(d, "mozinfo.json")
         if _os.path.isfile(json_path):
             update(json_path)
             return json_path
--- a/testing/mozbase/mozinfo/tests/test.py
+++ b/testing/mozbase/mozinfo/tests/test.py
@@ -78,17 +78,23 @@ class TestMozinfo(unittest.TestCase):
         """Test that mozinfo.find_and_update_from_json can
         find mozinfo.json using the mozbuild module."""
         j = os.path.join(self.tempdir, "mozinfo.json")
         with open(j, "w") as f:
             f.write(json.dumps({"foo": "123456"}))
         m = mock.MagicMock()
         # Mock the value of MozbuildObject.from_environment().topobjdir.
         m.MozbuildObject.from_environment.return_value.topobjdir = self.tempdir
-        with mock.patch.dict(sys.modules, {"mozbuild": m, "mozbuild.base": m}):
+
+        mocked_modules = {
+            "mozbuild": m,
+            "mozbuild.base": m,
+            "mozbuild.mozconfig": m,
+        }
+        with mock.patch.dict(sys.modules, mocked_modules):
             self.assertEqual(mozinfo.find_and_update_from_json(), j)
         self.assertEqual(mozinfo.info["foo"], "123456")
 
     def test_output_to_file(self):
         """Test that mozinfo.output_to_file works."""
         path = os.path.join(self.tempdir, "mozinfo.json")
         mozinfo.output_to_file(path)
         self.assertEqual(open(path).read(), json.dumps(mozinfo.info))