Separated YAML tests that makes reference to SCH files
- Avoiding KiCad 5 and 6 mixes
This commit is contained in:
parent
8a4064a544
commit
24ba23d203
|
|
@ -224,9 +224,16 @@ def load_board(pcb_file=None):
|
|||
return board
|
||||
|
||||
|
||||
def load_any_sch(sch, file, project):
|
||||
def load_any_sch(file, project):
|
||||
if file[-9:] == 'kicad_sch':
|
||||
sch = SchematicV6()
|
||||
load_libs = False
|
||||
else:
|
||||
sch = Schematic()
|
||||
load_libs = True
|
||||
try:
|
||||
sch.load(file, project)
|
||||
if load_libs:
|
||||
sch.load_libs(file)
|
||||
if GS.debug_level > 1:
|
||||
logger.debug('Schematic dependencies: '+str(sch.get_files()))
|
||||
|
|
@ -235,30 +242,24 @@ def load_any_sch(sch, file, project):
|
|||
logger.error('At line {} of `{}`: {}'.format(e.line, e.file, e.msg))
|
||||
logger.error('Line content: `{}`'.format(e.code))
|
||||
exit(CORRUPTED_SCH)
|
||||
except SchError as e:
|
||||
trace_dump()
|
||||
logger.error('While loading `{}`'.format(file))
|
||||
logger.error(str(e))
|
||||
exit(CORRUPTED_SCH)
|
||||
except KiConfError as e:
|
||||
trace_dump()
|
||||
logger.error('At line {} of `{}`: {}'.format(e.line, e.file, e.msg))
|
||||
logger.error('Line content: `{}`'.format(e.code))
|
||||
exit(EXIT_BAD_CONFIG)
|
||||
return sch
|
||||
|
||||
|
||||
def load_sch():
|
||||
if GS.sch: # Already loaded
|
||||
return
|
||||
GS.check_sch()
|
||||
# We can't yet load the new format
|
||||
if GS.sch_file[-9:] == 'kicad_sch':
|
||||
GS.sch = SchematicV6()
|
||||
try:
|
||||
GS.sch.load(GS.sch_file, GS.sch_basename)
|
||||
except SchError as e:
|
||||
trace_dump()
|
||||
logger.error('While loading `{}`'.format(GS.sch_file))
|
||||
logger.error(str(e))
|
||||
exit(CORRUPTED_SCH)
|
||||
return # pragma: no cover (Ki6)
|
||||
GS.sch = Schematic()
|
||||
load_any_sch(GS.sch, GS.sch_file, GS.sch_basename)
|
||||
GS.sch = load_any_sch(GS.sch_file, GS.sch_basename)
|
||||
|
||||
|
||||
def get_board_comps_data(comps):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from .kiplot import get_board_comps_data, load_any_sch
|
|||
from .bom.columnlist import ColumnList, BoMError
|
||||
from .bom.bom import do_bom
|
||||
from .var_kibom import KiBoM
|
||||
from .kicad.v5_sch import Schematic
|
||||
from .fil_base import BaseFilter, apply_exclude_filter, apply_fitted_filter, apply_fixed_filter, reset_filters
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
from . import log
|
||||
|
|
@ -563,8 +562,7 @@ class BoMOptions(BaseOptions):
|
|||
logger.debug('Adding components from project {} ({}) using reference id `{}`'.
|
||||
format(prj.name, prj.file, prj.ref_id))
|
||||
self.qtys[prj.name] = prj.number
|
||||
prj.sch = Schematic()
|
||||
load_any_sch(prj.sch, prj.file, prj.name)
|
||||
prj.sch = load_any_sch(prj.file, prj.name)
|
||||
new_comps = prj.sch.get_components()
|
||||
for c in new_comps:
|
||||
c.ref = prj.ref_id+c.ref
|
||||
|
|
|
|||
|
|
@ -1534,7 +1534,10 @@ def test_int_bom_variant_5(test_dir):
|
|||
|
||||
def test_int_bom_merge_csv_1(test_dir):
|
||||
prj = 'merge_1'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_csv_1', prj, 'int_bom_merge_csv_1', BOM_DIR)
|
||||
yaml = 'int_bom_merge_csv_1'
|
||||
if context.ki6():
|
||||
yaml += '_k6'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_csv_1', prj, yaml, BOM_DIR)
|
||||
ctx.run(extra_debug=True)
|
||||
rows, header, info = ctx.load_csv(prj+'-bom.csv')
|
||||
ref_column = header.index(REF_COLUMN_NAME)
|
||||
|
|
@ -1547,7 +1550,10 @@ def test_int_bom_merge_csv_1(test_dir):
|
|||
|
||||
def test_int_bom_merge_html_1(test_dir):
|
||||
prj = 'merge_1'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_html_1', prj, 'int_bom_merge_html_1', BOM_DIR)
|
||||
yaml = 'int_bom_merge_html_1'
|
||||
if context.ki6():
|
||||
yaml += '_k6'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_html_1', prj, yaml, BOM_DIR)
|
||||
ctx.run()
|
||||
rows, header, info = ctx.load_html(prj+'-bom.html')
|
||||
logging.debug(rows[0])
|
||||
|
|
@ -1560,7 +1566,10 @@ def test_int_bom_merge_html_1(test_dir):
|
|||
|
||||
def test_int_bom_merge_xlsx_1(test_dir):
|
||||
prj = 'merge_1'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_xlsx_1', prj, 'int_bom_merge_xlsx_1', BOM_DIR)
|
||||
yaml = 'int_bom_merge_xlsx_1'
|
||||
if context.ki6():
|
||||
yaml += '_k6'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_xlsx_1', prj, yaml, BOM_DIR)
|
||||
ctx.run()
|
||||
rows, header, info = ctx.load_xlsx(prj+'-bom.xlsx')
|
||||
ref_column = header.index(REF_COLUMN_NAME)
|
||||
|
|
@ -1572,7 +1581,10 @@ def test_int_bom_merge_xlsx_1(test_dir):
|
|||
|
||||
def test_int_bom_merge_xml_1(test_dir):
|
||||
prj = 'merge_1'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_xml_1', prj, 'int_bom_merge_xml_1', BOM_DIR)
|
||||
yaml = 'int_bom_merge_xml_1'
|
||||
if context.ki6():
|
||||
yaml += '_k6'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_int_bom_merge_xml_1', prj, yaml, BOM_DIR)
|
||||
ctx.run()
|
||||
rows, header = ctx.load_xml(prj+'-bom.xml')
|
||||
ref_column = header.index(REF_COLUMN_NAME)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,10 @@ def test_kicost_bom_sel_dist_1(test_dir):
|
|||
def test_kicost_bom_merge_1(test_dir):
|
||||
''' Internal BoM + KiCost, merging 3 projects. '''
|
||||
prj = 'merge_1'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_kicost_bom_merge_1', prj, 'int_bom_kicost_merge_xlsx', OUT_DIR)
|
||||
yaml = 'int_bom_kicost_merge_xlsx'
|
||||
if context.ki6():
|
||||
yaml += '_k6'
|
||||
ctx = context.TestContextSCH(test_dir, 'test_kicost_bom_merge_1', prj, yaml, OUT_DIR)
|
||||
ctx.run(kicost=True) # , extra_debug=True
|
||||
output = op.join(OUT_DIR, prj+'-bom.xlsx')
|
||||
ctx.expect_out_file(output)
|
||||
|
|
|
|||
|
|
@ -665,7 +665,10 @@ def test_error_aggregate_no_file(test_dir):
|
|||
|
||||
|
||||
def test_error_aggregate_miss_file(test_dir):
|
||||
ctx = context.TestContext(test_dir, 'test_error_aggregate_miss_file', 'bom', 'error_aggregate_miss_file', '')
|
||||
yaml = 'error_aggregate_miss_file'
|
||||
if context.ki6():
|
||||
yaml += '_k6'
|
||||
ctx = context.TestContext(test_dir, 'test_error_aggregate_miss_file', 'bom', yaml, '')
|
||||
ctx.run(EXIT_BAD_CONFIG)
|
||||
assert ctx.search_err("Missing `dummy`")
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_csv'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
format: CSV
|
||||
ref_id: 'A:'
|
||||
source_by_id: true
|
||||
use_alt: true
|
||||
aggregate:
|
||||
- file: tests/board_samples/kicad_6/merge_3.kicad_sch
|
||||
number: 4
|
||||
- file: dummy
|
||||
name: 2nd project
|
||||
ref_id: 'B:'
|
||||
number: 2
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_internal'
|
||||
comment: "Bill of Materials in XLSX format"
|
||||
type: bom
|
||||
dir: KiCost
|
||||
options:
|
||||
use_alt: true
|
||||
ref_id: 'prj0:'
|
||||
number: 50
|
||||
source_by_id: true
|
||||
aggregate:
|
||||
- file: tests/board_samples/kicad_6/merge_2.kicad_sch
|
||||
name: 2nd project
|
||||
ref_id: 'prj1:'
|
||||
number: 20
|
||||
- file: tests/board_samples/kicad_6/merge_3.kicad_sch
|
||||
ref_id: 'prj2:'
|
||||
number: 30
|
||||
columns:
|
||||
- References
|
||||
- Part
|
||||
- Value
|
||||
- Quantity Per PCB
|
||||
- field: manf#
|
||||
name: Manufacturer P/N
|
||||
xlsx:
|
||||
kicost: true
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_csv'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
format: CSV
|
||||
ref_id: 'A:'
|
||||
source_by_id: true
|
||||
use_alt: true
|
||||
aggregate:
|
||||
- file: tests/board_samples/kicad_6/merge_2.kicad_sch
|
||||
name: 2nd project
|
||||
ref_id: 'B:'
|
||||
number: 2
|
||||
- file: tests/board_samples/kicad_6/merge_3.kicad_sch
|
||||
ref_id: 'C:'
|
||||
number: 4
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_csv'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
format: HTML
|
||||
ref_id: 'A:'
|
||||
source_by_id: true
|
||||
use_alt: true
|
||||
aggregate:
|
||||
- file: tests/board_samples/kicad_6/merge_2.kicad_sch
|
||||
name: 2nd project
|
||||
ref_id: 'B:'
|
||||
number: 2
|
||||
- file: tests/board_samples/kicad_6/merge_3.kicad_sch
|
||||
ref_id: 'C:'
|
||||
number: 4
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_csv'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
format: XLSX
|
||||
ref_id: 'A:'
|
||||
source_by_id: true
|
||||
use_alt: true
|
||||
aggregate:
|
||||
- file: tests/board_samples/kicad_6/merge_2.kicad_sch
|
||||
name: 2nd project
|
||||
ref_id: 'B:'
|
||||
number: 2
|
||||
- file: tests/board_samples/kicad_6/merge_3.kicad_sch
|
||||
ref_id: 'C:'
|
||||
number: 4
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_csv'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
format: XML
|
||||
ref_id: 'A:'
|
||||
source_by_id: true
|
||||
use_alt: true
|
||||
aggregate:
|
||||
- file: tests/board_samples/kicad_6/merge_2.kicad_sch
|
||||
name: 2nd project
|
||||
ref_id: 'B:'
|
||||
number: 2
|
||||
- file: tests/board_samples/kicad_6/merge_3.kicad_sch
|
||||
ref_id: 'C:'
|
||||
number: 4
|
||||
|
||||
Loading…
Reference in New Issue