Skip to content

Commit

Permalink
[Tests][Import][Preflights] more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Jan 19, 2024
1 parent f314cda commit c431d60
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 10 deletions.
48 changes: 38 additions & 10 deletions tests/test_plot/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def test_import_g_3(test_dir):


def test_import_g_4(test_dir):
""" Import a global option: not a dict """
""" Import a global option: no globals """
prj = 'test_v5'
ctx = context.TestContext(test_dir, prj, 'import_test_g_4')
ctx.run()
Expand Down Expand Up @@ -935,25 +935,53 @@ def test_import_6(test_dir):
ctx.clean_up()


def create_rules_project(ctx):
if context.ki7():
with open(ctx.board_file.replace('kicad_pcb', 'kicad_pro'), 'wt') as f:
f.write(json.dumps({"board": {"design_settings": {"rule_severities": {"lib_footprint_issues": "ignore",
"lib_footprint_mismatch": "ignore"}}}}))


# Isn't really slow, just avoid to run it in parallel
@pytest.mark.slow
@pytest.mark.skipif(context.ki5(), reason="too slow on KiCad 5")
def test_import_7(test_dir):
def test_import_p_1(test_dir):
""" Import a preflight """
prj = '3Rs'
ctx = context.TestContext(test_dir, prj, 'import_test_7')
if context.ki7():
ctx.board_file.replace('kicad_pcb', 'kicad_pro')
with open(ctx.board_file.replace('kicad_pcb', 'kicad_pro'), 'wt') as f:
f.write(json.dumps({"board": {"design_settings": {"rule_severities": {"lib_footprint_issues": "ignore",
"lib_footprint_mismatch": "ignore"}}}}))
ctx.run(extra=[])
ctx = context.TestContext(test_dir, prj, 'import_test_p_1')
create_rules_project(ctx)
ctx.run()
ctx.expect_out_file('3Rs-drc.txt')
ctx.clean_up()


# Isn't really slow, just avoid to run it in parallel
@pytest.mark.slow
@pytest.mark.skipif(context.ki5(), reason="too slow on KiCad 5")
def test_import_p_2(test_dir):
""" Import a particular preflight """
prj = '3Rs'
ctx = context.TestContext(test_dir, prj, 'import_test_p_2')
create_rules_project(ctx)
ctx.run()
ctx.expect_out_file('3Rs-drc.txt')
ctx.dont_expect_out_file('3Rs-erc.txt')
ctx.search_err(r"can't import `foobar`")
ctx.clean_up()


def test_import_p_3(test_dir):
""" Import preflight: no preflights """
prj = '3Rs'
ctx = context.TestContext(test_dir, prj, 'import_test_p_3')
create_rules_project(ctx)
ctx.run()
ctx.search_err(r"No preflights found")
ctx.clean_up()


def test_import_8(test_dir):
""" Import a preflight """
""" Import at the end """
prj = 'light_control'
ctx = context.TestContext(test_dir, prj, 'import_test_8')
ctx.run(extra=[])
Expand Down
7 changes: 7 additions & 0 deletions tests/yaml_samples/drc_erc.kibot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Example KiBot config file
kibot:
version: 1

preflight:
run_drc: true
run_erc: true
3 changes: 3 additions & 0 deletions tests/yaml_samples/empty.kibot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kibot:
version: 1

File renamed without changes.
12 changes: 12 additions & 0 deletions tests/yaml_samples/import_test_p_2.kibot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kibot:
version: 1

global:
filters:
- filter: 'Ignore mismatch in the 3D models'
error: lib_footprint_mismatch
regexp: '.*'

import:
- file: drc_erc.kibot.yaml
preflights: ['run_drc', 'foobar']
6 changes: 6 additions & 0 deletions tests/yaml_samples/import_test_p_3.kibot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kibot:
version: 1

import:
- file: empty.kibot.yaml
preflights: ['run_drc', 'foobar']

0 comments on commit c431d60

Please sign in to comment.