mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 14:05:57 +00:00
Merge pull request #346: Let the installer extract the Switch shared fonts from a firmware folder (fch869)
Conflicts with dev resolved by keeping both sides: the fonts step sits between check and extract, beside the x86-64-v2 check, the pt-BR window language and the xbox-label patches. pt-BR gets the thirteen firmware and fonts texts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
4cece2c848
15 files changed
+395
-60
No files matched your search
+25
-10
@@ -30,7 +30,7 @@ from installer import layout as layouts # noqa: E402
|
||||
from installer import state as statefile # noqa: E402
|
||||
from installer.events import Reporter # noqa: E402
|
||||
from installer.runner import Context # noqa: E402
|
||||
from installer.steps import all_steps # noqa: E402
|
||||
from installer.steps import Fonts, all_steps # noqa: E402
|
||||
from installer.guilogic import (DONE, FAILED, PENDING, RUNNING, SKIPPED, UI_LANGUAGES, Catalog, Form, Model, # noqa: E402
|
||||
Process, amount, describe_event, parse_line, windows_ui_language)
|
||||
|
||||
@@ -38,7 +38,7 @@ INSTALLED = ROOT / 'build' / 'install-test'
|
||||
FIXTURE = ROOT / 'build' / 'inst-gui' / 'e2e-install'
|
||||
COPIED = ('totk.ini', statefile.NAME) # written by a run, so never linked
|
||||
START = {'type': 'start', 'release': 'r1', 'mode': 'install', 'dest': 'D:\\T', 'log': 'D:\\T.log',
|
||||
'steps': ['check', 'extract', 'lift', 'compile', 'prepare', 'cleanup']}
|
||||
'steps': ['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'cleanup']}
|
||||
|
||||
|
||||
def fold(*events):
|
||||
@@ -66,7 +66,7 @@ class ModelTest(unittest.TestCase):
|
||||
m = fold(START, {'type': 'plan', 'run': ['check', 'extract'], 'skip': {'lift': 'current', 'compile': 'current'}},
|
||||
{'type': 'step', 'step': 'check', 'state': 'started'})
|
||||
self.assertEqual([m.states[s] for s in m.steps],
|
||||
[RUNNING, PENDING, SKIPPED, SKIPPED, PENDING, PENDING])
|
||||
[RUNNING, PENDING, PENDING, SKIPPED, SKIPPED, PENDING, PENDING])
|
||||
self.assertEqual(m.current, 'check')
|
||||
m.apply({'type': 'step', 'step': 'check', 'state': 'done', 'seconds': 1.0})
|
||||
self.assertEqual(m.states['check'], DONE)
|
||||
@@ -137,10 +137,12 @@ class ModelTest(unittest.TestCase):
|
||||
|
||||
|
||||
class RunStatesTest(unittest.TestCase):
|
||||
OK = [START, {'type': 'plan', 'run': ['check', 'extract'], 'skip': {'lift': 'current', 'compile': 'current',
|
||||
'prepare': 'current', 'cleanup': 'not_needed'}},
|
||||
OK = [START, {'type': 'plan', 'run': ['check', 'extract'], 'skip': {'fonts': 'current', 'lift': 'current',
|
||||
'compile': 'current', 'prepare': 'current',
|
||||
'cleanup': 'not_needed'}},
|
||||
{'type': 'step', 'step': 'check', 'state': 'started'}, {'type': 'step', 'step': 'check', 'state': 'done'},
|
||||
{'type': 'step', 'step': 'extract', 'state': 'started'}, {'type': 'step', 'step': 'extract', 'state': 'done'},
|
||||
{'type': 'step', 'step': 'fonts', 'state': 'skipped'},
|
||||
{'type': 'step', 'step': 'lift', 'state': 'skipped'}, {'type': 'step', 'step': 'compile', 'state': 'skipped'},
|
||||
{'type': 'step', 'step': 'prepare', 'state': 'skipped'}, {'type': 'step', 'step': 'cleanup', 'state': 'done'},
|
||||
{'type': 'end', 'result': 'ok', 'seconds': 1}]
|
||||
@@ -200,11 +202,20 @@ class FormTest(unittest.TestCase):
|
||||
def test_unknown_language(self):
|
||||
self.assertEqual(self.form(lang='xx').problems(), ['ui.need_lang'])
|
||||
|
||||
def test_firmware_folder(self):
|
||||
firmware = self.dir / 'firmware'
|
||||
firmware.mkdir()
|
||||
self.assertEqual(self.form(firmware=str(firmware)).problems(), [])
|
||||
self.assertEqual(self.form(firmware=str(self.dir / 'no-firmware')).problems(), ['ui.missing_firmware'])
|
||||
|
||||
def test_command(self):
|
||||
cmd = self.form().command('py.exe', root=ROOT, temp=self.dir / 't', verify=True)
|
||||
firmware = self.dir / 'firmware'
|
||||
firmware.mkdir()
|
||||
cmd = self.form(firmware=str(firmware)).command('py.exe', root=ROOT, temp=self.dir / 't', verify_hashes=True)
|
||||
self.assertEqual(cmd[:3], ['py.exe', '-m', 'installer'])
|
||||
for flag in ('--base', '--update', '--keys', '--lang', '--dest', '--root', '--temp', '--verify'):
|
||||
for flag in ('--base', '--update', '--keys', '--firmware', '--lang', '--dest', '--root', '--temp', '--verify'):
|
||||
self.assertIn(flag, cmd)
|
||||
self.assertEqual(cmd[cmd.index('--firmware') + 1], str(firmware))
|
||||
self.assertEqual(cmd[cmd.index('--lang') + 1], 'en-US')
|
||||
|
||||
def test_installed_folder_needs_only_itself(self):
|
||||
@@ -248,7 +259,7 @@ class CatalogTest(unittest.TestCase):
|
||||
cat = Catalog('en')
|
||||
ids = ['ui.' + n for n in ('title', 'start', 'cancel', 'open_folder', 'notice', 'space_one', 'space_two',
|
||||
'process_died', 'result_ok', 'result_failed', 'result_cancelled')]
|
||||
ids += [f'step.{s}' for s in ('check', 'extract', 'lift', 'compile', 'prepare', 'cleanup')]
|
||||
ids += [f'step.{s}' for s in ('check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'cleanup')]
|
||||
ids += ['ui.state_' + n for n in ('started', 'done', 'skipped', 'pending', 'running', 'failed')]
|
||||
for lang in UI_LANGUAGES:
|
||||
cat.set_language(lang)
|
||||
@@ -338,6 +349,10 @@ def make_fixture():
|
||||
ctx = Context(layout, FIXTURE, ROOT / 'build' / 'inst-gui' / 'e2e-temp', Reporter(out=io.StringIO()), options, state=state)
|
||||
ctx.steps = all_steps()
|
||||
ctx.plan()
|
||||
# An install made before the fonts step has no record for it: record it as current when its output is (the
|
||||
# languages that need the fonts have them in shared-fonts/).
|
||||
if Fonts().current(ctx, {}):
|
||||
state['steps'].setdefault('fonts', {'release': state.get('release', ''), 'key': ctx.keys['fonts']})
|
||||
for step_id, record in state['steps'].items():
|
||||
record['key'] = ctx.keys[step_id]
|
||||
statefile.save(FIXTURE, state)
|
||||
@@ -350,7 +365,7 @@ class EndToEndTest(unittest.TestCase):
|
||||
def run_cli(form, temp, tries=1):
|
||||
"""Runs the CLI in --verify mode through Process, up to `tries` times while the RomFS hash reads wrong."""
|
||||
for attempt in range(tries):
|
||||
p = Process(form.command(sys.executable, root=ROOT, temp=temp, verify=True), cwd=ROOT)
|
||||
p = Process(form.command(sys.executable, root=ROOT, temp=temp, verify_hashes=True), cwd=ROOT)
|
||||
model, stray = Model(), []
|
||||
t0, code = time.monotonic(), None
|
||||
while code is None and time.monotonic() - t0 < 600:
|
||||
@@ -388,7 +403,7 @@ class EndToEndTest(unittest.TestCase):
|
||||
|
||||
def test_cancel_during_the_check(self):
|
||||
cmd = Form(dest=str(make_fixture())).command(sys.executable, root=ROOT, temp=ROOT / 'build' / 'inst-gui' / 'e2e-temp',
|
||||
verify=True)
|
||||
verify_hashes=True)
|
||||
p = Process(cmd, cwd=ROOT)
|
||||
model, t0, code, cancelled = Model(), time.monotonic(), None, False
|
||||
while code is None and time.monotonic() - t0 < 120:
|
||||
|
||||
Reference in new issue
Block a user