From 5a23fe2b376fb09f65625ff85f02f237c957016f Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 25 May 2020 19:49:05 -0300 Subject: [PATCH] Added tests for various cases of --skip command line option. --- tests/test_plot/test_misc.py | 72 +++++++++++++++++++ .../yaml_samples/pre_and_position.kiplot.yaml | 21 ++++++ 2 files changed, 93 insertions(+) create mode 100644 tests/test_plot/test_misc.py create mode 100644 tests/yaml_samples/pre_and_position.kiplot.yaml diff --git a/tests/test_plot/test_misc.py b/tests/test_plot/test_misc.py new file mode 100644 index 00000000..8e6ec05d --- /dev/null +++ b/tests/test_plot/test_misc.py @@ -0,0 +1,72 @@ +""" +Tests miscellaneous stuff. + +- -s all -i +- -s run_erc,update_xml,run_drc -i +- -s all,run_drc +- -s bogus + +For debug information use: +pytest-3 --log-cli-level debug +""" + +import os +import sys +# Look for the 'utils' module from where the script is running +prev_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.dirname(prev_dir)) +# Utils import +from utils import context +sys.path.insert(0, os.path.dirname(prev_dir)) +from kiplot.misc import (EXIT_BAD_ARGS) + + +POS_DIR = 'positiondir' + + +def test_skip_pre_and_outputs(): + prj = 'simple_2layer' + ctx = context.TestContext('SkipPreAndPos', prj, 'pre_and_position', POS_DIR) + ctx.run(extra=['-s', 'all', '-i']) + + ctx.dont_expect_out_file(ctx.get_pos_both_csv_filename()) + assert ctx.search_err('Skipping all pre-flight actions') + assert ctx.search_err('Skipping all outputs') + + ctx.clean_up() + + +def test_skip_pre_and_outputs_2(): + prj = 'simple_2layer' + ctx = context.TestContext('SkipPreAndPos2', prj, 'pre_and_position', POS_DIR) + ctx.run(extra=['-s', 'run_erc,update_xml,run_drc', '-i']) + + ctx.dont_expect_out_file(ctx.get_pos_both_csv_filename()) + assert ctx.search_err('Skipping run_erc') + assert ctx.search_err('Skipping run_drc') + assert ctx.search_err('Skipping update_xml') + assert ctx.search_err('Skipping all outputs') + + ctx.clean_up() + + +def test_skip_pre_and_outputs_3(): + prj = 'simple_2layer' + ctx = context.TestContext('SkipPreAndPos3', prj, 'pre_and_position', POS_DIR) + ctx.run(EXIT_BAD_ARGS, extra=['-s', 'all,run_drc']) + + ctx.dont_expect_out_file(ctx.get_pos_both_csv_filename()) + assert ctx.search_err('Use `--skip all`') + + ctx.clean_up() + + +def test_skip_pre_and_outputs_4(): + prj = 'simple_2layer' + ctx = context.TestContext('SkipPreAndPos4', prj, 'pre_and_position', POS_DIR) + ctx.run(EXIT_BAD_ARGS, extra=['-s', 'bogus']) + + ctx.dont_expect_out_file(ctx.get_pos_both_csv_filename()) + assert ctx.search_err('Unknown action to skip: bogus') + + ctx.clean_up() diff --git a/tests/yaml_samples/pre_and_position.kiplot.yaml b/tests/yaml_samples/pre_and_position.kiplot.yaml new file mode 100644 index 00000000..5d17518e --- /dev/null +++ b/tests/yaml_samples/pre_and_position.kiplot.yaml @@ -0,0 +1,21 @@ +# Example KiPlot config file +kiplot: + version: 1 + +preflight: + run_erc: true + update_xml: true + run_drc: true + check_zone_fills: true + ignore_unconnected: false + +outputs: + - name: 'position' + comment: "Pick and place file" + type: position + dir: positiondir + options: + format: CSV # CSV or ASCII format + units: millimeters # millimeters or inches + separate_files_for_front_and_back: false + only_smd: true \ No newline at end of file