From e55f0c3384954b59ddf158c3daad4f3595c067bc Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 19 Mar 2020 16:44:08 +0900 Subject: [PATCH] Fix mb.py when using `isolate archive` This fix is the same as https://crrev.com/c/2105272 Bug: chromium:1062881 Change-Id: Idb24551f4c26100b6983611ca486c0972dca70a6 Reviewers: mbonadei@webrtc.org, tikuta@chromium.org, dpranke@chromium.org Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170960 Reviewed-by: Mirko Bonadei Commit-Queue: Ye Kuang Cr-Commit-Position: refs/heads/master@{#30826} --- tools_webrtc/mb/mb.py | 23 +++++++++++++++++++++-- tools_webrtc/mb/mb_unittest.py | 9 ++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tools_webrtc/mb/mb.py b/tools_webrtc/mb/mb.py index 82077baaae..6287ca2366 100755 --- a/tools_webrtc/mb/mb.py +++ b/tools_webrtc/mb/mb.py @@ -338,18 +338,37 @@ class MetaBuildWrapper(object): for k, v in self.args.dimensions: dimensions += ['-d', k, v] + archive_json_path = self.ToSrcRelPath( + '%s/%s.archive.json' % (build_dir, target)) cmd = [ self.PathJoin(self.src_dir, 'tools', 'luci-go', self.isolate_exe), 'archive', + '-i', + self.ToSrcRelPath('%s/%s.isolate' % (build_dir, target)), '-s', self.ToSrcRelPath('%s/%s.isolated' % (build_dir, target)), '-I', 'isolateserver.appspot.com', + '-dump-json', archive_json_path, ] - ret, out, _ = self.Run(cmd, force_verbose=False) + ret, _, _ = self.Run(cmd, force_verbose=False) if ret: return ret - isolated_hash = out.splitlines()[0].split()[0] + try: + archive_hashes = json.loads(self.ReadFile(archive_json_path)) + except Exception: + self.Print( + 'Failed to read JSON file "%s"' % archive_json_path, file=sys.stderr) + return 1 + try: + isolated_hash = archive_hashes[target] + except Exception: + self.Print( + 'Cannot find hash for "%s" in "%s", file content: %s' % + (target, archive_json_path, archive_hashes), + file=sys.stderr) + return 1 + cmd = [ self.executable, self.PathJoin('tools', 'swarming_client', 'swarming.py'), diff --git a/tools_webrtc/mb/mb_unittest.py b/tools_webrtc/mb/mb_unittest.py index afbc1acf08..c1e477c104 100755 --- a/tools_webrtc/mb/mb_unittest.py +++ b/tools_webrtc/mb/mb_unittest.py @@ -760,16 +760,11 @@ class UnitTest(unittest.TestCase): '/fake_src/out/Default/base_unittests.runtime_deps': ( "base_unittests\n" ), + 'out/Default/base_unittests.archive.json': ( + "{\"base_unittests\":\"fake_hash\"}"), } - def run_stub(cmd, **_kwargs): - if os.path.join('tools', 'luci-go', 'isolate') in cmd[0]: - return 0, 'fake_hash base_unittests', '' - else: - return 0, '', '' - mbw = self.fake_mbw(files=files) - mbw.Run = run_stub self.check(['run', '-s', '-c', 'debug_goma', '//out/Default', 'base_unittests'], mbw=mbw, ret=0) self.check(['run', '-s', '-c', 'debug_goma', '-d', 'os', 'Win7',