Example #1
0
def test_miss_yaml():
    prj = 'bom'
    ctx = context.TestContext('MissingYaml', prj, 'pre_and_position', POS_DIR)
    ctx.run(EXIT_BAD_ARGS, no_yaml_file=True)

    assert ctx.search_err('No config file')

    ctx.clean_up()
Example #2
0
def test_3Rs_position_unified_csv(test_dir):
    """ Also test the quiet mode """
    ctx = context.TestContext(test_dir, '3Rs_position_unified_csv', '3Rs', 'simple_position_unified_csv', POS_DIR)
    ctx.run(no_verbose=True, extra=['-q'])
    expect_position(ctx, ctx.get_pos_both_csv_filename(), ['R1', 'R2'], ['R3'], csv=True)
    size = os.path.getsize(ctx.get_out_path('error.txt'))
    assert size == 0
    ctx.clean_up()
Example #3
0
def test_wrong_layer_big(test_dir):
    ctx = context.TestContext(test_dir, 'Wrong_Inner_Big', 'good-project')
    cmd = [PROG, 'export']
    layers = ['F.Cu', 'Inner.8']
    ctx.run(cmd, WRONG_LAYER_NAME, extra=layers)
    m = ctx.search_err(r"Inner.8 isn't a valid layer")
    assert m is not None
    ctx.clean_up()
Example #4
0
def test_miss_sch():
    prj = 'fail-project'
    ctx = context.TestContext('MissingSCH', prj, 'pre_and_position', POS_DIR)
    ctx.run(EXIT_BAD_ARGS, extra=['pos_ascii'])

    assert ctx.search_err('No SCH file found')

    ctx.clean_up()
Example #5
0
def test_wrong_pad_style_2(test_dir):
    ctx = context.TestContext(test_dir, 'wrong_pad_style_2', 'good-project')
    cmd = [PROG, 'export', '--pads', '3']
    layers = ['F.Cu', 'GND_Cu']
    ctx.run(cmd, WRONG_ARGUMENTS, extra=layers)
    m = ctx.search_err(r"Pad style must be 0, 1 or 2")
    assert m is not None
    ctx.clean_up()
Example #6
0
def test_wrong_layer_name_kiplot(test_dir):
    ctx = context.TestContext(test_dir, 'Wrong_Inner', 'good-project')
    cmd = [PROG, 'export']
    layers = ['F.Cu', 'Inner_1']
    ctx.run(cmd, WRONG_LAYER_NAME, extra=layers)
    m = ctx.search_err(r'Malformed inner layer name')
    assert m is not None
    ctx.clean_up()
Example #7
0
def test_wrong_layer_bogus(test_dir):
    ctx = context.TestContext(test_dir, 'Wrong_Inner_Name', 'good-project')
    cmd = [PROG, 'export']
    layers = ['F.Cu', 'GND_Cu']
    ctx.run(cmd, WRONG_LAYER_NAME, extra=layers)
    m = ctx.search_err(r"Unknown layer GND_Cu")
    assert m is not None
    ctx.clean_up()
Example #8
0
def test_wrong_scaling(test_dir):
    ctx = context.TestContext(test_dir, 'wrong_scaling', 'good-project')
    cmd = [PROG, 'export', '--scaling', 'A']
    layers = ['F.Cu', 'GND_Cu']
    ctx.run(cmd, WRONG_ARGUMENTS, extra=layers)
    m = ctx.search_err(r"Scaling must be a floating point value")
    assert m is not None
    ctx.clean_up()
Example #9
0
def test_drc_unco():
    """ Check we can ignore unconnected nets """
    prj = 'warning-project'
    ctx = context.TestContext('DRCUnco', prj, 'drc_unco', '')
    ctx.run()
    # Check all outputs are there
    ctx.expect_out_file('drc_result.rpt')
    ctx.clean_up()
Example #10
0
def test_drc_error():
    """ Check we catch DRC errors """
    prj = 'warning-project'
    ctx = context.TestContext('DRCError', prj, 'drc', '')
    ctx.run(DRC_ERROR)
    # Check all outputs are there
    ctx.expect_out_file('drc_result.rpt')
    ctx.clean_up()
Example #11
0
def test_drc_filter():
    prj = 'fail-project'
    ctx = context.TestContext('DRC_Filter', prj, 'drc_filter', '')
    ctx.run()
    # Check all outputs are there
    ctx.expect_out_file('drc_result.rpt')
    ctx.expect_out_file('kibot_errors.filter')
    ctx.clean_up()
