From 32310ba1fa0c4442695540c65998ddac3c932367 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 12 Feb 2021 14:56:51 -0300 Subject: [PATCH] Added test for makefile generation running the script from system. --- kibot/kiplot.py | 4 ++-- tests/test_plot/test_misc_2.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/kibot/kiplot.py b/kibot/kiplot.py index daccc447..4c08ab2c 100644 --- a/kibot/kiplot.py +++ b/kibot/kiplot.py @@ -360,14 +360,14 @@ def gen_global_targets(f, pre_targets, out_targets, type): return extra_targets -def generate_makefile(makefile, cfg_file, outputs): +def generate_makefile(makefile, cfg_file, outputs, kibot_sys=False): cfg_file = os.path.relpath(cfg_file) logger.info('- Creating makefile `{}` from `{}`'.format(makefile, cfg_file)) with open(makefile, 'wt') as f: f.write('#!/usr/bin/make\n') f.write('# Automatically generated by KiBot from `{}`\n'.format(cfg_file)) fname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src', 'kibot')) - if not os.path.isfile(fname): + if kibot_sys or not os.path.isfile(fname): fname = 'kibot' f.write('KIBOT={}\n'.format(fname)) dbg = '' diff --git a/tests/test_plot/test_misc_2.py b/tests/test_plot/test_misc_2.py index 9d38ace3..b2203f98 100644 --- a/tests/test_plot/test_misc_2.py +++ b/tests/test_plot/test_misc_2.py @@ -18,7 +18,7 @@ from kibot.layer import Layer from kibot.pre_base import BasePreFlight from kibot.out_base import BaseOutput from kibot.gs import GS -from kibot.kiplot import load_actions, _import, load_board, search_as_plugin +from kibot.kiplot import load_actions, _import, load_board, search_as_plugin, generate_makefile from kibot.registrable import RegOutput, RegFilter from kibot.misc import (MISSING_TOOL, WRONG_INSTALL, BOM_ERROR, DRC_ERROR, ERC_ERROR, PDF_PCB_PRINT, CMD_PCBNEW_PRINT_LAYERS, KICAD2STEP_ERR) @@ -317,3 +317,14 @@ def test_layer_no_id(): la.description = 'Top' la.suffix = 'F_Cu' assert str(la) == "F.Cu ('Top' F_Cu)" + + +def test_makefile_kibot_sys(test_dir): + ctx = context.TestContext(test_dir, 'test_makefile_kibot_sys', 'test_v5', 'empty_zip', '') + GS.sch_file = 'foo.sch' + GS.pcb_file = 'bar.kicad_pcb' + GS.out_dir = ctx.get_out_path('') + with context.cover_it(cov): + generate_makefile(ctx.get_out_path('Makefile'), 'pp', [], kibot_sys=True) + ctx.search_in_file('Makefile', ['KIBOT=kibot']) + ctx.clean_up()