Skip to content

Commit 008c0ab

Browse files
author
Simon Inns
committed
Fix the failing CI/CD after the scripts were moved
1 parent 5d191a8 commit 008c0ab

2 files changed

Lines changed: 82 additions & 10 deletions

File tree

scripts/test-chroma

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@
3333

3434
import argparse
3535
import os
36+
import shutil
3637
import statistics
3738
import subprocess
3839
import sys
3940

4041
build_dir = None
4142

43+
def resolve_tool(*candidates):
44+
for path in candidates:
45+
if os.path.exists(path):
46+
return path
47+
return candidates[0]
48+
4249
def safe_unlink(filename):
4350
"""Remove a file if it exists; if not, do nothing."""
4451

@@ -97,7 +104,10 @@ def test_encode(args, source, sc_locked, png_suffix):
97104

98105
# Encode the .rgb to .tbc, using ld-chroma-encoder
99106
tbc_file = args.output + '.tbc'
100-
cmd = [build_dir + '/src/ld-chroma-decoder/encoder/ld-chroma-encoder']
107+
cmd = [resolve_tool(
108+
os.path.join(build_dir, 'bin', 'ld-chroma-encoder'),
109+
os.path.join(build_dir, 'src', 'ld-chroma-decoder', 'encoder', 'ld-chroma-encoder'),
110+
)]
101111
cmd += ['--input-format', args.input_format]
102112
if sc_locked:
103113
cmd += ['--sc-locked']
@@ -131,7 +141,10 @@ def test_decode(args, decoder, phase_locked, output_format, png_suffix):
131141
# Decode the .tbc using ld-chroma-decoder
132142
tbc_file = args.output + '.tbc'
133143
decoded_file = args.output + '.decoded'
134-
cmd = [build_dir + '/src/ld-chroma-decoder/ld-chroma-decoder',
144+
cmd = [resolve_tool(
145+
os.path.join(build_dir, 'bin', 'ld-chroma-decoder'),
146+
os.path.join(build_dir, 'src', 'ld-chroma-decoder', 'ld-chroma-decoder'),
147+
),
135148
'--quiet',
136149
'-f', decoder,
137150
'--chroma-nr', '0',
@@ -218,6 +231,17 @@ def main():
218231
if args.build:
219232
build_dir = args.build
220233

234+
if shutil.which('ffmpeg') is None:
235+
print('SKIP: ffmpeg not found in PATH')
236+
sys.exit(77)
237+
238+
encoder_path = os.path.join(build_dir, 'src', 'ld-chroma-decoder', 'encoder', 'ld-chroma-encoder')
239+
decoder_path = os.path.join(build_dir, 'src', 'ld-chroma-decoder', 'ld-chroma-decoder')
240+
missing = [path for path in (encoder_path, decoder_path) if not os.path.exists(path)]
241+
if missing:
242+
print('SKIP: required tool(s) not built:', ', '.join(missing))
243+
sys.exit(77)
244+
221245
# Remove display environment variables, as the decoding tools shouldn't
222246
# depend on having a display
223247
for var in ('DISPLAY', 'WAYLAND_DISPLAY'):

scripts/test-decode-pretbc

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ dry_run = False
3636
source_dir = None
3737
build_dir = None
3838

39+
def resolve_tool(*candidates):
40+
for path in candidates:
41+
if os.path.exists(path):
42+
return path
43+
return candidates[0]
44+
3945
def die(*args):
4046
"""Print an error message and exit."""
4147
print(*args, file=sys.stderr)
@@ -101,7 +107,10 @@ def run_ld_process_vbi(args):
101107

102108
clean(args, ['.tbc.json.bup', '.tbc.db.bup'])
103109

104-
cmd = [build_dir + '/src/ld-process-vbi/ld-process-vbi']
110+
cmd = [resolve_tool(
111+
os.path.join(build_dir, 'bin', 'ld-process-vbi'),
112+
os.path.join(build_dir, 'src', 'ld-process-vbi', 'ld-process-vbi'),
113+
)]
105114
cmd += [args.output + '.tbc']
106115
run_command(cmd)
107116

@@ -180,7 +189,10 @@ def run_ld_export_metadata(args):
180189

181190
clean(args, ['.vits.csv', '.vbi.csv', '.ffmetadata'])
182191

183-
cmd = [build_dir + '/src/ld-export-metadata/ld-export-metadata']
192+
cmd = [resolve_tool(
193+
os.path.join(build_dir, 'bin', 'ld-export-metadata'),
194+
os.path.join(build_dir, 'src', 'ld-export-metadata', 'ld-export-metadata'),
195+
)]
184196
cmd += ['--vits-csv', args.output + '.vits.csv']
185197
cmd += ['--vbi-csv', args.output + '.vbi.csv']
186198
cmd += ['--ffmetadata', args.output + '.ffmetadata']
@@ -200,7 +212,10 @@ def run_ld_export_decode_metadata(args):
200212

201213
clean(args, ['.tbc.export.json'])
202214

203-
cmd = [build_dir + '/src/ld-export-decode-metadata/ld-export-decode-metadata']
215+
cmd = [resolve_tool(
216+
os.path.join(build_dir, 'bin', 'ld-export-decode-metadata'),
217+
os.path.join(build_dir, 'src', 'ld-export-decode-metadata', 'ld-export-decode-metadata'),
218+
)]
204219
cmd += ['--input-sqlite', db_file]
205220
run_command(cmd)
206221

@@ -318,19 +333,28 @@ def run_efm_decoder(args):
318333
die(efm_file, 'is empty')
319334

320335
# Run efm-decoder-f2 (EFM T-values to F2 Section)
321-
cmd = [build_dir + '/src/efm-decoder/tools/efm-decoder-f2/efm-decoder-f2']
336+
cmd = [resolve_tool(
337+
os.path.join(build_dir, 'bin', 'efm-decoder-f2'),
338+
os.path.join(build_dir, 'src', 'efm-decoder', 'tools', 'efm-decoder-f2', 'efm-decoder-f2'),
339+
)]
322340
if args.no_efm_timecodes:
323341
cmd += ['--no-timecodes']
324342
cmd += [efm_file, f2_file]
325343
run_command(cmd)
326344

327345
# Run efm-decoder-d24 (F2 Section to Data24 Section)
328-
cmd = [build_dir + '/src/efm-decoder/tools/efm-decoder-d24/efm-decoder-d24']
346+
cmd = [resolve_tool(
347+
os.path.join(build_dir, 'bin', 'efm-decoder-d24'),
348+
os.path.join(build_dir, 'src', 'efm-decoder', 'tools', 'efm-decoder-d24', 'efm-decoder-d24'),
349+
)]
329350
cmd += [f2_file, d24_file]
330351
run_command(cmd)
331352

332353
# Run efm-decoder-audio (Data24 to Audio WAV)
333-
cmd = [build_dir + '/src/efm-decoder/tools/efm-decoder-audio/efm-decoder-audio']
354+
cmd = [resolve_tool(
355+
os.path.join(build_dir, 'bin', 'efm-decoder-audio'),
356+
os.path.join(build_dir, 'src', 'efm-decoder', 'tools', 'efm-decoder-audio', 'efm-decoder-audio'),
357+
)]
334358
cmd += [d24_file, wav_file]
335359
run_command(cmd)
336360

@@ -352,7 +376,10 @@ def run_ld_dropout_correct(args):
352376

353377
clean(args, ['.doc.tbc', '.doc.tbc.db'])
354378

355-
cmd = [build_dir + '/src/ld-dropout-correct/ld-dropout-correct']
379+
cmd = [resolve_tool(
380+
os.path.join(build_dir, 'bin', 'ld-dropout-correct'),
381+
os.path.join(build_dir, 'src', 'ld-dropout-correct', 'ld-dropout-correct'),
382+
)]
356383
cmd += ['--overcorrect', args.output + '.tbc', args.output + '.doc.tbc']
357384
run_command(cmd)
358385

@@ -362,7 +389,10 @@ def run_ld_chroma_decoder(args, decoder):
362389
clean(args, ['.rgb'])
363390
rgb_file = args.output + '.rgb'
364391

365-
cmd = [build_dir + '/src/ld-chroma-decoder/ld-chroma-decoder']
392+
cmd = [resolve_tool(
393+
os.path.join(build_dir, 'bin', 'ld-chroma-decoder'),
394+
os.path.join(build_dir, 'src', 'ld-chroma-decoder', 'ld-chroma-decoder'),
395+
)]
366396
if decoder is not None:
367397
cmd += ['--decoder', decoder]
368398
cmd += [args.output + '.doc.tbc', rgb_file]
@@ -447,6 +477,24 @@ def main():
447477
build_dir = args.build
448478
source_dir = build_dir
449479

480+
required_tools = [
481+
os.path.join(build_dir, 'src', 'ld-process-vbi', 'ld-process-vbi'),
482+
os.path.join(build_dir, 'src', 'ld-export-metadata', 'ld-export-metadata'),
483+
os.path.join(build_dir, 'src', 'ld-export-decode-metadata', 'ld-export-decode-metadata'),
484+
os.path.join(build_dir, 'src', 'ld-dropout-correct', 'ld-dropout-correct'),
485+
os.path.join(build_dir, 'src', 'ld-chroma-decoder', 'ld-chroma-decoder'),
486+
]
487+
if not args.no_efm:
488+
required_tools += [
489+
os.path.join(build_dir, 'src', 'efm-decoder', 'tools', 'efm-decoder-f2', 'efm-decoder-f2'),
490+
os.path.join(build_dir, 'src', 'efm-decoder', 'tools', 'efm-decoder-d24', 'efm-decoder-d24'),
491+
os.path.join(build_dir, 'src', 'efm-decoder', 'tools', 'efm-decoder-audio', 'efm-decoder-audio'),
492+
]
493+
missing = [path for path in required_tools if not os.path.exists(path)]
494+
if missing:
495+
print('SKIP: required tool(s) not built:', ', '.join(missing), file=sys.stderr)
496+
sys.exit(77)
497+
450498
print('Processing', args.pretbc_input, 'using tools from', build_dir, file=sys.stderr)
451499

452500
# Remove display environment variables, as the decoding tools shouldn't

0 commit comments

Comments
 (0)