[Tests] Added some tollerance to img compare for non Debian

This commit is contained in:
Salvador E. Tropea 2022-09-23 09:43:57 -03:00
parent b989d1aaa3
commit 8392f468ae
2 changed files with 4 additions and 3 deletions

View File

@ -46,6 +46,7 @@ MK_TARGETS = ['position', 'archive', 'interactive_bom', 'run_erc', '3D', 'kibom_
'run_drc']
# If we are not running on Debian skip the text part at the top of diff PDFs
OFFSET_Y = '0' if os.path.isfile('/etc/debian_version') else '80'
DIFF_TOL = 0 if os.path.isfile('/etc/debian_version') else 1200
def test_skip_pre_and_outputs(test_dir):
@ -1277,7 +1278,7 @@ def test_diff_file_1(test_dir):
yaml = 'diff_file_'+('k5' if context.ki5() else 'k6')
ctx = context.TestContext(test_dir, prj, yaml)
ctx.run()
ctx.compare_pdf(prj+'-diff_pcb.pdf', reference='light_control-diff_pcb.pdf', off_y=OFFSET_Y)
ctx.compare_pdf(prj+'-diff_pcb.pdf', reference='light_control-diff_pcb.pdf', off_y=OFFSET_Y, tol=DIFF_TOL)
ctx.clean_up(keep_project=True)

View File

@ -520,7 +520,7 @@ class TestContext(object):
os.remove(png_image)
assert ae <= tol
def compare_pdf(self, gen, reference=None, diff='diff-{}.png', height='87%', off_y='0'):
def compare_pdf(self, gen, reference=None, diff='diff-{}.png', height='87%', off_y='0', tol=0):
""" For multi-page PDFs """
if reference is None:
reference = gen
@ -545,7 +545,7 @@ class TestContext(object):
# Compare each page
for page in range(len(ref_pages)):
self.compare_image('gen-'+str(page)+'.png', 'ref-'+str(page)+'.png', diff.format(page), ref_out_dir=True,
height=height, off_y=off_y)
height=height, off_y=off_y, tol=tol)
def compare_txt(self, text, reference=None, diff='diff.txt'):
if reference is None: