# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2009, 2010 Dan McMahill
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of version 2 of the GNU General Public License as
#  published by the Free Software Foundation
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
#  All rights reserved.
#
# This code was derived from code written by Dan McMahill as part of the
# latex-mk testsuite.  The original code was covered by a BSD license
# but the copyright holder is releasing the version for pcb under the GPL.
#
#
# Format:
#
# test_name | layout file(s) | [export hid name] | [optional arguments to pcb] |  [mismatch]
# | output file(s)
#
# test_name - a single string with no spaces, tabs, *, +, ? (i.e. any "special"
# characters) that identifies the test.
#
# layout file(s) - a list of layout files.  Files listed are relative to
# the $(top_srcdir)/tests/inputs directory. Action tests are expected to have
# a like-named script file with .script suffix in the same directory.
#
# [export hid name] - the name of the export HID to use.  This is used both for
# running pcb as well as determining how we process the output.  For testing
# actions, which are independent from HIDs, put 'action' there.
#
# [optional arguments to pcb] - a list of additional arguments to be passed to pcb.
# This is where one would specify additional options which are specific to a particular
# export HID.
#
# [mismatch] If specified as "mismatch" (no quotes), then the result 
# should *not* match the reference.  This can be thought of as a test
# on the testsuite to make sure we can properly detect when a change has
# occurred.
#
# output file(s) - a list of output files and their associated types.  For
# example:
#  bom:bom_general.bom xy:test.txt
# specifies that "bom_general.bom" is created and it is a bill of materials file
# and that "test.txt" is created and it is a centroid (X-Y) file.
#
# File types grouped by which HID produces them are:
#
# BOM
#
#    bom -- PCB bill of materials file
#    xy  -- PCB centroid file
#
# GCODE
#
#    gcode -- G-Code file.  Note that these typically have .cnc as the 
#             extension but we're already using the 'cnc' type for 
#             Excellon drill files.
#
# GERBER
#
#    cnc -- Excellon drill file
#    gbx -- RS274-X (Gerber) file
#
# GSVIT
#
#    png -- Portable network graphics (PNG) file
#    xem -- Import file for numerical analysis package
#
# NELMA
#
#    png -- Portable network graphics (PNG) file
#    em  -- Import file for numerical analysis package
#
# PS
#
#    ps  -- PostScript file
#
# PNG
#
#    gif -- GIF file
#    jpg -- JPEG file
#    png -- Portable network graphics (PNG) file
#
# ACTIONS
#
#    ACTIONS act on the layout file directly, so input and output file
#    are of the same name.
#
######################################################################
# ---------------------------------------------
# BOM export HID
# ---------------------------------------------
######################################################################
#
# options:
#  --bomfile <string>             BOM output file
#  --xyfile <string>              XY output file
#  --xy-in-mm                     XY dimensions in mm instead of mils
#
#
# Produces a bill of materials (BOM) file and a centroid (XY) file
#
hid_bom1 | bom_general.pcb | bom | | | bom:bom_general.bom xy:bom_general.xy
hid_bom2 | bom_general.pcb | bom | --bomfile test.bom | | bom:test.bom xy:bom_general.xy
hid_bom3 | bom_general.pcb | bom | --xyfile  test.xy  | | bom:bom_general.bom xy:test.xy
hid_bom4 | bom_general.pcb | bom | --xy-in-mm | |  bom:bom_general.bom xy:bom_general.xy
#
######################################################################
# ---------------------------------------------
# Gcode export HID
# ---------------------------------------------
######################################################################
#
# options:
# --basename <string>            File name prefix and suffix.
# --measurement-unit <km|m|cm|mm|um|nm|px|in|mil|cmil>
#                                Measurement unit used in the G-code output.
# --dpi <num>                    Accuracy of the mill path generation in pixels/inch.
# --safe-Z <num>                 Safe Z for traverse movements of all operations.
# --iso-mill-depth <num>         Isolation milling depth.
# --iso-tool-diameter <num>      Isolation milling tool diameter.
# --iso-tool-plunge <num>        Isolation milling feedrate when plunging into
#                                the material.
# --iso-tool-feedrate <num>      Isolation milling feedrate.
# --predrill                     Whether to pre-drill all drill spots with the
#                                isolation milling tool.
# --drill-depth <num>            Drilling depth.
# --drill-feedrate <num>         Drilling feedrate.
# --drill-mill                   Whether to produce drill holes equal or bigger
#                                than the milling tool diameter with the milling
#                                tool.
# --outline-mill-depth <num>     Milling depth when milling the outline.
# --outline-tool-diameter <num>  Diameter of the tool used for outline milling.
# --outline-mill-plunge <num>    Outline milling feedrate when plunging into
#                                the material.
# --outline-mill-feedrate <num>  Outline milling feedrate.
# --advanced-gcode               Whether to produce G-code for advanced interpreters.
hid_gcode1 | gcode_oneline.pcb | gcode | | | gcode:gcode_oneline-0.8890.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode2 | gcode_oneline.pcb | gcode | --basename out.gcode | | gcode:out-0.8890.drill.gcode gcode:out-bottom.gcode gcode:out-outline.gcode gcode:out-top.gcode
hid_gcode3 | gcode_oneline.pcb | gcode | --dpi 1200 | | gcode:gcode_oneline-0.8890.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode4 | gcode_oneline.pcb | gcode | --iso-mill-depth 0.5 | | gcode:gcode_oneline-0.8890.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode5 | gcode_oneline.pcb | gcode | --safe-Z 10 | | gcode:gcode_oneline-0.8890.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode6 | gcode_oneline.pcb | gcode | --iso-tool-diameter 0.4 | | gcode:gcode_oneline-0.8890.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode7 | gcode_oneline.pcb | gcode | --drill-depth 7 | | gcode:gcode_oneline-0.8890.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode8 | gcode_oneline.pcb | gcode | --measurement-unit mm | | gcode:gcode_oneline-0.8890.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode9 | gcode_oneline.pcb | gcode | --measurement-unit mil | | gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-drillmill.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode10 | gcode_oneline.pcb | gcode | --measurement-unit um | | gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-drillmill.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
hid_gcode11 | gcode_oneline.pcb | gcode | --measurement-unit inch | | gcode:gcode_oneline-0.0350.drill.gcode gcode:gcode_oneline-bottom.gcode gcode:gcode_oneline-outline.gcode gcode:gcode_oneline-top.gcode
#
######################################################################
# ---------------------------------------------
# Gerber export HID
# ---------------------------------------------
######################################################################
#
# options:
#  --gerberfile <string>          Basename for output file
#
# Produces RS274-X (a.k.a. gerber) photo plot files and Excellon drill files
#
# we can't include gbx:gerber_oneline.fab.gbr yet because it has a name and a date stamp
hid_gerber1 | gerber_oneline.pcb | gerber | | | gbx:gerber_oneline.bottom.gbr  gbx:gerber_oneline.top.gbr cnc:gerber_oneline.plated-drill.cnc
hid_gerber2 | gerber_oneline.pcb | gerber | --gerberfile out | | gbx:out.bottom.gbr  gbx:out.top.gbr cnc:out.plated-drill.cnc
hid_gerber3 | gerber_arcs.pcb | gerber | --gerberfile arcs | | gbx:arcs.bottom.gbr gbx:arcs.top.gbr gbx:arcs.group1.gbr gbx:arcs.group4.gbr cnc:arcs.plated-drill.cnc
hid_gerber4 | buried.pcb | gerber | --gerberfile buried | | gbx:buried.bottom.gbr gbx:buried.top.gbr gbx:buried.group2.gbr gbx:buried.group4.gbr gbx:buried.group7.gbr cnc:buried.plated-drill.cnc cnc:buried.plated-drill_03-08.cnc
#
######################################################################
# ---------------------------------------------
# gsvit export HID
# ---------------------------------------------
######################################################################
#
# Produces one XML file and a png file for every layer group.
#
hid_gsvit1 | gsvit_board.pcb | gsvit | --basename gsvit_board --dpi 1000 | | png:gsvit_board.top.png
hid_gsvit2 | gsvit_board.pcb | gsvit | --basename gsvit_board --dpi 1000 | | png:gsvit_board.bottom.png
hid_gsvit3 | gsvit_board.pcb | gsvit | --basename gsvit_board --dpi 1000 | | png:gsvit_board.outline.png
hid_gsvit4 | gsvit_board.pcb | gsvit | --basename gsvit_board --dpi 1000 | | xem:gsvit_board.xem
#
######################################################################
# ---------------------------------------------
# IPC-D-356 export HID
# ---------------------------------------------
######################################################################
#
# Produces one netlist file.
#
hid_ipcd3561 | ipcd356_board.pcb | IPC-D-356 | --netlistfile ipcd356_board.net | | net:ipcd356_board.net
#
# test for inches and degrees
hid_ipcd3562 | ipcd356_cust0.pcb | IPC-D-356 | --netlistfile ipcd356_cust0.net | | net:ipcd356_cust0.net
#
# test for milimeters and degrees
hid_ipcd3563 | ipcd356_cust1.pcb | IPC-D-356 | --netlistfile ipcd356_cust1.net | | net:ipcd356_cust1.net
#
# a plain uncovered via
hid_ipcd3564 | ipcd356_via_1.pcb | IPC-D-356 | --netlistfile ipcd356_via_1.net | | net:ipcd356_via_1.net
#
# a tented via
hid_ipcd3565 | ipcd356_via_2.pcb | IPC-D-356 | --netlistfile ipcd356_via_2.net | | net:ipcd356_via_2.net
#
# a blind uncovered via (from top layer to layer 3 (power))
# FIXME: generated "S0" soldermask info is wrong, this should give "S1" soldermask info
#        via can only be tested on top layer (primary side)
hid_ipcd3566 | ipcd356_via_3.pcb | IPC-D-356 | --netlistfile ipcd356_via_3.net | | net:ipcd356_via_3.net
#
# a tented blind via (from top layer to layer 3 (power))
hid_ipcd3567 | ipcd356_via_4.pcb | IPC-D-356 | --netlistfile ipcd356_via_4.net | | net:ipcd356_via_4.net
#
# a blind uncovered via (from layer 1 (gnd) to bottom layer)
# FIXME: generated "S0" soldermask info is wrong, this should give "S2" soldermask info
#        via can only be tested on bottom layer (secondary side)
hid_ipcd3568 | ipcd356_via_5.pcb | IPC-D-356 | --netlistfile ipcd356_via_5.net | | net:ipcd356_via_5.net
#
# a blind tented via (from layer 1 (gnd) to bottom layer)
hid_ipcd3569 | ipcd356_via_6.pcb | IPC-D-356 | --netlistfile ipcd356_via_6.net | | net:ipcd356_via_6.net
#
# a buried uncovered via (from layer 1 (gnd) to bottom layer)
# FIXME: generated "S0" soldermask info is wrong, this should give "S3" soldermask info
#        via can not be tested 
hid_ipcd35610 | ipcd356_via_7.pcb | IPC-D-356 | --netlistfile ipcd356_via_7.net | | net:ipcd356_via_7.net
#
# a buried tented via (from layer 1 (gnd) to bottom layer)
hid_ipcd35611 | ipcd356_via_8.pcb | IPC-D-356 | --netlistfile ipcd356_via_8.net | | net:ipcd356_via_8.net
#
# a plain unplated and uncovered throuh hole
hid_ipcd35612 | ipcd356_hole_1.pcb | IPC-D-356 | --netlistfile ipcd356_hole_1.net | | net:ipcd356_hole_1.net
#
# a soldermask covered unplated plain through hole
hid_ipcd35613 | ipcd356_hole_2.pcb | IPC-D-356 | --netlistfile ipcd356_hole_2.net | | net:ipcd356_hole_2.net
#
# a smt capacitor on the top layer
hid_ipcd35614 | ipcd356_smt_1.pcb | IPC-D-356 | --netlistfile ipcd356_smt_1.net | | net:ipcd356_smt_1.net
#
# a smt capacitor on the bottom layer
hid_ipcd35615 | ipcd356_smt_2.pcb | IPC-D-356 | --netlistfile ipcd356_smt_2.net | | net:ipcd356_smt_2.net
#
# smt capacitor on both the top and the bottom layer
hid_ipcd35616 | ipcd356_smt_3.pcb | IPC-D-356 | --netlistfile ipcd356_smt_3.net | | net:ipcd356_smt_3.net
#
#
######################################################################
# ---------------------------------------------
# nelma export HID
# ---------------------------------------------
######################################################################
#
# Produces one em file and a png file for every layer group.
#
hid_nelma1 | nelma_board.pcb | nelma | --basename nelma_board --dpi 100 --copper-height 100 --substrate-height 2000 --substrate-epsilon 4.000 | | png:nelma_board.top.png
hid_nelma2 | nelma_board.pcb | nelma | --basename nelma_board --dpi 100 --copper-height 100 --substrate-height 2000 --substrate-epsilon 4.000 | | png:nelma_board.bottom.png
hid_nelma3 | nelma_board.pcb | nelma | --basename nelma_board --dpi 100 --copper-height 100 --substrate-height 2000 --substrate-epsilon 4.000 | | png:nelma_board.outline.png
hid_nelma4 | nelma_board.pcb | nelma | --basename nelma_board --dpi 100 --copper-height 100 --substrate-height 2000 --substrate-epsilon 4.000 | | em:nelma_board.em
#
######################################################################
# ---------------------------------------------
# PostScript export HID
# ---------------------------------------------
######################################################################
#
# Produces one PostScript file, unless asked to export into one file
# per page.
#
hid_ps1 | circles.pcb | ps | --psfile circles.ps | | ps:circles.ps
hid_ps2 | buried.pcb | ps | --psfile buried.ps | | ps:buried.ps
#
######################################################################
# ---------------------------------------------
# PNG export HID
# ---------------------------------------------
######################################################################
#
# options:
#   --outfile <string>             Graphics output file
#   --dpi <num>                    Scale factor (pixels/inch). 0 to scale to fix specified size
#   --x-max <num>                  Maximum width (pixels).  0 to not constrain.
#   --y-max <num>                  Maximum height (pixels).  0 to not constrain.
#   --xy-max <num>                 Maximum width and height (pixels).  0 to not constrain.
#   --as-shown                     Export layers as shown on screen
#   --monochrome                   Convert to monochrome
#   --only-visible                 Limit the bounds of the PNG file to the visible items
#   --use-alpha                    Make the bottomground and any holes transparent
#   --format <GIF|JPEG|PNG>        Graphics file format
#   --photo-mode                   Photo-realistic mode
#   --photo-flip-x                 Show reverse side of the board, left-right flip
#   --photo-flip-y                 Show reverse side of the board, up-down flip
#
# Produces GIF/JPEG/PNG (image) files
#
hid_png1 | gerber_oneline.pcb | png | | | png:gerber_oneline.png
hid_png2 | gerber_oneline.pcb | png | --outfile myfile.png | | png:myfile.png
hid_png3 | gerber_oneline.pcb | png | --dpi 600 | | png:gerber_oneline.png
#
######################################################################
# ---------------------------------------------
# Actions
# ---------------------------------------------
######################################################################
#
# Tested actions:
#
#   MinMaskGap()           Ensures that pins, pads and vias have a minimum
#                          solder mask gap.
#
# Produces a change in the input layout.
#
MinMaskGap | minmaskgap.script minmaskgap.pcb | action | | | pcb:minmaskgap.pcb
#
#
# Check that clearances are properly exported for each object on each layer.
# We have to do this because clearances are rendered on each layer, and some
# layers don't get cleared.
Clearance  | clearance.pcb | gerber | | | gbx:clearance.top.gbr gbx:clearance.group1.gbr gbx:clearance.group2.gbr gbx:clearance.group3.gbr gbx:clearance.bottom.gbr gbx:clearance.topmask.gbr gbx:clearance.bottommask.gbr

# For the ChangeClearSize action, we don't have to check the export, because 
# we know that the clearances are being applied to individual layers properly 
# from the previous test. We can just check the output pcb files.
ChangeClearSize-Sel | changeclearsize-sel.script clearance.pcb | action | | | pcb:clearance-non-zero.pcb pcb:clearance-min.pcb pcb:clearance-zero.pcb

# Check that the presence of features causes the correct version to be written to the file header. 
FileVersions | fileversion.script fileversion-20091103.pcb fileversion-20100606.pcb fileversion-20170218.pcb | action | | | pcb:fileversion-20091103-out.pcb pcb:fileversion-20100606-out.pcb pcb:fileversion-20170218-out.pcb
