From 3892aa1c459f07a5355a8aa94c7ab3c5f6e5cf39 Mon Sep 17 00:00:00 2001 From: Cassidy Burden Date: Fri, 5 Aug 2016 11:00:29 -0700 Subject: binary search tool: Show how to reconstruct bisection env When bisect.py finishes, give users instructions on how to reconstruct bisection environment. This essentially gives the same setup.sh call that bisect.py uses. Change-Id: I060a4f3397e7d83d83321d25e751d6c47951436b Reviewed-on: https://chrome-internal-review.googlesource.com/273407 Commit-Ready: Cassidy Burden Tested-by: Cassidy Burden Reviewed-by: Caroline Tice --- binary_search_tool/bisect.py | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'binary_search_tool/bisect.py') diff --git a/binary_search_tool/bisect.py b/binary_search_tool/bisect.py index 6315c81c..dbe95d88 100755 --- a/binary_search_tool/bisect.py +++ b/binary_search_tool/bisect.py @@ -142,12 +142,13 @@ class BisectPackage(Bisector): 'prune': True, 'file_args': True } + self.setup_cmd = ('%s %s %s' % (self.cros_pkg_setup, self.options.board, + self.options.remote)) self.ArgOverride(self.default_kwargs, self.overrides) def PreRun(self): - cmd = ('%s %s %s' % - (self.cros_pkg_setup, self.options.board, self.options.remote)) - ret, _, _ = self.ce.RunCommandWExceptionCleanup(cmd, print_to_console=True) + ret, _, _ = self.ce.RunCommandWExceptionCleanup( + self.setup_cmd, print_to_console=True) if ret: self.logger.LogError('Package bisector setup failed w/ error %d' % ret) return 1 @@ -162,6 +163,10 @@ class BisectPackage(Bisector): if ret: self.logger.LogError('Package bisector cleanup failed w/ error %d' % ret) return 1 + + self.logger.LogOutput(('Cleanup successful! To restore the bisection ' + 'environment run the following:\n' + ' cd %s; %s') % (os.getcwd(), self.setup_cmd)) return 0 @@ -188,13 +193,15 @@ class BisectObject(Bisector): if options.dir: os.environ['BISECT_DIR'] = options.dir self.options.dir = os.environ.get('BISECT_DIR', '/tmp/sysroot_bisect') + self.setup_cmd = ('%s %s %s %s' % (self.sysroot_wrapper_setup, + self.options.board, self.options.remote, + self.options.package)) self.ArgOverride(self.default_kwargs, overrides) def PreRun(self): - cmd = ('%s %s %s %s' % (self.sysroot_wrapper_setup, self.options.board, - self.options.remote, self.options.package)) - ret, _, _ = self.ce.RunCommandWExceptionCleanup(cmd, print_to_console=True) + ret, _, _ = self.ce.RunCommandWExceptionCleanup( + self.setup_cmd, print_to_console=True) if ret: self.logger.LogError('Object bisector setup failed w/ error %d' % ret) return 1 @@ -211,6 +218,9 @@ class BisectObject(Bisector): if ret: self.logger.LogError('Object bisector cleanup failed w/ error %d' % ret) return 1 + self.logger.LogOutput(('Cleanup successful! To restore the bisection ' + 'environment run the following:\n' + ' cd %s; %s') % (os.getcwd(), self.setup_cmd)) return 0 @@ -239,17 +249,19 @@ class BisectAndroid(Bisector): os.environ['BISECT_DIR'] = options.dir self.options.dir = os.environ.get('BISECT_DIR', self.default_dir) - self.ArgOverride(self.default_kwargs, overrides) - - def PreRun(self): num_jobs = "NUM_JOBS='%s'" % self.options.num_jobs device_id = "" if self.options.device_id: device_id = "ANDROID_SERIAL='%s'" % self.options.device_id - cmd = ('%s %s %s %s' % (num_jobs, device_id, self.android_setup, - self.options.android_src)) - ret, _, _ = self.ce.RunCommandWExceptionCleanup(cmd, print_to_console=True) + self.setup_cmd = ('%s %s %s %s' % (num_jobs, device_id, self.android_setup, + self.options.android_src)) + + self.ArgOverride(self.default_kwargs, overrides) + + def PreRun(self): + ret, _, _ = self.ce.RunCommandWExceptionCleanup( + self.setup_cmd, print_to_console=True) if ret: self.logger.LogError('Android bisector setup failed w/ error %d' % ret) return 1 @@ -266,6 +278,9 @@ class BisectAndroid(Bisector): if ret: self.logger.LogError('Android bisector cleanup failed w/ error %d' % ret) return 1 + self.logger.LogOutput(('Cleanup successful! To restore the bisection ' + 'environment run the following:\n' + ' cd %s; %s') % (os.getcwd(), self.setup_cmd)) return 0 -- cgit v1.2.3