[Tests][Added] Simple KiRi test

This commit is contained in:
Salvador E. Tropea 2024-01-09 10:54:45 -03:00
parent edafc47d0b
commit 0dfaad0d3a
2 changed files with 38 additions and 5 deletions

View File

@ -1357,6 +1357,34 @@ def test_diff_git_1(test_dir):
ctx.clean_up(keep_project=True)
def test_diff_kiri_1(test_dir):
""" Difference between the current PCB and the git HEAD """
prj = 'light_control'
yaml = 'kiri_1'
ctx = context.TestContext(test_dir, prj, yaml)
# Create a git repo
git_init(ctx)
# Copy the "old" file
pcb = prj+'.kicad_pcb'
sch = prj+context.KICAD_SCH_EXT
file = ctx.get_out_path(pcb)
shutil.copy2(ctx.board_file, file)
shutil.copy2(ctx.board_file.replace('.kicad_pcb', context.KICAD_SCH_EXT),
file.replace('.kicad_pcb', context.KICAD_SCH_EXT))
# Add it to the repo
ctx.run_command(['git', 'add', pcb, sch], chdir_out=True)
ctx.run_command(['git', 'commit', '-m', 'Reference'], chdir_out=True)
hash = ctx.run_command(['git', 'log', '--pretty=format:%h', '-n', '1'], chdir_out=True)
# Copy the "new" file
shutil.copy2(ctx.board_file.replace(prj, prj+'_diff'), file)
# Run the test
ctx.run(extra=['-b', file], no_board_file=True)
ctx.expect_out_file(['_local_/_KIRI_/pcb_layers', hash+'/_KIRI_/pcb_layers',
'_local_/_KIRI_/sch_sheets', hash+'/_KIRI_/sch_sheets',
'index.html', 'commits', 'project'])
ctx.clean_up(keep_project=True)
def test_diff_git_2(test_dir):
""" Difference between the two repo points, wipe the current file """
prj = 'light_control'

View File

@ -286,11 +286,16 @@ class TestContext(object):
return os.path.join(self.sub_dir, self.board_name+'-NPTH-drl_map.pdf')
def expect_out_file(self, filename, sub=False):
file = self.get_out_path(filename, sub)
assert os.path.isfile(file), file
assert os.path.getsize(file) > 0
logging.debug(filename+' OK')
return file
if isinstance(filename, str):
filename = [filename]
files = []
for f in filename:
file = self.get_out_path(f, sub)
assert os.path.isfile(file), file
assert os.path.getsize(file) > 0
logging.debug(f+' OK')
files.append(file)
return files[0] if len(files) == 1 else files
def expect_out_file_d(self, filename):
return self.expect_out_file(os.path.join(self.sub_dir, filename))