#!/usr/bin/env vpython3 # Copyright 2020 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
import json import os import shutil import tempfile import unittest
def testReadAndWritePackageBlobs(self): # TODO(crbug.com/40219667): Disabled on Windows because Windows doesn't allow opening a # NamedTemporaryFile by name. if os.name == 'nt': return with tempfile.NamedTemporaryFile(mode='w') as tmp_file:
tmp_file.write(_EXAMPLE_BLOBS)
tmp_file.flush()
def testReadAndWritePackageSizes(self): # TODO(crbug.com/40219667): Disabled on Windows because Windows doesn't allow opening a # NamedTemporaryFile by name. if os.name == 'nt': return with tempfile.NamedTemporaryFile(mode='w') as tmp_file:
tmp_file.write(_EXAMPLE_BLOBS)
tmp_file.flush()
blobs = binary_sizes.ReadPackageBlobsJson(tmp_file.name)
sizes = binary_sizes.GetPackageSizes(blobs)
new_sizes = {} with tempfile.NamedTemporaryFile(mode='w') as tmp_file:
binary_sizes.WritePackageSizesJson(tmp_file.name, sizes)
new_sizes = binary_sizes.ReadPackageSizesJson(tmp_file.name)
self.assertEqual(new_sizes, sizes)
self.assertIn('web_engine', new_sizes)
def testGetPackageSizesUsesBlobMerklesForCount(self): # TODO(crbug.com/40219667): Disabled on Windows because Windows doesn't allow opening a # NamedTemporaryFile by name. if os.name == 'nt': return
blobs = json.loads(_EXAMPLE_BLOBS)
# Make a duplicate of the last blob.
last_blob = dict(blobs['web_engine'][-1])
blobs['cast_runner'] = []
last_blob['path'] = 'foo'# Give a non-sense name, but keep merkle.
# If the merkle is the same, the blob_count increases by 1. # This effectively reduces the size of the blobs size by half. # In both packages, despite it appearing in both and under different # names.
blobs['cast_runner'].append(last_blob)
with tempfile.NamedTemporaryFile(mode='w') as tmp_file:
tmp_file.write(json.dumps(blobs))
tmp_file.flush()
blobs = binary_sizes.ReadPackageBlobsJson(tmp_file.name)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.