Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/zip_bundle.gni
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ template("zip_bundle") {
args += [
"-i",
rebase_path(input.source),
rebase_path(input.destination),
input.destination,
]
sources += [ input.source ]
}
Expand Down
19 changes: 17 additions & 2 deletions tools/font-subset/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import subprocess
import sys
from zipfile import ZipFile

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, '..', '..', '..'))
Expand All @@ -20,8 +21,10 @@
EXE = '.exe' if IS_WINDOWS else ''
BAT = '.bat' if IS_WINDOWS else ''
FONT_SUBSET = os.path.join(SRC_DIR, 'out', 'host_debug', 'font-subset' + EXE)
FONT_SUBSET_ZIP = os.path.join(SRC_DIR, 'out', 'host_debug', 'zip_archives', 'font-subset.zip')
if not os.path.isfile(FONT_SUBSET):
FONT_SUBSET = os.path.join(SRC_DIR, 'out', 'host_debug_unopt', 'font-subset' + EXE)
FONT_SUBSET_ZIP = os.path.join(SRC_DIR, 'out', 'host_debug_unopt', 'zip_archives', 'font-subset.zip')
if not os.path.isfile(FONT_SUBSET):
raise Exception('Could not locate font-subset%s in host_debug or host_debug_unopt - build before running this script.' % EXE)

Expand Down Expand Up @@ -58,7 +61,7 @@ def RunCmd(cmd, codepoints, fail=False):
stderr=subprocess.PIPE,
cwd=SRC_DIR
)
stdout_data, stderr_data = p.communicate(input=' '.join(codepoints))
stdout_data, stderr_data = p.communicate(input=' '.join(codepoints).encode())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.encode is needed for python3.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also pass universal_newlines=True to subprocess.Popen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to .encode, or instead of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see instead of it.

if p.returncode != 0 and fail == False:
print('FAILURE: %s' % p.returncode)
print('STDOUT:')
Expand All @@ -77,9 +80,21 @@ def RunCmd(cmd, codepoints, fail=False):
return p.returncode


def TestZip():
with ZipFile(FONT_SUBSET_ZIP, 'r') as zip:
files = zip.namelist()
if 'font-subset%s' % EXE not in files:
print('expected %s to contain font-subset%s' % (files, EXE))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if it got inserted into the zip as Users/me/src/flutter/engine/src/flutter/tools/font-subset instead of just font-subset.

return 1
return 0


def main():
print('Using font subset binary at %s' % FONT_SUBSET)
print('Using font subset binary at %s (%s)' % (FONT_SUBSET, FONT_SUBSET_ZIP))
failures = 0

failures += TestZip()

for should_pass, golden_font, input_font, codepoints in COMPARE_TESTS:
gen_ttf = os.path.join(SCRIPT_DIR, 'gen', golden_font)
golden_ttf = os.path.join(SCRIPT_DIR, 'fixtures', golden_font)
Expand Down