From 4ffb4c65825ab0a5ded00ff799b494097e7bd143 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 5 Jun 2021 23:33:44 +0200 Subject: Make svg-flatten auto-search for cargo dependencies in all call sites --- svg-flatten/src/test/svg_tests.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'svg-flatten/src/test/svg_tests.py') diff --git a/svg-flatten/src/test/svg_tests.py b/svg-flatten/src/test/svg_tests.py index f98e367..c2e5d50 100644 --- a/svg-flatten/src/test/svg_tests.py +++ b/svg-flatten/src/test/svg_tests.py @@ -39,6 +39,16 @@ def run_svg_flatten(input_file, output_file, *args, **kwargs): print(proc.stderr) raise +def run_cargo_cmd(cmd, args, **kwargs): + if cmd.upper() in os.environ: + return subprocess.run([os.environ[cmd.upper()], *args], **kwargs) + + try: + return subprocess.run([cmd, *args], **kwargs) + + except FileNotFoundError: + return subprocess.run([str(Path.home() / '.cargo' / 'bin' / cmd), *args], **kwargs) + class SVGRoundTripTests(unittest.TestCase): # Notes on test cases: @@ -131,8 +141,8 @@ class SVGRoundTripTests(unittest.TestCase): vectorizer='binary-contours') if not use_rsvg: # default! - subprocess.run(['resvg', tmp_out_svg.name, tmp_out_png.name], check=True, stdout=subprocess.DEVNULL) - subprocess.run(['resvg', test_in_svg, tmp_in_png.name], check=True, stdout=subprocess.DEVNULL) + run_cargo_cmd('resvg', [tmp_out_svg.name, tmp_out_png.name], check=True, stdout=subprocess.DEVNULL) + run_cargo_cmd('resvg', [test_in_svg, tmp_in_png.name], check=True, stdout=subprocess.DEVNULL) else: subprocess.run(['rsvg-convert', tmp_out_svg.name, '-f', 'png', '-o', tmp_out_png.name], check=True, stdout=subprocess.DEVNULL) -- cgit