Added more tests for errors

This commit is contained in:
Salvador E. Tropea 2020-07-08 20:41:16 -03:00
parent 307bed3a36
commit 1917b4c601
7 changed files with 103 additions and 4 deletions

View File

@ -77,7 +77,8 @@ class AnyLayerOptions(BaseOptions):
# Plot single layer to file
logger.debug("Opening plot file for layer `{}` format `{}`".format(l, self._plot_format))
if not plot_ctrl.OpenPlotfile(suffix, self._plot_format, desc):
raise PlotError("OpenPlotfile failed!")
# Shouldn't happen
raise PlotError("OpenPlotfile failed!") # pragma: no cover
logger.debug("Plotting layer `{}` to `{}`".format(l, plot_ctrl.GetPlotFileName()))
plot_ctrl.PlotLayer()

View File

@ -70,8 +70,8 @@ class BasePreFlight(object):
def disable(self):
self._enabled = False
def is_enabled(self):
return self._enabled
# def is_enabled(self):
# return self._enabled
def __str__(self):
return "{}: {}".format(self._name, self._enabled)

View File

@ -41,5 +41,5 @@ class Run_DRC(BasePreFlight): # noqa: F821
if ret < 0:
logger.error('DRC errors: %d', -ret)
else:
logger.error('DRC returned %d', ret) # pragma: no cover
logger.error('DRC returned %d', ret)
exit(DRC_ERROR)

View File

@ -351,6 +351,14 @@ def test_error_wrong_type_4():
ctx.clean_up()
def test_error_wrong_type_5():
""" check_zone_fills = number """
ctx = context.TestContext('ErrorWrongType5', PRJ, 'error_pre_wrong_type_5', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("In preflight 'check_zone_fills': must be boolean")
ctx.clean_up()
def test_error_yaml():
ctx = context.TestContext('ErrorYAML', PRJ, 'error_yaml', '')
ctx.run(EXIT_BAD_CONFIG)
@ -384,3 +392,17 @@ def test_error_bom_wrong_format():
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Option .?format.? must be any of")
ctx.clean_up()
def test_error_gerber_precision():
ctx = context.TestContext('GerberPrecisionError', PRJ, 'error_gerber_precision', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err(".?gerber_precision.? must be 4.5 or 4.6")
ctx.clean_up()
def test_error_wrong_drill_marks():
ctx = context.TestContext('WrongDrillMarks', PRJ, 'error_wrong_drill_marks', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Unknown drill mark type: bogus")
ctx.clean_up()

View File

@ -0,0 +1,36 @@
# Example KiPlot config file for a basic 2-layer board
kiplot:
version: 1
outputs:
- name: 'gerbers'
comment: "Gerbers for the Gerber god"
type: gerber
dir: gerberdir
options:
# generic layer options
exclude_edge_layer: false
exclude_pads_from_silkscreen: false
use_aux_axis_as_origin: false
plot_sheet_reference: false
plot_footprint_refs: true
plot_footprint_values: true
force_plot_invisible_refs_vals: false
tent_vias: true
# gerber options
line_width: 0.15
subtract_mask_from_silk: true
use_protel_extensions: false
gerber_precision: 4.7
create_gerber_job_file: true
use_gerber_x2_attributes: true
use_gerber_net_attributes: false
layers:
- layer: F.Cu
suffix: F_Cu
- layer: F.SilkS
suffix: F_SilkS

View File

@ -0,0 +1,10 @@
# Example KiPlot config file
kiplot:
version: 1
preflight:
update_xml: true
run_erc: true
check_zone_fills: Hi!

View File

@ -0,0 +1,30 @@
kiplot:
version: 1
outputs:
- name: DXF
comment: "DXF files"
type: dxf
dir: DXF
options:
exclude_edge_layer: false
exclude_pads_from_silkscreen: false
use_aux_axis_as_origin: false
plot_sheet_reference: false
plot_footprint_refs: true
plot_footprint_values: true
force_plot_invisible_refs_vals: false
tent_vias: true
# DXF options
drill_marks: bogus
sketch_plot: false
use_aux_axis_as_origin: false
polygon_mode: true
metric_units: false
layers:
- layer: F.Cu
suffix: F_Cu
- layer: F.Fab
suffix: F_Fab