Example #12
0
def test_erc_fail_1():
    """ Using an SCH with ERC errors """
    prj = 'fail-erc'
    ctx = context.TestContext('ERCFail1', prj, 'erc', '')
    ctx.run(ERC_ERROR)
    # Check all outputs are there
    ctx.expect_out_file(prj + '.erc')
    ctx.clean_up()
Example #13
0
def test_3Rs_position_unified_th():
    ctx = context.TestContext('3Rs_position_unified_th', '3Rs',
                              'simple_position_unified_th', POS_DIR)
    ctx.run()
    expect_position(ctx, os.path.join(POS_DIR,
                                      ctx.board_name + '-position.pos'),
                    ['R1', 'R2', 'R3'])
    ctx.clean_up()
Example #14
0
def test_rot_bottom(test_dir):
    ctx = context.TestContext(test_dir, 'test_rot_bottom', 'comp_bottom',
                              'simple_position_rot_bottom', POS_DIR)
    ctx.run()
    pos_bot = ctx.get_pos_both_filename()
    ctx.expect_out_file(pos_bot)
    expect_position(ctx, pos_bot, ['U1'], neg_x=True)
    ctx.clean_up()
Example #15
0
def test_example_2(test_dir):
    """ Example with board """
    ctx = context.TestContext(test_dir, 'Example2', 'good-project',
                              'pre_and_position', '')
    ctx.run(extra=['--example'], no_verbose=True, no_yaml_file=True)
    assert ctx.expect_out_file(EXAMPLE_CFG)
    ctx.search_in_file(EXAMPLE_CFG, ['layers: all'])
    ctx.clean_up()
Example #16
0
def test_print_pcb_options():
    prj = 'bom'
    ctx = context.TestContext('print_pcb_options', prj, 'print_pcb_options', PDF_DIR)
    ctx.run()
    # Check all outputs are there
    ctx.expect_out_file(PDF_FILE)
    ctx.compare_pdf(PDF_FILE)
    ctx.clean_up()
Example #17
0
def test_pcb_no_extension():
    """ KiCad can't load a PCB file without extension """
    prj = 'good-project'
    ctx = context.TestContext('PCB_no_extension', prj)
    cmd = [PROG, 'run_drc']
    ctx.run(cmd, WRONG_PCB_NAME, filename='Makefile')
    m = ctx.search_err(r'Input files must use an extension')
    assert m is not None
    ctx.clean_up()
Example #18
0
def test_3Rs_position_unified_th_csv():
    ctx = context.TestContext('3Rs_position_unified_th_csv', '3Rs',
                              'simple_position_unified_th_csv', POS_DIR)
    ctx.run()
    expect_position(ctx,
                    os.path.join(POS_DIR, 'Test_3Rs-both_pos_OK.csv'),
                    ['R1', 'R2', 'R3'],
                    csv=True)
    ctx.clean_up()
Example #19
0
def test_pcb_not_found():
    """ When the provided .kicad_pcb isn't there """
    prj = 'good-project'
    ctx = context.TestContext('PCB_not_found', prj)
    cmd = [PROG, 'run_drc']
    ctx.run(cmd, NO_PCB, filename='dummy')
    m = ctx.search_err(r'ERROR:.* does not exist')
    assert m is not None
    ctx.clean_up()
Example #20
0
def test_error_bom_no_columns(test_dir):
    ctx = context.TestContext(test_dir, 'BoMNoColumns', PRJ,
                              'error_bom_column', '')
    ctx.run(BOM_ERROR,
            no_board_file=True,
            extra=['-e',
                   os.path.join(ctx.get_board_dir(), 'bom_no_xml.sch')])
    assert ctx.search_err("Failed to get the column names")
    ctx.clean_up()
Example #21
0
def test_error_bom_no_field(test_dir):
    ctx = context.TestContext(test_dir, 'BoMNoField', PRJ,
                              'error_bom_no_field', '')
    ctx.run(EXIT_BAD_CONFIG,
            no_board_file=True,
            extra=['-e',
                   os.path.join(ctx.get_board_dir(), 'fail-erc.sch')])
    assert ctx.search_err("Missing or empty .?field.?")
    ctx.clean_up()
Example #22
0
def test_no_yaml(test_dir):
    ctx = context.TestContext(test_dir, 'test_no_yaml', 'bom', 'bom', '')
    cmd = [
        os.path.abspath(
            os.path.dirname(os.path.abspath(__file__)) +
            '/force_yaml_error.py')
    ]
    ctx.do_run(cmd, NO_YAML_MODULE)
    ctx.search_err('No yaml module for Python, install python3-yaml')
