Bug 1252556 - Make profileserver.py fail when running Firefox fails. r?build draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 02 Nov 2017 08:59:23 +0900
changeset 691853 cc973afe115111eba533ca68e7cf9c6a22b09bcf
parent 690457 fa42202670b85ee2ef0a66f3948b2a4357d68c0a
child 738601 08bdf24eca7bffd9653ffc44436f3fd113f233da
push id87330
push userbmo:mh+mozilla@glandium.org
push dateThu, 02 Nov 2017 04:09:46 +0000
reviewersbuild
bugs1252556
milestone58.0a1
Bug 1252556 - Make profileserver.py fail when running Firefox fails. r?build Currently, when Firefox crashes when running the PGO profile, the error is ignored, and the result is a build that is not optimized as expected. So instead of such things going unnoticed, we make profileserver.py return an error code, further failing the build. Unfortunately, this does not make the output useful to know what went wrong exactly, but the most important thing is that the build fails instead of going through and leading to bad results.
build/pgo/profileserver.py
--- a/build/pgo/profileserver.py
+++ b/build/pgo/profileserver.py
@@ -1,16 +1,17 @@
 #!/usr/bin/python
 #
 # 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/.
 
 import json
 import os
+import sys
 
 from buildconfig import substs
 from mozbuild.base import MozbuildObject
 from mozfile import TemporaryDirectory
 from mozhttpd import MozHttpd
 from mozprofile import FirefoxProfile, Profile, Preferences
 from mozprofile.permissions import ServerLocations
 from mozrunner import FirefoxRunner, CLI
@@ -81,24 +82,32 @@ if __name__ == '__main__':
 
         # Run Firefox a first time to initialize its profile
         runner = FirefoxRunner(profile=profile,
                                binary=build.get_binary_path(
                                    where="staged-package"),
                                cmdargs=['javascript:Quitter.quit()'],
                                env=env)
         runner.start()
-        runner.wait()
+        ret = runner.wait()
+        if ret:
+            print("Firefox exited with code %d during profile initialization"
+                  % ret)
+            httpd.stop()
+            sys.exit(ret)
 
         jarlog = os.getenv("JARLOG_FILE")
         if jarlog:
             env["MOZ_JAR_LOG_FILE"] = os.path.abspath(jarlog)
             print "jarlog: %s" % env["MOZ_JAR_LOG_FILE"]
 
         cmdargs = ["http://localhost:%d/index.html" % PORT]
         runner = FirefoxRunner(profile=profile,
                                binary=build.get_binary_path(
                                    where="staged-package"),
                                cmdargs=cmdargs,
                                env=env)
         runner.start(debug_args=debug_args, interactive=interactive)
-        runner.wait()
+        ret = runner.wait()
         httpd.stop()
+        if ret:
+            print("Firefox exited with code %d during profiling" % ret)
+            sys.exit(ret)