From 39fef16d1c4629dfad5feed05e0faaf7f91d08ca Mon Sep 17 00:00:00 2001 From: werner Date: Mon, 26 Apr 2010 23:11:22 +0000 Subject: [PATCH] Got rid of the requirement to have a "package" directive. Fixed a grammar error found in the process. Also taught the regression test system a new trick: the path to "fped" can be passed in the environment variable FPED. E.g., FPED=fped.r5943 make test - fped.c (usage, main): duplicating the -T option produces a dump to stdout before exiting (like %dump would) - test/Common: new command fped_dump to invoked fped with a second -T option - test/Common: if the environment variable FPED is set, use its content to invoke fped (default is ../fped) - test/Common: if the environment variable CWD_PREFIX is set, prepend it to $FPED if the latter is a relative path - Makefile (test, tests): set CWD_PREFIX to .., so that the path given in FPED is valid at the point of invocation - fpd.y: revised grammar to make "package" optional - fpd.y: measurements were syntactically allowed inside non-root frame (test/structure) - test/structure: test various combinations of the grammatical file structure - test/tsort: removed all the now unnecessary "package" directives git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5944 99fdad57-331a-0410-800a-d7fa5415bdb3 --- Makefile | 2 +- README | 7 +++- fpd.y | 23 +++++++++-- fped.c | 7 +++- test/Common | 15 ++++++- test/structure | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ test/tsort | 16 -------- 7 files changed, 147 insertions(+), 26 deletions(-) create mode 100755 test/structure diff --git a/Makefile b/Makefile index 17c4be9..7893370 100644 --- a/Makefile +++ b/Makefile @@ -162,7 +162,7 @@ test tests: all LANG= sh -c \ 'passed=0 && cd test && \ for n in [a-z]*; do \ - SCRIPT=$$n . ./$$n; done; \ + SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \ echo "Passed all $$passed tests"' valgrind: diff --git a/README b/README index 8de9a81..83b62d2 100644 --- a/README +++ b/README @@ -148,6 +148,8 @@ unit mm unit mil unit auto +If the "unit" directive is omitted, fped defaults to millimeters. + When saving a footprint definition, the default unit is set to the unit set in the GUI. @@ -301,8 +303,9 @@ meas a b 0.2 mm Package name - - - - - - -The package name is a string of printable ASCII characters, including -spaces. +The package name is a non-empty string of printable ASCII characters, +including spaces. If the "package" directive is omitted, fped defaults +to using the name "_". package "" diff --git a/fpd.y b/fpd.y index 742a23d..1ef0eb8 100644 --- a/fpd.y +++ b/fpd.y @@ -342,7 +342,10 @@ all: ; fpd: - | frame_defs part_name opt_unit frame_items + frame_defs part_name opt_unit opt_frame_items opt_measurements + | frame_defs unit opt_frame_items opt_measurements + | frame_defs frame_items opt_measurements + | frame_defs opt_measurements ; part_name: @@ -364,7 +367,11 @@ part_name: ; opt_unit: - | TOK_UNIT ID + | unit + ; + +unit: + TOK_UNIT ID { if (!strcmp($2, "mm")) curr_unit = curr_unit_mm; @@ -400,14 +407,18 @@ frame_def: frames = curr_frame; last_frame = curr_frame; } - frame_items '}' + opt_frame_items '}' { set_frame(root_frame); } ; +opt_frame_items: + | frame_items + ; + frame_items: - | measurements + frame_item | frame_item frame_items ; @@ -763,6 +774,10 @@ pad_type: } ; +opt_measurements: + | measurements + ; + measurements: meas { diff --git a/fped.c b/fped.c index 9b6c353..8a840a6 100644 --- a/fped.c +++ b/fped.c @@ -65,11 +65,12 @@ static void load_file(const char *name) static void usage(const char *name) { fprintf(stderr, -"usage: %s [-k] [-p|-P] [-T] [cpp_option ...] [in_file [out_file]]\n\n" +"usage: %s [-k] [-p|-P] [-T [-T]] [cpp_option ...] [in_file [out_file]]\n\n" " -k write KiCad output, then exit\n" " -p write Postscript output, then exit\n" " -P write Postscript output (full page), then exit\n" " -T test mode. Load file, then exit\n" +" -T -T test mode. Load file, dump to stdout, then exit\n" " cpp_option -Idir, -Dname[=value], or -Uname\n" , name); exit(1); @@ -85,6 +86,7 @@ int main(int argc, char **argv) char opt[] = "-?"; int error; int batch = 0; + int test_mode = 0; int batch_write_kicad = 0; int batch_write_ps = 0, batch_write_ps_fullpage = 0; int c; @@ -102,6 +104,7 @@ int main(int argc, char **argv) break; case 'T': batch = 1; + test_mode++; break; case 'D': case 'U': @@ -167,6 +170,8 @@ int main(int argc, char **argv) if (error) return error; } + if (test_mode > 1) + dump(stdout); purge(); inst_revert(); diff --git a/test/Common b/test/Common index 42989eb..d91a3d3 100755 --- a/test/Common +++ b/test/Common @@ -17,7 +17,7 @@ fped() echo -n "$1: " 1>&2 shift cat >_in - $VALGRIND ../fped -T _in "$@" >_out 2>&1 || { + $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 || { echo FAILED "($SCRIPT)" 1>&2 cat _out rm -f _in _out @@ -27,12 +27,18 @@ fped() } +fped_dump() +{ + fped "$@" -T +} + + fped_fail() { echo -n "$1: " 1>&2 shift cat >_in - $VALGRIND ../fped -T _in "$@" >_out 2>&1 && { + $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 && { echo FAILED "($SCRIPT)" 1>&2 cat _out rm -f _in _out @@ -54,3 +60,8 @@ expect() rm -f _out _diff passed=`expr ${passed:-0} + 1` } + + +if [ ! -z "$CWD_PREFIX" -a ! -z "$FPED" -a "$FPED" = "${FPED#/}" ]; then + FPED="$CWD_PREFIX/$FPED" +fi diff --git a/test/structure b/test/structure new file mode 100755 index 0000000..4ba89c6 --- /dev/null +++ b/test/structure @@ -0,0 +1,103 @@ +#!/bin/sh +. ./Common + +############################################################################### + +fped_dump "structure: empty file" < f.b +EOF +expect < f.b +EOF + +#------------------------------------------------------------------------------ + +fped_fail "structure: measurement in frame" < f.b +} +EOF +expect <