diff options
Diffstat (limited to 'gerbonara/tests')
-rw-r--r-- | gerbonara/tests/image_support.py | 9 | ||||
-rw-r--r-- | gerbonara/tests/test_kicad_footprints.py | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/gerbonara/tests/image_support.py b/gerbonara/tests/image_support.py index 9902863..64f59ea 100644 --- a/gerbonara/tests/image_support.py +++ b/gerbonara/tests/image_support.py @@ -23,6 +23,7 @@ from pathlib import Path import tempfile import textwrap import os +import stat from functools import total_ordering import shutil import bs4 @@ -156,10 +157,14 @@ def kicad_fp_export(mod_file, out_svg): print(f'Building cache for {mod_file.name}') with tempfile.TemporaryDirectory() as tmpdir: + os.chmod(tmpdir, 0o1777) pretty_dir = mod_file.parent fp_name = mod_file.name[:-len('.kicad_mod')] - cmd = ['kicad-cli', 'fp', 'export', 'svg', '--output', tmpdir, '--footprint', fp_name, pretty_dir] - subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + cmd = ['podman', 'run', '--mount', f'type=bind,src={pretty_dir},dst=/{pretty_dir.name}', + '--mount', f'type=bind,src={tmpdir},dst=/out', + 'registry.gitlab.com/kicad/kicad-ci/kicad-cli-docker/kicad:nightly', + 'kicad-cli', 'fp', 'export', 'svg', '--output', '/out', '--footprint', fp_name, f'/{pretty_dir.name}'] + subprocess.run(cmd, check=True) #, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) out_file = Path(tmpdir) / f'{fp_name}.svg' shutil.copy(out_file, cachefile) else: diff --git a/gerbonara/tests/test_kicad_footprints.py b/gerbonara/tests/test_kicad_footprints.py index 73aeea5..1685a12 100644 --- a/gerbonara/tests/test_kicad_footprints.py +++ b/gerbonara/tests/test_kicad_footprints.py @@ -282,6 +282,10 @@ def test_render(kicad_mod_file, tmpfile, print_on_error): root['width'] = root_w root['height'] = root_h + #for elem in root.find_all('path'): + # if elem.attrs.get('fill', '').lower() == '#d864ff' and math.isclose(float(elem.attrs.get('fill-opacity', 0)), 0.4): + # elem.decompose() + # remove alpha to avoid complicated filter hacks for elem in root.descendants: if not isinstance(elem, bs4.Tag): @@ -312,8 +316,8 @@ def test_render(kicad_mod_file, tmpfile, print_on_error): mean, _max, hist = svg_difference(ref_svg, out_svg, dpi=600, diff_out=tmpfile('Difference', '.png')) # compensate for circular pads aliasing badly - aliasing_artifacts = 1e-4 * len(fp.sexp.pads)/50 - assert mean < 1e-3 + aliasing_artifacts + aliasing_artifacts = 1e-3 * len(fp.sexp.pads)/10 + assert mean < 3e-3 + aliasing_artifacts assert hist[9] < 100 assert hist[3:].sum() < (1e-3 + 10*aliasing_artifacts)*hist.size |