Bug 1457963 - Add a --temp-profile argument to `mach run` that creates a new temp profile directory;r=ahal
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 01 May 2018 12:13:40 -0700
changeset 472547 eb78f49f99f095346715906321a5730bf647dfec
parent 472546 969b429c982e793de88d04011f4a1aa610ff8d6d
child 472548 fa4f44996ac6a77963450d25e5ea66fc6d39c701
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1457963 - Add a --temp-profile argument to `mach run` that creates a new temp profile directory;r=ahal MozReview-Commit-ID: LI6a9KBNXer
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -9,16 +9,17 @@ import hashlib
 import itertools
 import json
 import logging
 import operator
 import os
 import re
 import subprocess
 import sys
+import tempfile
 from collections import OrderedDict
 import mozpack.path as mozpath
 from mach.decorators import (
@@ -818,16 +819,18 @@ class RunProgram(MachCommandBase):
     @CommandArgument('--noprofile', '-n', action='store_true', group=prog_group,
         help='Do not pass the --profile argument by default.')
     @CommandArgument('--disable-e10s', action='store_true', group=prog_group,
         help='Run the program with electrolysis disabled.')
     @CommandArgument('--enable-crash-reporter', action='store_true', group=prog_group,
         help='Run the program with the crash reporter enabled.')
     @CommandArgument('--setpref', action='append', default=[], group=prog_group,
         help='Set the specified pref before starting the program. Can be set multiple times. Prefs can also be set in ~/.mozbuild/machrc in the [runprefs] section - see `./mach settings` for more information.')
+    @CommandArgument('--temp-profile', action='store_true', group=prog_group,
+        help='Run the program using a new temporary profile created inside the objdir.')
     @CommandArgument('--debug', action='store_true', group='debugging',
         help='Enable the debugger. Not specifying a --debugger option will result in the default debugger being used.')
     @CommandArgument('--debugger', default=None, type=str, group='debugging',
         help='Name of debugger to use.')
     @CommandArgument('--debugger-args', default=None, metavar='params', type=str,
@@ -841,17 +844,17 @@ class RunProgram(MachCommandBase):
         help='Enable DMD. The following arguments have no effect without this.')
     @CommandArgument('--mode', choices=['live', 'dark-matter', 'cumulative', 'scan'], group='DMD',
          help='Profiling mode. The default is \'dark-matter\'.')
     @CommandArgument('--stacks', choices=['partial', 'full'], group='DMD',
         help='Allocation stack trace coverage. The default is \'partial\'.')
     @CommandArgument('--show-dump-stats', action='store_true', group='DMD',
         help='Show stats when doing dumps.')
     def run(self, params, remote, background, noprofile, disable_e10s,
-        enable_crash_reporter, setpref, debug, debugger,
+        enable_crash_reporter, setpref, temp_profile, debug, debugger,
         debugger_args, dmd, mode, stacks, show_dump_stats):
         if conditions.is_android(self):
             # Running Firefox for Android is completely different
             if dmd:
                 print("DMD is not supported for Firefox for Android")
                 return 1
             from mozrunner.devices.android_device import verify_android_device, run_firefox_for_android
@@ -890,17 +893,21 @@ class RunProgram(MachCommandBase):
                    'browser.shell.checkDefaultBrowser': False,
                    'general.warnOnAboutConfig': False,
                 prefs.update([p.split('=', 1) for p in setpref])
                 for pref in prefs:
                     prefs[pref] = Preferences.cast(prefs[pref])
-                path = os.path.join(self.topobjdir, 'tmp', 'scratch_user')
+                if (temp_profile):
+                    path = tempfile.mkdtemp(dir=os.path.join(self.topobjdir, 'tmp'), prefix='profile-')
+                else:
+                    path = os.path.join(self.topobjdir, 'tmp', 'profile-default')
                 profile = Profile(path, preferences=prefs)
             if not no_profile_option_given and setpref:
                 print("setpref is only supported if a profile is not specified")
                 return 1