Bug 1300163 - Lazy load certain mach context attributes using the 'key' mechanism, r=armenzg
You can set attributes on a mach context by using the 'key' argument to the context_handler. Basically, whatever gets returned by the handler when <key> is passed in, will get set (i.e cached) on the context object for fast retrieval next time. This is a way to lazy load these attributes. Previously I was setting functions like 'find_firefox()' on the context object, and then having the mach_commands call that directly. But this way is much cleaner. Now, the loaded 'mozharness_config' can be stored as an attribute on the context. Also 'find_firefox()' is now an attribute called 'firefox_bin'. MozReview-Commit-ID: 4lsKGpizfH7
This commit is contained in:
@@ -21,12 +21,10 @@ from mach.decorators import (
|
||||
|
||||
def run_xpcshell(context, **kwargs):
|
||||
args = Namespace(**kwargs)
|
||||
args.appPath = args.appPath or os.path.dirname(context.firefox_bin)
|
||||
args.utility_path = context.bin_dir
|
||||
args.testingModulesDir = context.modules_dir
|
||||
|
||||
if not args.appPath:
|
||||
args.appPath = os.path.dirname(context.find_firefox())
|
||||
|
||||
if not args.xpcshell:
|
||||
args.xpcshell = os.path.join(args.appPath, 'xpcshell')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user