Catched error of using set_text_variables with KiCad 5
This commit is contained in:
parent
2d86f9516d
commit
82aac838d5
|
|
@ -1,13 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2020-2021 Salvador E. Tropea
|
# Copyright (c) 2020-2022 Salvador E. Tropea
|
||||||
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
|
# Copyright (c) 2020-2022 Instituto Nacional de Tecnología Industrial
|
||||||
# License: GPL-3.0
|
# License: GPL-3.0
|
||||||
# Project: KiBot (formerly KiPlot)
|
# Project: KiBot (formerly KiPlot)
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
from .registrable import Registrable
|
from .registrable import Registrable
|
||||||
from .optionable import Optionable
|
from .optionable import Optionable
|
||||||
from .error import PlotError
|
from .error import PlotError, KiPlotConfigurationError
|
||||||
from .misc import PLOT_ERROR
|
from .misc import PLOT_ERROR, EXIT_BAD_CONFIG
|
||||||
from .log import get_logger
|
from .log import get_logger
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
@ -66,6 +66,9 @@ class BasePreFlight(Registrable):
|
||||||
except PlotError as e:
|
except PlotError as e:
|
||||||
logger.error("In preflight `"+str(k)+"`: "+str(e))
|
logger.error("In preflight `"+str(k)+"`: "+str(e))
|
||||||
exit(PLOT_ERROR)
|
exit(PLOT_ERROR)
|
||||||
|
except KiPlotConfigurationError as e:
|
||||||
|
logger.error("In preflight `"+str(k)+"`: "+str(e))
|
||||||
|
exit(EXIT_BAD_CONFIG)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self._enabled = False
|
self._enabled = False
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ if prev_dir not in sys.path:
|
||||||
sys.path.insert(0, prev_dir)
|
sys.path.insert(0, prev_dir)
|
||||||
# Utils import
|
# Utils import
|
||||||
from utils import context
|
from utils import context
|
||||||
from kibot.misc import (DRC_ERROR, ERC_ERROR, BOM_ERROR, CORRUPTED_PCB, CORRUPTED_SCH)
|
from kibot.misc import (DRC_ERROR, ERC_ERROR, BOM_ERROR, CORRUPTED_PCB, CORRUPTED_SCH, EXIT_BAD_CONFIG)
|
||||||
|
|
||||||
|
|
||||||
def test_erc_1(test_dir):
|
def test_erc_1(test_dir):
|
||||||
|
|
@ -203,6 +203,7 @@ def test_sch_replace_1(test_dir):
|
||||||
finally:
|
finally:
|
||||||
for k, v in files.items():
|
for k, v in files.items():
|
||||||
os.rename(v, k)
|
os.rename(v, k)
|
||||||
|
ctx.clean_up()
|
||||||
|
|
||||||
|
|
||||||
def test_pcb_replace_1(test_dir):
|
def test_pcb_replace_1(test_dir):
|
||||||
|
|
@ -232,26 +233,31 @@ def test_pcb_replace_1(test_dir):
|
||||||
assert m.group(1) == text
|
assert m.group(1) == text
|
||||||
finally:
|
finally:
|
||||||
os.rename(file_back, file)
|
os.rename(file_back, file)
|
||||||
|
ctx.clean_up(keep_project=True)
|
||||||
|
|
||||||
|
|
||||||
def test_set_text_variables_1(test_dir):
|
def test_set_text_variables_1(test_dir):
|
||||||
""" KiCad 6 variables """
|
""" KiCad 6 variables """
|
||||||
prj = 'light_control'
|
prj = 'light_control'
|
||||||
ctx = context.TestContext(test_dir, 'test_set_text_variables_1', prj, 'set_text_variables_1', '')
|
ctx = context.TestContext(test_dir, 'test_set_text_variables_1', prj, 'set_text_variables_1', '')
|
||||||
ctx.run(extra=[])
|
if context.ki5():
|
||||||
file = os.path.join(ctx.get_board_dir(), ctx.board_name+context.PRO_EXT)
|
ctx.run(EXIT_BAD_CONFIG)
|
||||||
file_back = file + '-bak'
|
else:
|
||||||
assert os.path.isfile(file_back), file_back
|
ctx.run()
|
||||||
assert os.path.getsize(file_back) > 0
|
file = os.path.join(ctx.get_board_dir(), ctx.board_name+context.PRO_EXT)
|
||||||
try:
|
file_back = file + '-bak'
|
||||||
logging.debug(file)
|
assert os.path.isfile(file_back), file_back
|
||||||
cmd = ['/bin/bash', '-c', "git log -1 --format='%h' " + ctx.board_file]
|
assert os.path.getsize(file_back) > 0
|
||||||
text = "Git_hash:'" + run(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True).stdout.strip() + "' ({})".format(prj)
|
try:
|
||||||
with open(file, 'rt') as f:
|
logging.debug(file)
|
||||||
c = f.read()
|
cmd = ['/bin/bash', '-c', "git log -1 --format='%h' " + ctx.board_file]
|
||||||
data = json.loads(c)
|
text = "Git_hash:'"+run(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True).stdout.strip()+"' ({})".format(prj)
|
||||||
assert 'text_variables' in data
|
with open(file, 'rt') as f:
|
||||||
assert 'Comment4' in data['text_variables']
|
c = f.read()
|
||||||
assert data['text_variables']['Comment4'] == text
|
data = json.loads(c)
|
||||||
finally:
|
assert 'text_variables' in data
|
||||||
os.rename(file_back, file)
|
assert 'Comment4' in data['text_variables']
|
||||||
|
assert data['text_variables']['Comment4'] == text
|
||||||
|
finally:
|
||||||
|
os.rename(file_back, file)
|
||||||
|
ctx.clean_up(keep_project=True)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue