Added tests to cover 100% of kiplot/config_reader.py
Mostly parser errors.
This commit is contained in:
parent
6ed99d8515
commit
19023ef4e6
|
|
@ -115,29 +115,24 @@ class CfgYamlReader(object):
|
|||
|
||||
def _parse_layers(self, layers_to_parse):
|
||||
# Check we have a list of layers
|
||||
if not layers_to_parse:
|
||||
raise KiPlotConfigurationError("Missing `layers` definition")
|
||||
if not isinstance(layers_to_parse, list):
|
||||
raise KiPlotConfigurationError("`layers` must be a list")
|
||||
# Parse the elements
|
||||
layers = []
|
||||
for l in layers_to_parse:
|
||||
# Check they are dictionaries
|
||||
if not isinstance(l, dict):
|
||||
raise KiPlotConfigurationError("Malformed `layer` entry ({})".format(l))
|
||||
# Extract the attributes
|
||||
layer = None
|
||||
description = 'no desc'
|
||||
suffix = ''
|
||||
for k, v in l.items():
|
||||
if k == 'layer':
|
||||
layer = v
|
||||
layer = str(v)
|
||||
elif k == 'description':
|
||||
description = v
|
||||
description = str(v)
|
||||
elif k == 'suffix':
|
||||
suffix = v
|
||||
suffix = str(v)
|
||||
else:
|
||||
raise KiPlotConfigurationError("Unknown {} attribute for `layer`".format(v))
|
||||
raise KiPlotConfigurationError("Unknown `{}` attribute for `layer`".format(k))
|
||||
# Check we got the layer name
|
||||
if layer is None:
|
||||
raise KiPlotConfigurationError("Missing `layer` attribute for layer entry ({})".format(l))
|
||||
|
|
@ -217,7 +212,7 @@ class CfgYamlReader(object):
|
|||
logger.debug("Adding DRC/ERC filter '{}','{}','{}'".format(comment, number, regex))
|
||||
if parsed is None:
|
||||
parsed = ''
|
||||
if not comment:
|
||||
if comment:
|
||||
parsed += '# '+comment+'\n'
|
||||
parsed += '{},{}\n'.format(number, regex)
|
||||
else:
|
||||
|
|
@ -268,7 +263,7 @@ class CfgYamlReader(object):
|
|||
else:
|
||||
config_error("`outputs` must be a list")
|
||||
else:
|
||||
logger.warning('Skipping unknown `{}` section in config.'.format(k))
|
||||
config_error('Unknown section `{}` in config.'.format(k))
|
||||
if version is None:
|
||||
config_error("YAML config needs `kiplot.version`.")
|
||||
return outputs
|
||||
|
|
|
|||
|
|
@ -0,0 +1,295 @@
|
|||
(kicad_pcb (version 20171130) (host pcbnew 5.1.5+dfsg1-2~bpo10+1)
|
||||
|
||||
(general
|
||||
(thickness 1.6)
|
||||
(drawings 6)
|
||||
(tracks 20)
|
||||
(zones 0)
|
||||
(modules 4)
|
||||
(nets 4)
|
||||
)
|
||||
|
||||
(page A4)
|
||||
(layers
|
||||
(0 F.Cu signal)
|
||||
(1 GND.Cu signal)
|
||||
(2 Signal1.Cu signal)
|
||||
(3 Signal2.Cu signal)
|
||||
(4 Power.Cu signal)
|
||||
(31 B.Cu signal)
|
||||
(32 B.Adhes user)
|
||||
(33 F.Adhes user)
|
||||
(34 B.Paste user)
|
||||
(35 F.Paste user)
|
||||
(36 B.SilkS user)
|
||||
(37 F.SilkS user)
|
||||
(38 B.Mask user)
|
||||
(39 F.Mask user)
|
||||
(40 Dwgs.User user)
|
||||
(41 Cmts.User user)
|
||||
(42 Eco1.User user)
|
||||
(43 Eco2.User user)
|
||||
(44 Edge.Cuts user)
|
||||
(45 Margin user)
|
||||
(46 B.CrtYd user)
|
||||
(47 F.CrtYd user)
|
||||
(48 B.Fab user)
|
||||
(49 F.Fab user)
|
||||
)
|
||||
|
||||
(setup
|
||||
(last_trace_width 0.25)
|
||||
(trace_clearance 0.2)
|
||||
(zone_clearance 0.508)
|
||||
(zone_45_only no)
|
||||
(trace_min 0.2)
|
||||
(via_size 0.8)
|
||||
(via_drill 0.4)
|
||||
(via_min_size 0.4)
|
||||
(via_min_drill 0.3)
|
||||
(uvia_size 0.3)
|
||||
(uvia_drill 0.1)
|
||||
(uvias_allowed no)
|
||||
(uvia_min_size 0.2)
|
||||
(uvia_min_drill 0.1)
|
||||
(edge_width 0.05)
|
||||
(segment_width 0.2)
|
||||
(pcb_text_width 0.3)
|
||||
(pcb_text_size 1.5 1.5)
|
||||
(mod_edge_width 0.12)
|
||||
(mod_text_size 1 1)
|
||||
(mod_text_width 0.15)
|
||||
(pad_size 1.524 1.524)
|
||||
(pad_drill 0.762)
|
||||
(pad_to_mask_clearance 0.051)
|
||||
(solder_mask_min_width 0.25)
|
||||
(aux_axis_origin 0 0)
|
||||
(visible_elements FFFFFF7F)
|
||||
(pcbplotparams
|
||||
(layerselection 0x010fc_ffffffff)
|
||||
(usegerberextensions false)
|
||||
(usegerberattributes false)
|
||||
(usegerberadvancedattributes false)
|
||||
(creategerberjobfile false)
|
||||
(excludeedgelayer true)
|
||||
(linewidth 0.100000)
|
||||
(plotframeref false)
|
||||
(viasonmask false)
|
||||
(mode 1)
|
||||
(useauxorigin false)
|
||||
(hpglpennumber 1)
|
||||
(hpglpenspeed 20)
|
||||
(hpglpendiameter 15.000000)
|
||||
(psnegative false)
|
||||
(psa4output false)
|
||||
(plotreference true)
|
||||
(plotvalue true)
|
||||
(plotinvisibletext false)
|
||||
(padsonsilk false)
|
||||
(subtractmaskfromsilk false)
|
||||
(outputformat 1)
|
||||
(mirror false)
|
||||
(drillshape 1)
|
||||
(scaleselection 1)
|
||||
(outputdirectory ""))
|
||||
)
|
||||
|
||||
(net 0 "")
|
||||
(net 1 /Power/VCC)
|
||||
(net 2 GND)
|
||||
(net 3 "Net-(C2-Pad1)")
|
||||
|
||||
(net_class Default "This is the default net class."
|
||||
(clearance 0.2)
|
||||
(trace_width 0.25)
|
||||
(via_dia 0.8)
|
||||
(via_drill 0.4)
|
||||
(uvia_dia 0.3)
|
||||
(uvia_drill 0.1)
|
||||
(add_net /Power/VCC)
|
||||
(add_net GND)
|
||||
(add_net "Net-(C2-Pad1)")
|
||||
)
|
||||
|
||||
(module Capacitor_SMD:C_0402_1005Metric (layer F.Cu) (tedit 5B301BBE) (tstamp 5CA72801)
|
||||
(at 164.775001 80.505001 90)
|
||||
(descr "Capacitor SMD 0402 (1005 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: http://www.tortai-tech.com/upload/download/2011102023233369053.pdf), generated with kicad-footprint-generator")
|
||||
(tags capacitor)
|
||||
(path /5CA71704/5CA745A6)
|
||||
(attr smd)
|
||||
(fp_text reference C1 (at 0 -1.17 90) (layer F.SilkS)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_text value C (at 0 1.17 90) (layer F.Fab)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_line (start -0.5 0.25) (end -0.5 -0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -0.5 -0.25) (end 0.5 -0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 0.5 -0.25) (end 0.5 0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 0.5 0.25) (end -0.5 0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -0.93 0.47) (end -0.93 -0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start -0.93 -0.47) (end 0.93 -0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 0.93 -0.47) (end 0.93 0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 0.93 0.47) (end -0.93 0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_text user %R (at 0 0 90) (layer F.Fab)
|
||||
(effects (font (size 0.25 0.25) (thickness 0.04)))
|
||||
)
|
||||
(pad 1 smd roundrect (at -0.485 0 90) (size 0.59 0.64) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
|
||||
(net 1 /Power/VCC))
|
||||
(pad 2 smd roundrect (at 0.485 0 90) (size 0.59 0.64) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
|
||||
(net 2 GND))
|
||||
(model ${KIPRJMOD}/3D/C_0402_1005Metric.wrl
|
||||
(at (xyz 0 0 0))
|
||||
(scale (xyz 1 1 1))
|
||||
(rotate (xyz 0 0 0))
|
||||
)
|
||||
)
|
||||
|
||||
(module Capacitor_SMD:C_0402_1005Metric (layer F.Cu) (tedit 5B301BBE) (tstamp 5CA72810)
|
||||
(at 170.18 80.020001 90)
|
||||
(descr "Capacitor SMD 0402 (1005 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: http://www.tortai-tech.com/upload/download/2011102023233369053.pdf), generated with kicad-footprint-generator")
|
||||
(tags capacitor)
|
||||
(path /5CA75BC1/5CA76352)
|
||||
(attr smd)
|
||||
(fp_text reference C2 (at 0 -1.17 90) (layer F.SilkS)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_text value C (at 0 1.17 90) (layer F.Fab)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_text user %R (at 0 0 90) (layer F.Fab)
|
||||
(effects (font (size 0.25 0.25) (thickness 0.04)))
|
||||
)
|
||||
(fp_line (start 0.93 0.47) (end -0.93 0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 0.93 -0.47) (end 0.93 0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start -0.93 -0.47) (end 0.93 -0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start -0.93 0.47) (end -0.93 -0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 0.5 0.25) (end -0.5 0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 0.5 -0.25) (end 0.5 0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -0.5 -0.25) (end 0.5 -0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -0.5 0.25) (end -0.5 -0.25) (layer F.Fab) (width 0.1))
|
||||
(pad 2 smd roundrect (at 0.485 0 90) (size 0.59 0.64) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
|
||||
(net 2 GND))
|
||||
(pad 1 smd roundrect (at -0.485 0 90) (size 0.59 0.64) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
|
||||
(net 3 "Net-(C2-Pad1)"))
|
||||
(model ${KIPRJMOD}/3D/C_0402_1005Metric.wrl
|
||||
(at (xyz 0 0 0))
|
||||
(scale (xyz 1 1 1))
|
||||
(rotate (xyz 0 0 0))
|
||||
)
|
||||
)
|
||||
|
||||
(module Connector_JST:JST_JWPF_B02B-JWPF-SK-R_1x02_P2.00mm_Vertical (layer F.Cu) (tedit 5B772B89) (tstamp 5CA7282D)
|
||||
(at 154.94 80.01)
|
||||
(descr "JST JWPF series connector, B02B-JWPF-SK-R (http://www.jst-mfg.com/product/pdf/eng/eJWPF1.pdf), generated with kicad-footprint-generator")
|
||||
(tags "connector JST JWPF side entry")
|
||||
(path /5CA71704/5CA714F2)
|
||||
(fp_text reference P1 (at -1.35 -3.7) (layer F.SilkS)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_text value CONN_01X02 (at -1.35 5.7) (layer F.Fab)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_arc (start 1.7 -1.5) (end 1.7 -2.5) (angle 90) (layer F.Fab) (width 0.1))
|
||||
(fp_arc (start 1.7 3.5) (end 2.7 3.5) (angle 90) (layer F.Fab) (width 0.1))
|
||||
(fp_arc (start 1.81 -1.61) (end 1.81 -2.61) (angle 90) (layer F.SilkS) (width 0.12))
|
||||
(fp_arc (start 1.81 3.61) (end 2.81 3.61) (angle 90) (layer F.SilkS) (width 0.12))
|
||||
(fp_line (start -5.9 -3) (end -5.9 5) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start -5.9 5) (end 3.2 5) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 3.2 5) (end 3.2 -3) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 3.2 -3) (end -5.9 -3) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 1.7 -2.5) (end -5.4 -2.5) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -5.4 -2.5) (end -5.4 4.5) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -5.4 4.5) (end 1.7 4.5) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 2.7 -1.5) (end 2.7 3.5) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 1.81 -2.61) (end -5.51 -2.61) (layer F.SilkS) (width 0.12))
|
||||
(fp_line (start -5.51 -2.61) (end -5.51 4.61) (layer F.SilkS) (width 0.12))
|
||||
(fp_line (start -5.51 4.61) (end 1.81 4.61) (layer F.SilkS) (width 0.12))
|
||||
(fp_line (start 2.81 -1.61) (end 2.81 3.61) (layer F.SilkS) (width 0.12))
|
||||
(fp_line (start -5.75 -1.35) (end -5.75 -2.85) (layer F.SilkS) (width 0.12))
|
||||
(fp_line (start -5.75 -2.85) (end -4.25 -2.85) (layer F.SilkS) (width 0.12))
|
||||
(fp_line (start -0.375 -1.9) (end 0.375 -1.9) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 0.375 -1.9) (end 0 -1.15) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 0 -1.15) (end -0.375 -1.9) (layer F.Fab) (width 0.1))
|
||||
(fp_text user %R (at -4.7 1 90) (layer F.Fab)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(pad 1 thru_hole roundrect (at 0 0) (size 2 1.3) (drill 1) (layers *.Cu *.Mask) (roundrect_rratio 0.192308)
|
||||
(net 2 GND))
|
||||
(pad 2 thru_hole oval (at 0 2) (size 2 1.3) (drill 1) (layers *.Cu *.Mask)
|
||||
(net 1 /Power/VCC))
|
||||
(pad "" np_thru_hole circle (at -1.5 4.05) (size 1.15 1.15) (drill 1.15) (layers *.Cu *.Mask))
|
||||
(model ${KIPRJMOD}/3D/B02B-JWPF-SK-R.step
|
||||
(offset (xyz -3.2 -4.5 -8))
|
||||
(scale (xyz 1 1 1))
|
||||
(rotate (xyz 0 0 -90))
|
||||
)
|
||||
)
|
||||
|
||||
(module Resistor_SMD:R_0402_1005Metric (layer F.Cu) (tedit 5B301BBD) (tstamp 5CA7283C)
|
||||
(at 167.64 83.82)
|
||||
(descr "Resistor SMD 0402 (1005 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: http://www.tortai-tech.com/upload/download/2011102023233369053.pdf), generated with kicad-footprint-generator")
|
||||
(tags resistor)
|
||||
(path /5CA75BC1/5CA75C86)
|
||||
(attr smd)
|
||||
(fp_text reference R1 (at 0 -1.17) (layer F.SilkS)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_text value R (at 0 1.17) (layer F.Fab)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(fp_line (start -0.5 0.25) (end -0.5 -0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -0.5 -0.25) (end 0.5 -0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 0.5 -0.25) (end 0.5 0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start 0.5 0.25) (end -0.5 0.25) (layer F.Fab) (width 0.1))
|
||||
(fp_line (start -0.93 0.47) (end -0.93 -0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start -0.93 -0.47) (end 0.93 -0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 0.93 -0.47) (end 0.93 0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_line (start 0.93 0.47) (end -0.93 0.47) (layer F.CrtYd) (width 0.05))
|
||||
(fp_text user %R (at 0 0) (layer F.Fab)
|
||||
(effects (font (size 0.25 0.25) (thickness 0.04)))
|
||||
)
|
||||
(pad 1 smd roundrect (at -0.485 0) (size 0.59 0.64) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
|
||||
(net 1 /Power/VCC))
|
||||
(pad 2 smd roundrect (at 0.485 0) (size 0.59 0.64) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25)
|
||||
(net 3 "Net-(C2-Pad1)"))
|
||||
(model ${KIPRJMOD}/3D/R_0402_1005Metric.wrl
|
||||
(at (xyz 0 0 0))
|
||||
(scale (xyz 1 1 1))
|
||||
(rotate (xyz 0 0 0))
|
||||
)
|
||||
)
|
||||
|
||||
(gr_text "Text in Cmts.User" (at 149 93) (layer Cmts.User)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(gr_text "Text in Dwgs.User" (at 149 68) (layer Dwgs.User)
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
)
|
||||
(gr_line (start 187.96 69.85) (end 142.24 69.85) (layer Edge.Cuts) (width 0.12))
|
||||
(gr_line (start 187.96 91.44) (end 187.96 69.85) (layer Edge.Cuts) (width 0.12))
|
||||
(gr_line (start 142.24 91.44) (end 187.96 91.44) (layer Edge.Cuts) (width 0.12))
|
||||
(gr_line (start 142.24 69.85) (end 142.24 91.44) (layer Edge.Cuts) (width 0.12))
|
||||
|
||||
(segment (start 160 73) (end 180 73) (width 0.25) (layer GND.Cu) (net 0))
|
||||
(segment (start 180 73) (end 180 88) (width 0.25) (layer GND.Cu) (net 0))
|
||||
(segment (start 180 88) (end 160 88) (width 0.25) (layer Signal1.Cu) (net 0))
|
||||
(segment (start 160 88) (end 160 73) (width 0.25) (layer Signal1.Cu) (net 0))
|
||||
(segment (start 161 87) (end 179 87) (width 0.25) (layer Signal2.Cu) (net 0))
|
||||
(segment (start 179 87) (end 179 74) (width 0.25) (layer Signal2.Cu) (net 0))
|
||||
(segment (start 161 74) (end 179 74) (width 0.25) (layer Power.Cu) (net 0))
|
||||
(segment (start 161 74) (end 161 87) (width 0.25) (layer Power.Cu) (net 0))
|
||||
(segment (start 167.155 83.37) (end 165.1 81.315) (width 0.25) (layer F.Cu) (net 1))
|
||||
(segment (start 167.155 83.82) (end 167.155 83.37) (width 0.25) (layer F.Cu) (net 1))
|
||||
(segment (start 165.1 81.315) (end 164.775001 80.990001) (width 0.25) (layer F.Cu) (net 1))
|
||||
(segment (start 164.775001 80.990001) (end 157.769999 80.990001) (width 0.25) (layer F.Cu) (net 1))
|
||||
(segment (start 156.75 82.01) (end 154.94 82.01) (width 0.25) (layer F.Cu) (net 1))
|
||||
(segment (start 157.769999 80.990001) (end 156.75 82.01) (width 0.25) (layer F.Cu) (net 1))
|
||||
(segment (start 164.765 80.01) (end 164.775001 80.020001) (width 0.25) (layer F.Cu) (net 2))
|
||||
(segment (start 154.94 80.01) (end 164.765 80.01) (width 0.25) (layer F.Cu) (net 2))
|
||||
(segment (start 165.260001 79.535001) (end 170.18 79.535001) (width 0.25) (layer F.Cu) (net 2))
|
||||
(segment (start 164.775001 80.020001) (end 165.260001 79.535001) (width 0.25) (layer F.Cu) (net 2))
|
||||
(segment (start 170.18 81.765) (end 168.125 83.82) (width 0.25) (layer F.Cu) (net 3))
|
||||
(segment (start 170.18 80.505001) (end 170.18 81.765) (width 0.25) (layer F.Cu) (net 3))
|
||||
|
||||
)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Tests of simple 2-layer PCBs.
|
||||
We generate the gerbers.
|
||||
Tests of Gerber format.
|
||||
- Simple 2 layers
|
||||
- Inner layer
|
||||
|
||||
For debug information use:
|
||||
pytest-3 --log-cli-level debug
|
||||
|
|
@ -19,7 +20,7 @@ from utils import context
|
|||
GERBER_DIR = 'gerberdir'
|
||||
|
||||
|
||||
def test_2layer():
|
||||
def test_gerber_2layer():
|
||||
prj = 'simple_2layer'
|
||||
ctx = context.TestContext('Simple_2_layer', prj, prj, GERBER_DIR)
|
||||
ctx.run()
|
||||
|
|
@ -37,3 +38,14 @@ def test_2layer():
|
|||
ctx.expect_gerber_flash_at(f_cu, 5, (140, -100))
|
||||
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_gerber_inner():
|
||||
prj = 'good-project'
|
||||
ctx = context.TestContext('Gerber_Inner', prj, 'gerber_inner', GERBER_DIR)
|
||||
ctx.run()
|
||||
|
||||
ctx.expect_out_file(ctx.get_gerber_filename('GND_Cu'))
|
||||
ctx.expect_out_file(ctx.get_gerber_filename('Signal1'))
|
||||
ctx.expect_out_file(ctx.get_gerber_job_filename())
|
||||
ctx.clean_up()
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
"""
|
||||
Tests various errors in the config file
|
||||
|
||||
- Wrong kiplot
|
||||
- No kiplot.version
|
||||
- Typo in kiplot.version
|
||||
- Wrong kiplot.version
|
||||
- Missing drill map type
|
||||
- Wrong drill map type
|
||||
|
|
@ -11,10 +13,29 @@ Tests various errors in the config file
|
|||
- Incorrect name
|
||||
- Inner.1, but no inner layers
|
||||
- Inner_1 (malformed)
|
||||
- Not a list
|
||||
- Unknown attribute
|
||||
- No layer attribute
|
||||
- No output:
|
||||
- name
|
||||
- type
|
||||
- layers
|
||||
- Output:
|
||||
- with unknown attribute
|
||||
- Not a list
|
||||
- Filters:
|
||||
- Not a list
|
||||
- Empty number
|
||||
- No number
|
||||
- Empty regex
|
||||
- No regex
|
||||
- No filter
|
||||
- Pre-flight:
|
||||
- Not a list
|
||||
- Unknown entry
|
||||
- Wrong type for entry (run_drc)
|
||||
- YAML syntax
|
||||
- Unknown section
|
||||
|
||||
For debug information use:
|
||||
pytest-3 --log-cli-level debug
|
||||
|
|
@ -31,6 +52,9 @@ sys.path.insert(0, os.path.dirname(prev_dir))
|
|||
from kiplot.misc import (EXIT_BAD_CONFIG, PLOT_ERROR)
|
||||
|
||||
|
||||
PRJ = 'fail-project'
|
||||
|
||||
|
||||
def test_no_version():
|
||||
ctx = context.TestContext('ErrorNoVersion', '3Rs', 'error_no_version', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
|
|
@ -45,6 +69,20 @@ def test_wrong_version():
|
|||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_wrong_version_2():
|
||||
ctx = context.TestContext('ErrorWrongVersion2', '3Rs', 'error_wrong_version_2', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err('Incorrect .?kiplot.? section')
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_wrong_version_3():
|
||||
ctx = context.TestContext('ErrorWrongVersion3', '3Rs', 'error_wrong_version_3', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err('YAML config needs .?kiplot.version.?')
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_drill_map_no_type():
|
||||
ctx = context.TestContext('ErrorDrillMapNoType', '3Rs', 'error_drill_map_no_type', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
|
|
@ -80,6 +118,27 @@ def test_wrong_layer_3():
|
|||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_wrong_layer_4():
|
||||
ctx = context.TestContext('ErrorWrongLayer4', '3Rs', 'error_wrong_layer_4', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err(".?layers.? must be a list")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_wrong_layer_5():
|
||||
ctx = context.TestContext('ErrorWrongLayer5', '3Rs', 'error_wrong_layer_5', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Unknown .?bogus.? attribute ")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_wrong_layer_6():
|
||||
ctx = context.TestContext('ErrorWrongLayer6', '3Rs', 'error_wrong_layer_6', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Missing .?layer.? attribute")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_no_name():
|
||||
ctx = context.TestContext('ErrorNoName', '3Rs', 'error_no_name', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
|
|
@ -94,6 +153,13 @@ def test_no_type():
|
|||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_out_unknown_attr():
|
||||
ctx = context.TestContext('ErrorUnkOutAttr', '3Rs', 'error_unk_attr', None)
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Unknown key .?types.?")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
# Now is valid
|
||||
# def test_no_options():
|
||||
# ctx = context.TestContext('ErrorNoOptions', '3Rs', 'error_no_options', None)
|
||||
|
|
@ -121,3 +187,87 @@ def test_error_step_min_distance():
|
|||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("`min_distance` must be a number")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_filter_not_list():
|
||||
ctx = context.TestContext('FilterNotList', PRJ, 'error_filter_not_list', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err(".?filters.? must be a list ")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_filter_no_number():
|
||||
ctx = context.TestContext('FilterNoNumber', PRJ, 'error_filter_no_number', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("empty .?number.? in .?filter.?")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_filter_no_number_2():
|
||||
ctx = context.TestContext('FilterNoNumber2', PRJ, 'error_filter_no_number_2', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("missing .?number.? for .?filter.?")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_filter_no_regex():
|
||||
ctx = context.TestContext('FilterNoRegex', PRJ, 'error_filter_no_regex', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("empty .?regex.? in .?filter.?")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_filter_no_regex_2():
|
||||
ctx = context.TestContext('FilterNoRegex2', PRJ, 'error_filter_no_regex_2', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("missing .?regex.? for .?filter.?")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_filter_wrong_entry():
|
||||
ctx = context.TestContext('FilterWrongEntry', PRJ, 'error_filter_wrong_entry', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err(".?filters.? section of .?preflight.? must contain .?filter.?(.*)Pad 2 of C4")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_error_pre_list():
|
||||
ctx = context.TestContext('ErrorPreList', PRJ, 'error_pre_list', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Incorrect .?preflight.? section")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_error_pre_unk():
|
||||
ctx = context.TestContext('ErrorPreUnk', PRJ, 'error_pre_unk', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Unknown preflight: .?run_drcs.?")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_error_wrong_type_1():
|
||||
ctx = context.TestContext('ErrorWrongType1', PRJ, 'error_pre_wrong_type_1', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("In preflight 'run_drc': must be boolean")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_error_yaml():
|
||||
ctx = context.TestContext('ErrorYAML', PRJ, 'error_yaml', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Error loading YAML")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_out_not_list():
|
||||
ctx = context.TestContext('OutNotList', PRJ, 'error_out_not_list', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err(".?outputs.? must be a list")
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_unk_section():
|
||||
ctx = context.TestContext('UnkSection', PRJ, 'error_unk_section', '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Unknown section .?bogus.? in config")
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
filters:
|
||||
- filter: 'Ignore C3 pad 2 too close to anything'
|
||||
number:
|
||||
regex: 'Pad 2 of C3'
|
||||
- filter: 'Ignore unconnected pad 2 of C4'
|
||||
number: 2
|
||||
regex: 'Pad 2 of C4'
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
filters:
|
||||
- filter: 'Ignore C3 pad 2 too close to anything'
|
||||
regex: 'Pad 2 of C3'
|
||||
- filter: 'Ignore unconnected pad 2 of C4'
|
||||
number: 2
|
||||
regex: 'Pad 2 of C4'
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
filters:
|
||||
- filter: 'Ignore C3 pad 2 too close to anything'
|
||||
number: 2
|
||||
regex:
|
||||
- filter: 'Ignore unconnected pad 2 of C4'
|
||||
number: 2
|
||||
regex: 'Pad 2 of C4'
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
filters:
|
||||
- filter: 'Ignore C3 pad 2 too close to anything'
|
||||
number: 2
|
||||
- filter: 'Ignore unconnected pad 2 of C4'
|
||||
number: 2
|
||||
regex: 'Pad 2 of C4'
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
filters:
|
||||
filter: 'Ignore C3 pad 2 too close to anything'
|
||||
number: 4
|
||||
regex: 'Pad 2 of C3'
|
||||
filter: 'Ignore unconnected pad 2 of C4'
|
||||
number: 2
|
||||
regex: 'Pad 2 of C4'
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
filters:
|
||||
- number: 4
|
||||
filter: 'Ignore C3 pad 2 too close to anything'
|
||||
regex: 'Pad 2 of C3'
|
||||
- regex: 'Pad 2 of C4'
|
||||
number: 2
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
kiplot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
name: PDF
|
||||
comment: "PDF files"
|
||||
type: pdf
|
||||
dir: PDF
|
||||
layers:
|
||||
- layer: F.Cu
|
||||
suffix: F_Cu
|
||||
- layer: F.Bogus
|
||||
suffix: B_Silks
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
- update_xml: true
|
||||
- run_drc: false
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
update_xml: true
|
||||
run_drcs: false
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Example KiPlot config file
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
preflight:
|
||||
update_xml: true
|
||||
run_drc: 1
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
kiplot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: PDF
|
||||
comment: "PDF files"
|
||||
types: pdf
|
||||
dir: PDF
|
||||
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
|
||||
check_zone_fills: true
|
||||
|
||||
# PDF options
|
||||
drill_marks: small
|
||||
mirror_plot: false
|
||||
negative_plot: false
|
||||
line_width: 0.01
|
||||
layers:
|
||||
- layer: F.Cu
|
||||
suffix: F_Cu
|
||||
- layer: F.Bogus
|
||||
suffix: B_Silks
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Drills and Gerber drills
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
bogus:
|
||||
|
||||
- name: excellon_drill
|
||||
comment: "Excellon drill files"
|
||||
type: excellon
|
||||
dir: Drill
|
||||
options:
|
||||
metric_units: true
|
||||
pth_and_npth_single_file: false
|
||||
use_aux_axis_as_origin: false
|
||||
minimal_header: false
|
||||
mirror_y_axis: false
|
||||
report:
|
||||
filename: 'report.rpt'
|
||||
map:
|
||||
|
||||
- name: gerber_drills
|
||||
comment: "Gerber drill files"
|
||||
type: gerb_drill
|
||||
dir: Drill
|
||||
options:
|
||||
use_aux_axis_as_origin: false
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
kiplot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: PDF
|
||||
comment: "PDF files"
|
||||
type: pdf
|
||||
dir: PDF
|
||||
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
|
||||
check_zone_fills: true
|
||||
|
||||
# PDF options
|
||||
drill_marks: small
|
||||
mirror_plot: false
|
||||
negative_plot: false
|
||||
line_width: 0.01
|
||||
layers:
|
||||
layer: F.Cu
|
||||
suffix: F_Cu
|
||||
layer: Inner_1
|
||||
suffix: B_Silks
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
kiplot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: PDF
|
||||
comment: "PDF files"
|
||||
type: pdf
|
||||
dir: PDF
|
||||
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
|
||||
check_zone_fills: true
|
||||
|
||||
# PDF options
|
||||
drill_marks: small
|
||||
mirror_plot: false
|
||||
negative_plot: false
|
||||
line_width: 0.01
|
||||
layers:
|
||||
- layer: F.Cu
|
||||
description: 'Ok'
|
||||
- layer: B.Cu
|
||||
bogus: 'Wrong'
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
kiplot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: PDF
|
||||
comment: "PDF files"
|
||||
type: pdf
|
||||
dir: PDF
|
||||
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
|
||||
check_zone_fills: true
|
||||
|
||||
# PDF options
|
||||
drill_marks: small
|
||||
mirror_plot: false
|
||||
negative_plot: false
|
||||
line_width: 0.01
|
||||
layers:
|
||||
- description: 'Not in order'
|
||||
suffix: 'A_'
|
||||
layer: F.Cu
|
||||
- description: 'Where is my layer?'
|
||||
suffix: 'A_'
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
kiplot: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
kiplot:
|
||||
versiona: 1
|
||||
|
||||
preflight:
|
||||
run_drc: true
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Drills and Gerber drills
|
||||
kiplot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
|
||||
- name excellon_drill
|
||||
comment: "Excellon drill files"
|
||||
type: excellon
|
||||
dir: Drill
|
||||
options:
|
||||
metric_units: true
|
||||
pth_and_npth_single_file: false
|
||||
use_aux_axis_as_origin: false
|
||||
minimal_header: false
|
||||
mirror_y_axis: false
|
||||
report:
|
||||
filename: 'report.rpt'
|
||||
map:
|
||||
|
||||
- name: gerber_drills
|
||||
comment: "Gerber drill files"
|
||||
type: gerb_drill
|
||||
dir: Drill
|
||||
options:
|
||||
use_aux_axis_as_origin: false
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# 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
|
||||
check_zone_fills: true
|
||||
|
||||
# gerber options
|
||||
line_width: 0.15
|
||||
subtract_mask_from_silk: true
|
||||
use_protel_extensions: false
|
||||
gerber_precision: 4.6
|
||||
create_gerber_job_file: true
|
||||
use_gerber_x2_attributes: true
|
||||
use_gerber_net_attributes: false
|
||||
|
||||
layers:
|
||||
- layer: GND.Cu
|
||||
suffix: GND_Cu
|
||||
description: 'Ground plane'
|
||||
- layer: Inner.2
|
||||
suffix: Signal1
|
||||
description: 'Inner signals 1'
|
||||
|
||||
Loading…
Reference in New Issue