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 <mbonadei@webrtc.org>
Commit-Queue: Ye Kuang <yekuang@google.com>
Cr-Commit-Position: refs/heads/master@{#30826}
This commit is contained in:
Ye Kuang
2020-03-19 16:44:08 +09:00
committed by Commit Bot
parent 93bcaae445
commit e55f0c3384
2 changed files with 23 additions and 9 deletions

View File

@ -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'),

View File

@ -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',