diff options
| author | eunhhu <[email protected]> | 2026-09-28 16:31:53 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-28 16:31:53 +0100 |
| commit | 30a730c54298f6abafc622045cc2e6542126f735 (patch) | |
| tree | 85114105e3b5d10e4ed90976045e20b339b05990 /text | |
| parent | d6974ee04d553b5ad4862cf27340adab4c9e3a02 (diff) | |
| download | vega-30a730c54298f6abafc622045cc2e6542126f735.tar.gz vega-30a730c54298f6abafc622045cc2e6542126f735.zip | |
Leave a generated file as it was when its generator fails
Run against HarfBuzz 14.5.0 and Unicode 18.0.0, text/unicode.py met a
line breaking class it does not know (HH) and text/syllabic.py a table
laid out otherwise, and the tool had already emptied both files. A
generator's output now replaces its file only when it succeeds, and the
tool stops before building when one fails: those are what to port first.
Diffstat (limited to 'text')
| -rw-r--r-- | text/upstream.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/text/upstream.py b/text/upstream.py index ec0e18b..0cf1d98 100644 --- a/text/upstream.py +++ b/text/upstream.py @@ -90,9 +90,9 @@ def run(name, command, results, **kwargs): print(f'== {name}', file=sys.stderr) done = subprocess.run(command, capture_output=True, text=True, cwd=ROOT, **kwargs) sys.stderr.write(done.stderr[-4000:]) - reports = [json.loads(line) for line in done.stdout.splitlines() if line.startswith('{')] + reports = [json.loads(line) for line in done.stdout.splitlines() if line.startswith('{"')] results[name] = {'passed': done.returncode == 0, **({'report': reports} if reports else {})} - if done.returncode: + if done.returncode and not name.endswith('.py'): sys.stderr.write(done.stdout[-4000:]) return done @@ -114,13 +114,17 @@ def main(): results = {} generated = ['text/unicode-data.c', 'text/syllabic-data.c'] - with open(ROOT / 'text' / 'unicode-data.c', 'w') as out: - results['unicode.py'] = {'passed': subprocess.run([sys.executable, 'text/unicode.py', str(database)], - stdout=out, cwd=ROOT).returncode == 0} - with open(ROOT / 'text' / 'syllabic-data.c', 'w') as out: - results['syllabic.py'] = {'passed': subprocess.run([sys.executable, 'text/syllabic.py', str(source / 'src')], - stdout=out, cwd=ROOT).returncode == 0} + for name, target, given in (('unicode.py', 'unicode-data.c', database), ('syllabic.py', 'syllabic-data.c', + source / 'src')): + # a generator that fails leaves its file as it was + made = run(name, [sys.executable, f'text/{name}', str(given)], results) + if not made.returncode: + (ROOT / 'text' / target).write_text(made.stdout) run('syllabic.py --check', [sys.executable, 'text/syllabic.py', str(source / 'src'), '--check'], results) + if not all(r['passed'] for r in results.values()): + # the generators do not follow this version yet: what to port first + print(json.dumps({'harfbuzz': version, 'unicode': unicode, 'checks': results})) + return 1 build = UPSTREAM / 'build' flags = [f'BUILD={build}', f'HARFBUZZ_CFLAGS=-I{source / "src"}', |
