From 4105718ec62c43273f6f55d09cdbfa9fc0bcc2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1n=20D=C3=A9nes?= Date: Sat, 17 Jul 2021 15:23:19 +0200 Subject: [PATCH] Complete CLI testing --- test/cli/bad_input/bad.yaml | 1 + test/cli/bad_input/command | 1 + test/cli/bad_input/error | 1 + test/cli/big/command | 1 + test/cli/big/log | 13 ++ test/cli/big/reference/canonical.yaml | 33 ++++++ test/cli/big/reference/cases/_export.jscad | 36 ++++++ test/cli/big/reference/cases/_export.stl | 86 ++++++++++++++ test/cli/big/reference/cases/export.jscad | 36 ++++++ test/cli/big/reference/cases/export.stl | 86 ++++++++++++++ test/cli/big/reference/outlines/_export.dxf | 98 +++++++++++++++ test/cli/big/reference/outlines/_export.json | 91 ++++++++++++++ test/cli/big/reference/outlines/_export.svg | 1 + test/cli/big/reference/outlines/export.dxf | 98 +++++++++++++++ test/cli/big/reference/outlines/export.json | 91 ++++++++++++++ test/cli/big/reference/outlines/export.svg | 1 + test/cli/big/reference/pcbs/_export.kicad_pcb | 112 ++++++++++++++++++ test/cli/big/reference/pcbs/export.kicad_pcb | 112 ++++++++++++++++++ .../{basic => big}/reference/points/demo.dxf | 0 .../{basic => big}/reference/points/demo.json | 0 .../{basic => big}/reference/points/demo.svg | 0 .../reference/points/points.json | 0 test/cli/big/reference/raw.txt | 24 ++++ test/cli/big/reference/units.json | 6 + test/cli/medium/command | 1 + test/cli/medium/log | 12 ++ test/cli/medium/reference/outlines/export.dxf | 98 +++++++++++++++ .../medium/reference/pcbs/export.kicad_pcb | 112 ++++++++++++++++++ test/cli/{basic => minimal}/command | 0 test/cli/{basic => minimal}/log | 2 +- .../reference/canonical.yaml | 0 test/cli/minimal/reference/points/demo.dxf | 98 +++++++++++++++ test/cli/minimal/reference/points/demo.json | 69 +++++++++++ test/cli/minimal/reference/points/demo.svg | 1 + test/cli/minimal/reference/points/points.json | 34 ++++++ test/cli/{basic => minimal}/reference/raw.txt | 0 .../{basic => minimal}/reference/units.json | 0 test/cli/nonexistent_input/command | 1 + test/cli/nonexistent_input/error | 1 + test/fixtures/medium.yaml | 9 ++ test/index.js | 25 +++- 41 files changed, 1384 insertions(+), 7 deletions(-) create mode 100644 test/cli/bad_input/bad.yaml create mode 100644 test/cli/bad_input/command create mode 100644 test/cli/bad_input/error create mode 100644 test/cli/big/command create mode 100644 test/cli/big/log create mode 100644 test/cli/big/reference/canonical.yaml create mode 100644 test/cli/big/reference/cases/_export.jscad create mode 100644 test/cli/big/reference/cases/_export.stl create mode 100644 test/cli/big/reference/cases/export.jscad create mode 100644 test/cli/big/reference/cases/export.stl create mode 100644 test/cli/big/reference/outlines/_export.dxf create mode 100644 test/cli/big/reference/outlines/_export.json create mode 100644 test/cli/big/reference/outlines/_export.svg create mode 100644 test/cli/big/reference/outlines/export.dxf create mode 100644 test/cli/big/reference/outlines/export.json create mode 100644 test/cli/big/reference/outlines/export.svg create mode 100644 test/cli/big/reference/pcbs/_export.kicad_pcb create mode 100644 test/cli/big/reference/pcbs/export.kicad_pcb rename test/cli/{basic => big}/reference/points/demo.dxf (100%) rename test/cli/{basic => big}/reference/points/demo.json (100%) rename test/cli/{basic => big}/reference/points/demo.svg (100%) rename test/cli/{basic => big}/reference/points/points.json (100%) create mode 100644 test/cli/big/reference/raw.txt create mode 100644 test/cli/big/reference/units.json create mode 100644 test/cli/medium/command create mode 100644 test/cli/medium/log create mode 100644 test/cli/medium/reference/outlines/export.dxf create mode 100644 test/cli/medium/reference/pcbs/export.kicad_pcb rename test/cli/{basic => minimal}/command (100%) rename test/cli/{basic => minimal}/log (91%) rename test/cli/{basic => minimal}/reference/canonical.yaml (100%) create mode 100644 test/cli/minimal/reference/points/demo.dxf create mode 100644 test/cli/minimal/reference/points/demo.json create mode 100644 test/cli/minimal/reference/points/demo.svg create mode 100644 test/cli/minimal/reference/points/points.json rename test/cli/{basic => minimal}/reference/raw.txt (100%) rename test/cli/{basic => minimal}/reference/units.json (100%) create mode 100644 test/cli/nonexistent_input/command create mode 100644 test/cli/nonexistent_input/error create mode 100644 test/fixtures/medium.yaml diff --git a/test/cli/bad_input/bad.yaml b/test/cli/bad_input/bad.yaml new file mode 100644 index 0000000..08ff39c --- /dev/null +++ b/test/cli/bad_input/bad.yaml @@ -0,0 +1 @@ +'bad input' \ No newline at end of file diff --git a/test/cli/bad_input/command b/test/cli/bad_input/command new file mode 100644 index 0000000..0908d04 --- /dev/null +++ b/test/cli/bad_input/command @@ -0,0 +1 @@ +node src/cli.js test/cli/bad_input/bad.yaml diff --git a/test/cli/bad_input/error b/test/cli/bad_input/error new file mode 100644 index 0000000..2ed6722 --- /dev/null +++ b/test/cli/bad_input/error @@ -0,0 +1 @@ +Error: Input doesn't resolve into an object! diff --git a/test/cli/big/command b/test/cli/big/command new file mode 100644 index 0000000..0e62ec1 --- /dev/null +++ b/test/cli/big/command @@ -0,0 +1 @@ +node src/cli.js test/fixtures/big.yaml --debug --clean diff --git a/test/cli/big/log b/test/cli/big/log new file mode 100644 index 0000000..a44a320 --- /dev/null +++ b/test/cli/big/log @@ -0,0 +1,13 @@ +Ergogen CLI (Debug Mode) + +Interpreting format: YAML +Preprocessing input... +Calculating variables... +Parsing points... +Generating outlines... +Extruding cases... +Scaffolding PCBs... +Cleaning output folder... +Writing output to disk... +Done. + diff --git a/test/cli/big/reference/canonical.yaml b/test/cli/big/reference/canonical.yaml new file mode 100644 index 0000000..bcd5013 --- /dev/null +++ b/test/cli/big/reference/canonical.yaml @@ -0,0 +1,33 @@ +units: + a: 28 + u +points: + zones: + matrix: + columns: + col: {} + rows: + row: {} +outlines: + exports: + export: + - + type: keys + side: left + size: 18 + _export: + - + type: keys + side: left + size: 18 +cases: + export: + - + name: export + extrude: 1 + _export: + - + name: export + extrude: 1 +pcbs: + export: {} + _export: {} diff --git a/test/cli/big/reference/cases/_export.jscad b/test/cli/big/reference/cases/_export.jscad new file mode 100644 index 0000000..a98416f --- /dev/null +++ b/test/cli/big/reference/cases/_export.jscad @@ -0,0 +1,36 @@ +function export_outline_fn(){ + return new CSG.Path2D([[-9,-9],[9,-9]]).appendPoint([9,9]).appendPoint([-9,9]).appendPoint([-9,-9]).close().innerToCAG() +.extrude({ offset: [0, 0, 1] }); +} + + + + + function _export_case_fn() { + + + // creating part 0 of case _export + let _export__part_0 = export_outline_fn(); + + // make sure that rotations are relative + let _export__part_0_bounds = _export__part_0.getBounds(); + let _export__part_0_x = _export__part_0_bounds[0].x + (_export__part_0_bounds[1].x - _export__part_0_bounds[0].x) / 2 + let _export__part_0_y = _export__part_0_bounds[0].y + (_export__part_0_bounds[1].y - _export__part_0_bounds[0].y) / 2 + _export__part_0 = translate([-_export__part_0_x, -_export__part_0_y, 0], _export__part_0); + _export__part_0 = rotate([0,0,0], _export__part_0); + _export__part_0 = translate([_export__part_0_x, _export__part_0_y, 0], _export__part_0); + + _export__part_0 = translate([0,0,0], _export__part_0); + let result = _export__part_0; + + + return result; + } + + + + function main() { + return _export_case_fn(); + } + + \ No newline at end of file diff --git a/test/cli/big/reference/cases/_export.stl b/test/cli/big/reference/cases/_export.stl new file mode 100644 index 0000000..0cdcee2 --- /dev/null +++ b/test/cli/big/reference/cases/_export.stl @@ -0,0 +1,86 @@ +solid csg.js +facet normal 0 0 -1 +outer loop +vertex -9 9 0 +vertex 9 9 0 +vertex 9 -9 0 +endloop +endfacet +facet normal 0 0 -1 +outer loop +vertex -9 9 0 +vertex 9 -9 0 +vertex -9 -9 0 +endloop +endfacet +facet normal 0 0 1 +outer loop +vertex -9 9 1 +vertex -9 -9 1 +vertex 9 -9 1 +endloop +endfacet +facet normal 0 0 1 +outer loop +vertex -9 9 1 +vertex 9 -9 1 +vertex 9 9 1 +endloop +endfacet +facet normal 0 -1 0 +outer loop +vertex 9 -9 0 +vertex 9 -9 1 +vertex -9 -9 1 +endloop +endfacet +facet normal 0 -1 0 +outer loop +vertex 9 -9 0 +vertex -9 -9 1 +vertex -9 -9 0 +endloop +endfacet +facet normal 1 0 0 +outer loop +vertex 9 9 0 +vertex 9 9 1 +vertex 9 -9 1 +endloop +endfacet +facet normal 1 0 0 +outer loop +vertex 9 9 0 +vertex 9 -9 1 +vertex 9 -9 0 +endloop +endfacet +facet normal 0 1 0 +outer loop +vertex 9 9 1 +vertex 9 9 0 +vertex -9 9 0 +endloop +endfacet +facet normal 0 1 0 +outer loop +vertex 9 9 1 +vertex -9 9 0 +vertex -9 9 1 +endloop +endfacet +facet normal -1 0 0 +outer loop +vertex -9 9 1 +vertex -9 9 0 +vertex -9 -9 0 +endloop +endfacet +facet normal -1 0 0 +outer loop +vertex -9 9 1 +vertex -9 -9 0 +vertex -9 -9 1 +endloop +endfacet +endsolid csg.js diff --git a/test/cli/big/reference/cases/export.jscad b/test/cli/big/reference/cases/export.jscad new file mode 100644 index 0000000..6ccb677 --- /dev/null +++ b/test/cli/big/reference/cases/export.jscad @@ -0,0 +1,36 @@ +function export_outline_fn(){ + return new CSG.Path2D([[-9,-9],[9,-9]]).appendPoint([9,9]).appendPoint([-9,9]).appendPoint([-9,-9]).close().innerToCAG() +.extrude({ offset: [0, 0, 1] }); +} + + + + + function export_case_fn() { + + + // creating part 0 of case export + let export__part_0 = export_outline_fn(); + + // make sure that rotations are relative + let export__part_0_bounds = export__part_0.getBounds(); + let export__part_0_x = export__part_0_bounds[0].x + (export__part_0_bounds[1].x - export__part_0_bounds[0].x) / 2 + let export__part_0_y = export__part_0_bounds[0].y + (export__part_0_bounds[1].y - export__part_0_bounds[0].y) / 2 + export__part_0 = translate([-export__part_0_x, -export__part_0_y, 0], export__part_0); + export__part_0 = rotate([0,0,0], export__part_0); + export__part_0 = translate([export__part_0_x, export__part_0_y, 0], export__part_0); + + export__part_0 = translate([0,0,0], export__part_0); + let result = export__part_0; + + + return result; + } + + + + function main() { + return export_case_fn(); + } + + \ No newline at end of file diff --git a/test/cli/big/reference/cases/export.stl b/test/cli/big/reference/cases/export.stl new file mode 100644 index 0000000..0cdcee2 --- /dev/null +++ b/test/cli/big/reference/cases/export.stl @@ -0,0 +1,86 @@ +solid csg.js +facet normal 0 0 -1 +outer loop +vertex -9 9 0 +vertex 9 9 0 +vertex 9 -9 0 +endloop +endfacet +facet normal 0 0 -1 +outer loop +vertex -9 9 0 +vertex 9 -9 0 +vertex -9 -9 0 +endloop +endfacet +facet normal 0 0 1 +outer loop +vertex -9 9 1 +vertex -9 -9 1 +vertex 9 -9 1 +endloop +endfacet +facet normal 0 0 1 +outer loop +vertex -9 9 1 +vertex 9 -9 1 +vertex 9 9 1 +endloop +endfacet +facet normal 0 -1 0 +outer loop +vertex 9 -9 0 +vertex 9 -9 1 +vertex -9 -9 1 +endloop +endfacet +facet normal 0 -1 0 +outer loop +vertex 9 -9 0 +vertex -9 -9 1 +vertex -9 -9 0 +endloop +endfacet +facet normal 1 0 0 +outer loop +vertex 9 9 0 +vertex 9 9 1 +vertex 9 -9 1 +endloop +endfacet +facet normal 1 0 0 +outer loop +vertex 9 9 0 +vertex 9 -9 1 +vertex 9 -9 0 +endloop +endfacet +facet normal 0 1 0 +outer loop +vertex 9 9 1 +vertex 9 9 0 +vertex -9 9 0 +endloop +endfacet +facet normal 0 1 0 +outer loop +vertex 9 9 1 +vertex -9 9 0 +vertex -9 9 1 +endloop +endfacet +facet normal -1 0 0 +outer loop +vertex -9 9 1 +vertex -9 9 0 +vertex -9 -9 0 +endloop +endfacet +facet normal -1 0 0 +outer loop +vertex -9 9 1 +vertex -9 -9 0 +vertex -9 -9 1 +endloop +endfacet +endsolid csg.js diff --git a/test/cli/big/reference/outlines/_export.dxf b/test/cli/big/reference/outlines/_export.dxf new file mode 100644 index 0000000..0d161b6 --- /dev/null +++ b/test/cli/big/reference/outlines/_export.dxf @@ -0,0 +1,98 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-9 +20 +-9 +11 +9 +21 +-9 +0 +LINE +8 +0 +10 +9 +20 +-9 +11 +9 +21 +9 +0 +LINE +8 +0 +10 +9 +20 +9 +11 +-9 +21 +9 +0 +LINE +8 +0 +10 +-9 +20 +9 +11 +-9 +21 +-9 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/cli/big/reference/outlines/_export.json b/test/cli/big/reference/outlines/_export.json new file mode 100644 index 0000000..74d8810 --- /dev/null +++ b/test/cli/big/reference/outlines/_export.json @@ -0,0 +1,91 @@ +{ + "models": { + "export": { + "models": { + "a": { + "models": {}, + "origin": [ + 0, + 0 + ] + }, + "b": { + "models": { + "a": { + "models": {}, + "origin": [ + 0, + 0 + ] + }, + "b": { + "paths": { + "ShapeLine1": { + "type": "line", + "origin": [ + -9, + -9 + ], + "end": [ + 9, + -9 + ] + }, + "ShapeLine2": { + "type": "line", + "origin": [ + 9, + -9 + ], + "end": [ + 9, + 9 + ] + }, + "ShapeLine3": { + "type": "line", + "origin": [ + 9, + 9 + ], + "end": [ + -9, + 9 + ] + }, + "ShapeLine4": { + "type": "line", + "origin": [ + -9, + 9 + ], + "end": [ + -9, + -9 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "units": "mm", + "origin": [ + 0, + 0 + ] +} diff --git a/test/cli/big/reference/outlines/_export.svg b/test/cli/big/reference/outlines/_export.svg new file mode 100644 index 0000000..5212641 --- /dev/null +++ b/test/cli/big/reference/outlines/_export.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/cli/big/reference/outlines/export.dxf b/test/cli/big/reference/outlines/export.dxf new file mode 100644 index 0000000..0d161b6 --- /dev/null +++ b/test/cli/big/reference/outlines/export.dxf @@ -0,0 +1,98 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-9 +20 +-9 +11 +9 +21 +-9 +0 +LINE +8 +0 +10 +9 +20 +-9 +11 +9 +21 +9 +0 +LINE +8 +0 +10 +9 +20 +9 +11 +-9 +21 +9 +0 +LINE +8 +0 +10 +-9 +20 +9 +11 +-9 +21 +-9 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/cli/big/reference/outlines/export.json b/test/cli/big/reference/outlines/export.json new file mode 100644 index 0000000..74d8810 --- /dev/null +++ b/test/cli/big/reference/outlines/export.json @@ -0,0 +1,91 @@ +{ + "models": { + "export": { + "models": { + "a": { + "models": {}, + "origin": [ + 0, + 0 + ] + }, + "b": { + "models": { + "a": { + "models": {}, + "origin": [ + 0, + 0 + ] + }, + "b": { + "paths": { + "ShapeLine1": { + "type": "line", + "origin": [ + -9, + -9 + ], + "end": [ + 9, + -9 + ] + }, + "ShapeLine2": { + "type": "line", + "origin": [ + 9, + -9 + ], + "end": [ + 9, + 9 + ] + }, + "ShapeLine3": { + "type": "line", + "origin": [ + 9, + 9 + ], + "end": [ + -9, + 9 + ] + }, + "ShapeLine4": { + "type": "line", + "origin": [ + -9, + 9 + ], + "end": [ + -9, + -9 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "units": "mm", + "origin": [ + 0, + 0 + ] +} diff --git a/test/cli/big/reference/outlines/export.svg b/test/cli/big/reference/outlines/export.svg new file mode 100644 index 0000000..5212641 --- /dev/null +++ b/test/cli/big/reference/outlines/export.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/cli/big/reference/pcbs/_export.kicad_pcb b/test/cli/big/reference/pcbs/_export.kicad_pcb new file mode 100644 index 0000000..3e5ec29 --- /dev/null +++ b/test/cli/big/reference/pcbs/_export.kicad_pcb @@ -0,0 +1,112 @@ + + +(kicad_pcb (version 20171130) (host pcbnew 5.1.6) + + (page A3) + (title_block + (title KEYBOARD_NAME_HERE) + (rev VERSION_HERE) + (company YOUR_NAME_HERE) + ) + + (general + (thickness 1.6) + ) + + (layers + (0 F.Cu signal) + (31 B.Cu signal) + (32 B.Adhes user) + (33 F.Adhes user) + (34 B.Paste user) + (35 F.Paste user) + (36 B.SilkS user) + (37 F.SilkS user) + (38 B.Mask user) + (39 F.Mask user) + (40 Dwgs.User user) + (41 Cmts.User user) + (42 Eco1.User user) + (43 Eco2.User user) + (44 Edge.Cuts user) + (45 Margin user) + (46 B.CrtYd user) + (47 F.CrtYd user) + (48 B.Fab user) + (49 F.Fab user) + ) + + (setup + (last_trace_width 0.25) + (trace_clearance 0.2) + (zone_clearance 0.508) + (zone_45_only no) + (trace_min 0.2) + (via_size 0.8) + (via_drill 0.4) + (via_min_size 0.4) + (via_min_drill 0.3) + (uvia_size 0.3) + (uvia_drill 0.1) + (uvias_allowed no) + (uvia_min_size 0.2) + (uvia_min_drill 0.1) + (edge_width 0.05) + (segment_width 0.2) + (pcb_text_width 0.3) + (pcb_text_size 1.5 1.5) + (mod_edge_width 0.12) + (mod_text_size 1 1) + (mod_text_width 0.15) + (pad_size 1.524 1.524) + (pad_drill 0.762) + (pad_to_mask_clearance 0.05) + (aux_axis_origin 0 0) + (visible_elements FFFFFF7F) + (pcbplotparams + (layerselection 0x010fc_ffffffff) + (usegerberextensions false) + (usegerberattributes true) + (usegerberadvancedattributes true) + (creategerberjobfile true) + (excludeedgelayer true) + (linewidth 0.100000) + (plotframeref false) + (viasonmask false) + (mode 1) + (useauxorigin false) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15.000000) + (psnegative false) + (psa4output false) + (plotreference true) + (plotvalue true) + (plotinvisibletext false) + (padsonsilk false) + (subtractmaskfromsilk false) + (outputformat 1) + (mirror false) + (drillshape 1) + (scaleselection 1) + (outputdirectory "")) + ) + + (net 0 "") + + (net_class Default "This is the default net class." + (clearance 0.2) + (trace_width 0.25) + (via_dia 0.8) + (via_drill 0.4) + (uvia_dia 0.3) + (uvia_drill 0.1) + (add_net "") + ) + + + + +) + + \ No newline at end of file diff --git a/test/cli/big/reference/pcbs/export.kicad_pcb b/test/cli/big/reference/pcbs/export.kicad_pcb new file mode 100644 index 0000000..3e5ec29 --- /dev/null +++ b/test/cli/big/reference/pcbs/export.kicad_pcb @@ -0,0 +1,112 @@ + + +(kicad_pcb (version 20171130) (host pcbnew 5.1.6) + + (page A3) + (title_block + (title KEYBOARD_NAME_HERE) + (rev VERSION_HERE) + (company YOUR_NAME_HERE) + ) + + (general + (thickness 1.6) + ) + + (layers + (0 F.Cu signal) + (31 B.Cu signal) + (32 B.Adhes user) + (33 F.Adhes user) + (34 B.Paste user) + (35 F.Paste user) + (36 B.SilkS user) + (37 F.SilkS user) + (38 B.Mask user) + (39 F.Mask user) + (40 Dwgs.User user) + (41 Cmts.User user) + (42 Eco1.User user) + (43 Eco2.User user) + (44 Edge.Cuts user) + (45 Margin user) + (46 B.CrtYd user) + (47 F.CrtYd user) + (48 B.Fab user) + (49 F.Fab user) + ) + + (setup + (last_trace_width 0.25) + (trace_clearance 0.2) + (zone_clearance 0.508) + (zone_45_only no) + (trace_min 0.2) + (via_size 0.8) + (via_drill 0.4) + (via_min_size 0.4) + (via_min_drill 0.3) + (uvia_size 0.3) + (uvia_drill 0.1) + (uvias_allowed no) + (uvia_min_size 0.2) + (uvia_min_drill 0.1) + (edge_width 0.05) + (segment_width 0.2) + (pcb_text_width 0.3) + (pcb_text_size 1.5 1.5) + (mod_edge_width 0.12) + (mod_text_size 1 1) + (mod_text_width 0.15) + (pad_size 1.524 1.524) + (pad_drill 0.762) + (pad_to_mask_clearance 0.05) + (aux_axis_origin 0 0) + (visible_elements FFFFFF7F) + (pcbplotparams + (layerselection 0x010fc_ffffffff) + (usegerberextensions false) + (usegerberattributes true) + (usegerberadvancedattributes true) + (creategerberjobfile true) + (excludeedgelayer true) + (linewidth 0.100000) + (plotframeref false) + (viasonmask false) + (mode 1) + (useauxorigin false) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15.000000) + (psnegative false) + (psa4output false) + (plotreference true) + (plotvalue true) + (plotinvisibletext false) + (padsonsilk false) + (subtractmaskfromsilk false) + (outputformat 1) + (mirror false) + (drillshape 1) + (scaleselection 1) + (outputdirectory "")) + ) + + (net 0 "") + + (net_class Default "This is the default net class." + (clearance 0.2) + (trace_width 0.25) + (via_dia 0.8) + (via_drill 0.4) + (uvia_dia 0.3) + (uvia_drill 0.1) + (add_net "") + ) + + + + +) + + \ No newline at end of file diff --git a/test/cli/basic/reference/points/demo.dxf b/test/cli/big/reference/points/demo.dxf similarity index 100% rename from test/cli/basic/reference/points/demo.dxf rename to test/cli/big/reference/points/demo.dxf diff --git a/test/cli/basic/reference/points/demo.json b/test/cli/big/reference/points/demo.json similarity index 100% rename from test/cli/basic/reference/points/demo.json rename to test/cli/big/reference/points/demo.json diff --git a/test/cli/basic/reference/points/demo.svg b/test/cli/big/reference/points/demo.svg similarity index 100% rename from test/cli/basic/reference/points/demo.svg rename to test/cli/big/reference/points/demo.svg diff --git a/test/cli/basic/reference/points/points.json b/test/cli/big/reference/points/points.json similarity index 100% rename from test/cli/basic/reference/points/points.json rename to test/cli/big/reference/points/points.json diff --git a/test/cli/big/reference/raw.txt b/test/cli/big/reference/raw.txt new file mode 100644 index 0000000..c9f82ec --- /dev/null +++ b/test/cli/big/reference/raw.txt @@ -0,0 +1,24 @@ +units: + a: 28 + u +points.zones.matrix: + columns.col: {} + rows.row: {} +outlines.exports: + export: + - type: 'keys' + side: 'left' + size: 18 + _export: + - type: 'keys' + side: 'left' + size: 18 +cases: + export: + - name: 'export' + extrude: 1 + _export: + - name: 'export' + extrude: 1 +pcbs: + export: {} + _export: {} diff --git a/test/cli/big/reference/units.json b/test/cli/big/reference/units.json new file mode 100644 index 0000000..1ae3c36 --- /dev/null +++ b/test/cli/big/reference/units.json @@ -0,0 +1,6 @@ +{ + "u": 19, + "cx": 18, + "cy": 17, + "a": 47 +} diff --git a/test/cli/medium/command b/test/cli/medium/command new file mode 100644 index 0000000..7dc9597 --- /dev/null +++ b/test/cli/medium/command @@ -0,0 +1 @@ +node src/cli.js test/fixtures/medium.yaml diff --git a/test/cli/medium/log b/test/cli/medium/log new file mode 100644 index 0000000..ba78a5c --- /dev/null +++ b/test/cli/medium/log @@ -0,0 +1,12 @@ +Ergogen CLI + +Interpreting format: YAML +Preprocessing input... +Calculating variables... +Parsing points... +Generating outlines... +Extruding cases... +Scaffolding PCBs... +Writing output to disk... +Done. + diff --git a/test/cli/medium/reference/outlines/export.dxf b/test/cli/medium/reference/outlines/export.dxf new file mode 100644 index 0000000..0d161b6 --- /dev/null +++ b/test/cli/medium/reference/outlines/export.dxf @@ -0,0 +1,98 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-9 +20 +-9 +11 +9 +21 +-9 +0 +LINE +8 +0 +10 +9 +20 +-9 +11 +9 +21 +9 +0 +LINE +8 +0 +10 +9 +20 +9 +11 +-9 +21 +9 +0 +LINE +8 +0 +10 +-9 +20 +9 +11 +-9 +21 +-9 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/cli/medium/reference/pcbs/export.kicad_pcb b/test/cli/medium/reference/pcbs/export.kicad_pcb new file mode 100644 index 0000000..3e5ec29 --- /dev/null +++ b/test/cli/medium/reference/pcbs/export.kicad_pcb @@ -0,0 +1,112 @@ + + +(kicad_pcb (version 20171130) (host pcbnew 5.1.6) + + (page A3) + (title_block + (title KEYBOARD_NAME_HERE) + (rev VERSION_HERE) + (company YOUR_NAME_HERE) + ) + + (general + (thickness 1.6) + ) + + (layers + (0 F.Cu signal) + (31 B.Cu signal) + (32 B.Adhes user) + (33 F.Adhes user) + (34 B.Paste user) + (35 F.Paste user) + (36 B.SilkS user) + (37 F.SilkS user) + (38 B.Mask user) + (39 F.Mask user) + (40 Dwgs.User user) + (41 Cmts.User user) + (42 Eco1.User user) + (43 Eco2.User user) + (44 Edge.Cuts user) + (45 Margin user) + (46 B.CrtYd user) + (47 F.CrtYd user) + (48 B.Fab user) + (49 F.Fab user) + ) + + (setup + (last_trace_width 0.25) + (trace_clearance 0.2) + (zone_clearance 0.508) + (zone_45_only no) + (trace_min 0.2) + (via_size 0.8) + (via_drill 0.4) + (via_min_size 0.4) + (via_min_drill 0.3) + (uvia_size 0.3) + (uvia_drill 0.1) + (uvias_allowed no) + (uvia_min_size 0.2) + (uvia_min_drill 0.1) + (edge_width 0.05) + (segment_width 0.2) + (pcb_text_width 0.3) + (pcb_text_size 1.5 1.5) + (mod_edge_width 0.12) + (mod_text_size 1 1) + (mod_text_width 0.15) + (pad_size 1.524 1.524) + (pad_drill 0.762) + (pad_to_mask_clearance 0.05) + (aux_axis_origin 0 0) + (visible_elements FFFFFF7F) + (pcbplotparams + (layerselection 0x010fc_ffffffff) + (usegerberextensions false) + (usegerberattributes true) + (usegerberadvancedattributes true) + (creategerberjobfile true) + (excludeedgelayer true) + (linewidth 0.100000) + (plotframeref false) + (viasonmask false) + (mode 1) + (useauxorigin false) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15.000000) + (psnegative false) + (psa4output false) + (plotreference true) + (plotvalue true) + (plotinvisibletext false) + (padsonsilk false) + (subtractmaskfromsilk false) + (outputformat 1) + (mirror false) + (drillshape 1) + (scaleselection 1) + (outputdirectory "")) + ) + + (net 0 "") + + (net_class Default "This is the default net class." + (clearance 0.2) + (trace_width 0.25) + (via_dia 0.8) + (via_drill 0.4) + (uvia_dia 0.3) + (uvia_drill 0.1) + (add_net "") + ) + + + + +) + + \ No newline at end of file diff --git a/test/cli/basic/command b/test/cli/minimal/command similarity index 100% rename from test/cli/basic/command rename to test/cli/minimal/command diff --git a/test/cli/basic/log b/test/cli/minimal/log similarity index 91% rename from test/cli/basic/log rename to test/cli/minimal/log index 7df27c1..72c917f 100644 --- a/test/cli/basic/log +++ b/test/cli/minimal/log @@ -1,4 +1,4 @@ -Ergogen v2.0.0 CLI +Ergogen CLI Interpreting format: YAML Preprocessing input... diff --git a/test/cli/basic/reference/canonical.yaml b/test/cli/minimal/reference/canonical.yaml similarity index 100% rename from test/cli/basic/reference/canonical.yaml rename to test/cli/minimal/reference/canonical.yaml diff --git a/test/cli/minimal/reference/points/demo.dxf b/test/cli/minimal/reference/points/demo.dxf new file mode 100644 index 0000000..8082f61 --- /dev/null +++ b/test/cli/minimal/reference/points/demo.dxf @@ -0,0 +1,98 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-9 +20 +9 +11 +9 +21 +9 +0 +LINE +8 +0 +10 +9 +20 +9 +11 +9 +21 +-9 +0 +LINE +8 +0 +10 +9 +20 +-9 +11 +-9 +21 +-9 +0 +LINE +8 +0 +10 +-9 +20 +-9 +11 +-9 +21 +9 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/cli/minimal/reference/points/demo.json b/test/cli/minimal/reference/points/demo.json new file mode 100644 index 0000000..d400097 --- /dev/null +++ b/test/cli/minimal/reference/points/demo.json @@ -0,0 +1,69 @@ +{ + "models": { + "export": { + "models": { + "matrix_col_row": { + "paths": { + "top": { + "type": "line", + "origin": [ + -9, + 9 + ], + "end": [ + 9, + 9 + ] + }, + "right": { + "type": "line", + "origin": [ + 9, + 9 + ], + "end": [ + 9, + -9 + ] + }, + "bottom": { + "type": "line", + "origin": [ + 9, + -9 + ], + "end": [ + -9, + -9 + ] + }, + "left": { + "type": "line", + "origin": [ + -9, + -9 + ], + "end": [ + -9, + 9 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "origin": [ + 0, + 0 + ] + } + }, + "units": "mm", + "origin": [ + 0, + 0 + ] +} diff --git a/test/cli/minimal/reference/points/demo.svg b/test/cli/minimal/reference/points/demo.svg new file mode 100644 index 0000000..bcd7456 --- /dev/null +++ b/test/cli/minimal/reference/points/demo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/cli/minimal/reference/points/points.json b/test/cli/minimal/reference/points/points.json new file mode 100644 index 0000000..17e880a --- /dev/null +++ b/test/cli/minimal/reference/points/points.json @@ -0,0 +1,34 @@ +{ + "matrix_col_row": { + "x": 0, + "y": 0, + "r": 0, + "meta": { + "shift": [ + 0, + 0 + ], + "rotate": 0, + "padding": 19, + "width": 1, + "height": 1, + "skip": false, + "asym": "both", + "name": "matrix_col_row", + "colrow": "col_row", + "col": { + "stagger": 0, + "spread": 0, + "rotate": 0, + "origin": [ + 0, + 0 + ], + "rows": {}, + "key": {}, + "name": "col" + }, + "row": "row" + } + } +} diff --git a/test/cli/basic/reference/raw.txt b/test/cli/minimal/reference/raw.txt similarity index 100% rename from test/cli/basic/reference/raw.txt rename to test/cli/minimal/reference/raw.txt diff --git a/test/cli/basic/reference/units.json b/test/cli/minimal/reference/units.json similarity index 100% rename from test/cli/basic/reference/units.json rename to test/cli/minimal/reference/units.json diff --git a/test/cli/nonexistent_input/command b/test/cli/nonexistent_input/command new file mode 100644 index 0000000..498d5ae --- /dev/null +++ b/test/cli/nonexistent_input/command @@ -0,0 +1 @@ +node src/cli.js nonexistent.yaml diff --git a/test/cli/nonexistent_input/error b/test/cli/nonexistent_input/error new file mode 100644 index 0000000..d5ef9b2 --- /dev/null +++ b/test/cli/nonexistent_input/error @@ -0,0 +1 @@ +Could not read config file "nonexistent.yaml": Error: ENOENT: no such file or directory, open 'nonexistent.yaml' diff --git a/test/fixtures/medium.yaml b/test/fixtures/medium.yaml new file mode 100644 index 0000000..a48969c --- /dev/null +++ b/test/fixtures/medium.yaml @@ -0,0 +1,9 @@ +points.zones.matrix: + columns.col: {} +outlines.exports: + export: + - type: 'keys' + side: 'left' + size: 18 +pcbs: + export: {} diff --git a/test/index.js b/test/index.js index 8d98290..f12dd8b 100644 --- a/test/index.js +++ b/test/index.js @@ -103,33 +103,43 @@ if (what) { } // End-to-end tests to actually drive the CLI as well -// --what filter is 'cli' -// --dump is meaningless (just use the CLI itself) +// --what filter is the same as above ('cli', or 'cli/prefix') +// --dump saves the log, as well as prevents the output from being deleted const read = (d, p) => fs.readFileSync(path.join(d, p)).toString() const exists = (d, p) => fs.existsSync(path.join(d, p)) const { execSync } = require('child_process') const dircompare = require('dir-compare') -if (!what || what.includes('cli')) { +const cli_what = what ? what.filter(w => w.startsWith('cli')) : ['cli'] + +for (let w of cli_what) { + if (!w.includes('/')) w += '/' + if (!w.endsWith('*')) w += '*' describe('CLI', function() { this.timeout(120000) this.slow(120000) - for (const t of glob.sync(path.join(__dirname, 'cli/*'))) { + for (const t of glob.sync(path.join(__dirname, w))) { it(cap(path.basename(t).split('_').join(' ')), function() { const command = read(t, 'command') const output_path = exists(t, 'path') ? read(t, 'path') : 'output' + fs.removeSync(output_path) const version_regex = /\bv\d+\.\d+\.\d+\b/ // correct execution if (exists(t, 'log')) { const ref_log = read(t, 'log').replace(version_regex, '') const actual_log = execSync(command).toString().replace(version_regex, '') + if (dump) { + fs.writeFileSync(path.join(t, 'log'), actual_log) + } actual_log.should.equal(ref_log) const comp_res = dircompare.compareSync(output_path, path.join(t, 'reference'), { compareContent: true }) comp_res.same.should.be.true - fs.removeSync(output_path) + if (!dump) { + fs.removeSync(output_path) + } } else { const ref_error = read(t, 'error').replace(version_regex, '') try { @@ -140,7 +150,10 @@ if (!what || what.includes('cli')) { throw new Error('This command should have thrown!') } const actual_error = ex.stderr.toString().replace(version_regex, '') - actual_error.should.equal(ref_error) + if (dump) { + fs.writeFileSync(path.join(t, 'error'), actual_error) + } + actual_error.includes(ref_error).should.be.true } } })