Added more preflight tests

This commit is contained in:
Salvador E. Tropea 2020-07-08 19:49:33 -03:00
parent 38baa62cbe
commit 307bed3a36
4 changed files with 46 additions and 4 deletions

View File

@ -39,5 +39,5 @@ class Run_ERC(BasePreFlight): # noqa: F821
if ret < 0:
logger.error('ERC errors: %d', -ret)
else:
logger.error('ERC returned %d', ret) # pragma: no cover
logger.error('ERC returned %d', ret)
exit(ERC_ERROR)

View File

@ -23,7 +23,7 @@ if prev_dir not in sys.path:
sys.path.insert(0, prev_dir)
# Utils import
from utils import context
from kiplot.misc import (DRC_ERROR, ERC_ERROR)
from kiplot.misc import (DRC_ERROR, ERC_ERROR, BOM_ERROR)
def test_erc():
@ -35,15 +35,24 @@ def test_erc():
ctx.clean_up()
def test_erc_fail():
def test_erc_fail_1():
""" Using an SCH with ERC errors """
prj = 'fail-erc'
ctx = context.TestContext('ERC', prj, 'erc', '')
ctx = context.TestContext('ERCFail1', prj, 'erc', '')
ctx.run(ERC_ERROR)
# Check all outputs are there
ctx.expect_out_file(prj+'.erc')
ctx.clean_up()
def test_erc_fail_2():
""" Using a dummy SCH """
prj = '3Rs'
ctx = context.TestContext('ERCFail2', prj, 'erc', '')
ctx.run(ERC_ERROR)
ctx.clean_up()
def test_drc():
prj = 'bom'
ctx = context.TestContext('DRC', prj, 'drc', '')
@ -83,6 +92,14 @@ def test_drc_error():
ctx.clean_up()
def test_drc_fail():
""" Check we dummy PCB """
prj = 'bom_no_xml'
ctx = context.TestContext('DRCFail', prj, 'drc', '')
ctx.run(DRC_ERROR)
ctx.clean_up()
def test_update_xml():
prj = 'bom'
ctx = context.TestContext('Update_XML', prj, 'update_xml', '')
@ -100,3 +117,11 @@ def test_update_xml():
os.remove(xml)
os.rename(xml+'-bak', xml)
ctx.clean_up()
def test_update_xml_fail():
""" Using a dummy SCH """
prj = '3Rs'
ctx = context.TestContext('Update_XMLFail', prj, 'update_xml', '')
ctx.run(BOM_ERROR)
ctx.clean_up()

View File

@ -343,6 +343,14 @@ def test_error_wrong_type_3():
ctx.clean_up()
def test_error_wrong_type_4():
""" update_xml = number """
ctx = context.TestContext('ErrorWrongType4', PRJ, 'error_pre_wrong_type_4', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("In preflight 'update_xml': must be boolean")
ctx.clean_up()
def test_error_yaml():
ctx = context.TestContext('ErrorYAML', PRJ, 'error_yaml', '')
ctx.run(EXIT_BAD_CONFIG)

View File

@ -0,0 +1,9 @@
# Example KiPlot config file
kiplot:
version: 1
preflight:
update_xml: 5
run_erc: true