Example #23
0
def test_no_colorama(test_dir):
    ctx = context.TestContext(test_dir, 'test_no_colorama', 'bom', 'bom', '')
    cmd = [
        os.path.abspath(
            os.path.dirname(os.path.abspath(__file__)) +
            '/force_colorama_error.py')
    ]
    ctx.do_run(cmd, use_a_tty=True)
    ctx.search_err(r'\[31m.\[1mERROR:Testing 1 2 3')
Example #24
0
def test_print_pcb_good_dwg():
    ctx = context.TestContext('Print_Good_with_Dwg', 'good-project')
    pdf = 'good_pcb_with_dwg.pdf'
    cmd = [PROG, 'export', '--output_name', pdf]
    layers = ['F.Cu', 'F.SilkS', 'Dwgs.User', 'Edge.Cuts']
    ctx.run(cmd, extra=layers)
    ctx.expect_out_file(pdf)
    ctx.compare_image(pdf)
    ctx.clean_up()
Example #25
0
def test_example_4(test_dir):
    """ Expand copied layers """
    ctx = context.TestContext(test_dir, 'Example4', 'good-project',
                              'pre_and_position', '')
    ctx.run(extra=['--example', '-P'], no_verbose=True, no_yaml_file=True)
    assert ctx.expect_out_file(EXAMPLE_CFG)
    ctx.search_in_file(EXAMPLE_CFG, ['GND.Cu', 'pen_width: 35.0'])
    ctx.search_not_in_file(EXAMPLE_CFG, ['F.Adhes'])
    ctx.clean_up()
Example #26
0
def test_print_pcb_refill():
    ctx = context.TestContext('Print_Refill', 'zone-refill')
    pdf = 'zone-refill.pdf'
    cmd = [PROG, 'export', '-f', '--output_name', pdf]
    layers = ['F.Cu', 'B.Cu', 'Edge.Cuts']
    ctx.run(cmd, extra=layers)
    ctx.expect_out_file(pdf)
    ctx.compare_image(pdf)
    ctx.clean_up()
Example #27
0
def test_drc_save():
    """ Here we test a PCB with outdated zone fills.
        We run the DRC refilling, save it and then print. """
    ctx = context.TestContext('DRC_Save_1', 'zone-refill')
    shutil.copy2(ctx.board_file + '.ok', ctx.board_file)
    cmd = [PROG, 'run_drc', '-s']
    ctx.run(cmd)
    ctx.expect_out_file(REPORT)
    ctx.clean_up()

    ctx = context.TestContext('DRC_Save_2', 'zone-refill')
    cmd = [PROG, 'export']
    layers = ['F.Cu', 'B.Cu', 'Edge.Cuts']
    ctx.run(cmd, extra=layers)
    ctx.expect_out_file(DEFAULT)
    ctx.compare_image(DEFAULT, 'zone-refill.pdf')
    shutil.copy2(ctx.board_file + '.ok', ctx.board_file)
    ctx.clean_up()
Example #28
0
def test_print_variant_1():
    prj = 'kibom-variant_3'
    ctx = context.TestContext('test_print_variant_1', prj, 'print_pcb_variant_1', '')
    ctx.run()
    # Check all outputs are there
    fname = prj+'-F_Fab.pdf'
    ctx.expect_out_file(fname)
    ctx.compare_pdf(fname)
    ctx.clean_up()
Example #29
0
def test_ibom_no_ops():
    prj = 'bom'
    ctx = context.TestContext('BoM_interactiveNoOps', prj, 'ibom_no_ops',
                              BOM_DIR)
    ctx.run()
    fname = os.path.join(BOM_DIR, IBOM_OUT)
    ctx.expect_out_file(fname)
    check_modules(ctx, IBOM_OUT, ['C1', 'R1', 'R2'])
    ctx.clean_up()
Example #30
0
def test_gerber_inner_ok():
    prj = 'good-project'
    ctx = context.TestContext('Gerber_Inner', prj, 'gerber_inner', GERBER_DIR)
    ctx.run()

    ctx.expect_out_file(os.path.join(GERBER_DIR, prj + '_GND_Cu.gbr'))
    ctx.expect_out_file(os.path.join(GERBER_DIR, prj + '_Signal1.gbr'))
    ctx.expect_out_file(os.path.join(GERBER_DIR, 'test-' + prj + '.gbrjob'))
    ctx.clean_up()