diff --git a/ci/builders/mac_unopt.json b/ci/builders/mac_unopt.json index dc6f18b3a88df..c6674574489ec 100644 --- a/ci/builders/mac_unopt.json +++ b/ci/builders/mac_unopt.json @@ -142,7 +142,21 @@ "$flutter/osx_sdk": { "sdk_version": "15a240d" } - } + }, + "tests": [ + { + "language": "python3", + "name": "Host Tests for host_debug_unopt_arm64", + "script": "flutter/testing/run_tests.py", + "parameters": [ + "--variant", + "host_debug_unopt_arm64", + "--type", + "dart,dart-host,engine", + "--engine-capture-core-dump" + ] + } + ] }, { "properties": { diff --git a/shell/platform/embedder/tests/embedder_unittests.cc b/shell/platform/embedder/tests/embedder_unittests.cc index 23f30fdc44705..319127f394693 100644 --- a/shell/platform/embedder/tests/embedder_unittests.cc +++ b/shell/platform/embedder/tests/embedder_unittests.cc @@ -646,6 +646,14 @@ TEST_F(EmbedderTest, VMAndIsolateSnapshotSizesAreRedundantInAOTMode) { /// TEST_F(EmbedderTest, CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor) { + // TODO(143940): Convert this test to use SkiaGold. +#if FML_OS_MACOSX && FML_ARCH_CPU_ARM64 + { + GTEST_SKIP() << "Skipping golen test on arm64 macOS"; + return; + } +#endif // FML_OS_MACOSX && FML_ARCH_CPU_ARM64 + auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext); EmbedderConfigBuilder builder(context); diff --git a/testing/run_tests.py b/testing/run_tests.py index 966a02778e34d..8fd19bafd3dab 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -1260,7 +1260,10 @@ def main(): variants_to_skip = ['host_release', 'host_profile'] if ('engine' in types or 'font-subset' in types) and args.variant not in variants_to_skip: - run_cmd(['python3', 'test.py'], cwd=FONT_SUBSET_DIR) + cmd = ['python3', 'test.py', '--variant', args.variant] + if 'arm64' in args.variant: + cmd += ['--target-cpu', 'arm64'] + run_cmd(cmd, cwd=FONT_SUBSET_DIR) if 'impeller-golden' in types: run_impeller_golden_tests(build_dir) diff --git a/tools/font_subset/test.py b/tools/font_subset/test.py index d9f74fb3d6c2c..fceda3af8208e 100755 --- a/tools/font_subset/test.py +++ b/tools/font_subset/test.py @@ -8,46 +8,17 @@ Tests for font-subset ''' +import argparse import filecmp import os import subprocess import sys from zipfile import ZipFile -# Dictionary to map the platform name to the output directory -# of the font artifacts. -PLATFORM_2_PATH = { - 'darwin': 'darwin-x64', - 'linux': 'linux-x64', - 'linux2': 'linux-x64', - 'cygwin': 'windows-x64', - 'win': 'windows-x64', - 'win32': 'windows-x64', -} - SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, '..', '..', '..')) MATERIAL_TTF = os.path.join(SCRIPT_DIR, 'fixtures', 'MaterialIcons-Regular.ttf') VARIABLE_MATERIAL_TTF = os.path.join(SCRIPT_DIR, 'fixtures', 'MaterialSymbols-Variable.ttf') -IS_WINDOWS = sys.platform.startswith(('cygwin', 'win')) -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', PLATFORM_2_PATH.get(sys.platform, ''), - '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', PLATFORM_2_PATH.get(sys.platform, ''), - '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 - ) COMPARE_TESTS = ( (True, '1.ttf', MATERIAL_TTF, [r'57347']), @@ -91,59 +62,61 @@ ]), ) -FAIL_TESTS = [ - ([FONT_SUBSET, 'output.ttf', 'does-not-exist.ttf'], [ - '1', - ]), # non-existent input font - ([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [ - '0xFFFFFFFF', - ]), # Value too big. - ([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [ - '-1', - ]), # invalid value - ([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [ - 'foo', - ]), # no valid values - ([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [ - '0xE003', - '0x12', - '0xE004', - ]), # codepoint not in font - ([FONT_SUBSET, 'non-existent-dir/output.ttf', MATERIAL_TTF], [ - '0xE003', - ]), # dir doesn't exist - ([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], [ - ' ', - ]), # empty input - ([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], []), # empty input - ([FONT_SUBSET, 'output.ttf', MATERIAL_TTF], ['']), # empty input - # repeat tests with variable input font - ([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [ - '0xFFFFFFFF', - ]), # Value too big. - ([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [ - '-1', - ]), # invalid value - ([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [ - 'foo', - ]), # no valid values - ([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [ - '0xE003', - '0x12', - '0xE004', - ]), # codepoint not in font - ([FONT_SUBSET, 'non-existent-dir/output.ttf', VARIABLE_MATERIAL_TTF], [ - '0xE003', - ]), # dir doesn't exist - ([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], [ - ' ', - ]), # empty input - ([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], []), # empty input - ([FONT_SUBSET, 'output.ttf', VARIABLE_MATERIAL_TTF], ['']), # empty input -] - - -def RunCmd(cmd, codepoints, fail=False): + +def fail_tests(font_subset): + return [ + ([font_subset, 'output.ttf', 'does-not-exist.ttf'], [ + '1', + ]), # non-existent input font + ([font_subset, 'output.ttf', MATERIAL_TTF], [ + '0xFFFFFFFF', + ]), # Value too big. + ([font_subset, 'output.ttf', MATERIAL_TTF], [ + '-1', + ]), # invalid value + ([font_subset, 'output.ttf', MATERIAL_TTF], [ + 'foo', + ]), # no valid values + ([font_subset, 'output.ttf', MATERIAL_TTF], [ + '0xE003', + '0x12', + '0xE004', + ]), # codepoint not in font + ([font_subset, 'non-existent-dir/output.ttf', MATERIAL_TTF], [ + '0xE003', + ]), # dir doesn't exist + ([font_subset, 'output.ttf', MATERIAL_TTF], [ + ' ', + ]), # empty input + ([font_subset, 'output.ttf', MATERIAL_TTF], []), # empty input + ([font_subset, 'output.ttf', MATERIAL_TTF], ['']), # empty input + # repeat tests with variable input font + ([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [ + '0xFFFFFFFF', + ]), # Value too big. + ([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [ + '-1', + ]), # invalid value + ([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [ + 'foo', + ]), # no valid values + ([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [ + '0xE003', + '0x12', + '0xE004', + ]), # codepoint not in font + ([font_subset, 'non-existent-dir/output.ttf', VARIABLE_MATERIAL_TTF], [ + '0xE003', + ]), # dir doesn't exist + ([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], [ + ' ', + ]), # empty input + ([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], []), # empty input + ([font_subset, 'output.ttf', VARIABLE_MATERIAL_TTF], ['']), # empty input + ] + + +def run_cmd(cmd, codepoints, fail=False): print('Running command:') print(' %s' % ' '.join(cmd)) print('STDIN: "%s"' % ' '.join(codepoints)) @@ -169,34 +142,66 @@ def RunCmd(cmd, codepoints, fail=False): return p.returncode -def TestZip(): - with ZipFile(FONT_SUBSET_ZIP, 'r') as zip: +def test_zip(font_subset_zip, exe): + 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)) + if 'font-subset%s' % exe not in files: + print('expected %s to contain font-subset%s' % (files, exe)) return 1 return 0 +# Maps the platform name to the output directory of the font artifacts. +def platform_to_path(os, cpu): + d = { + 'darwin': 'darwin-', + 'linux': 'linux-', + 'linux2': 'linux-', + 'cygwin': 'windows-', + 'win': 'windows-', + 'win32': 'windows-', + } + return d[os] + cpu + + def main(): - print('Using font subset binary at %s (%s)' % (FONT_SUBSET, FONT_SUBSET_ZIP)) + parser = argparse.ArgumentParser(description='Runs font-subset tests.') + parser.add_argument('--variant', type=str, required=True) + parser.add_argument('--target-cpu', type=str, default='x64') + args = parser.parse_args() + variant = args.variant + + is_windows = sys.platform.startswith(('cygwin', 'win')) + exe = '.exe' if is_windows else '' + font_subset = os.path.join(SRC_DIR, 'out', variant, 'font-subset' + exe) + font_subset_zip = os.path.join( + SRC_DIR, 'out', variant, 'zip_archives', platform_to_path(sys.platform, args.target_cpu), + '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 + ) + + print('Using font subset binary at %s (%s)' % (font_subset, font_subset_zip)) failures = 0 - failures += TestZip() + failures += test_zip(font_subset_zip, exe) 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) - cmd = [FONT_SUBSET, gen_ttf, input_font] - RunCmd(cmd, codepoints) + cmd = [font_subset, gen_ttf, input_font] + run_cmd(cmd, codepoints) cmp = filecmp.cmp(gen_ttf, golden_ttf, shallow=False) if (should_pass and not cmp) or (not should_pass and cmp): print('Test case %s failed.' % cmd) failures += 1 with open(os.devnull, 'w') as devnull: - for cmd, codepoints in FAIL_TESTS: - if RunCmd(cmd, codepoints, fail=True) == 0: + for cmd, codepoints in fail_tests(font_subset): + if run_cmd(cmd, codepoints, fail=True) == 0: failures += 1 if failures > 0: