diff --git a/math/graphviz/Makefile b/math/graphviz/Makefile index b0e9c51782b..afe2e8af629 100644 --- a/math/graphviz/Makefile +++ b/math/graphviz/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.48 2012/08/22 22:15:49 edd Exp $ +# $OpenBSD: Makefile,v 1.49 2012/08/31 19:50:01 edd Exp $ COMMENT-main= graph drawing software @@ -62,6 +62,8 @@ LIB_DEPENDS= graphics/jpeg \ RUN_DEPENDS= lang/guile BUILD_DEPENDS= devel/swig \ lang/guile +REGRESS_DEPENDS=math/graphviz + WANTLIB += GL ICE SM X11 Xau Xaw Xcomposite Xcursor Xdamage Xdmcp WANTLIB += Xext Xfixes Xi Xinerama Xmu Xpm Xrandr Xrender Xt Xxf86vm WANTLIB += atk-1.0 c cairo croco-0.6 drm expat ffi fontconfig @@ -137,6 +139,17 @@ post-install: ${SUBST_CMD} -c ${FILESDIR}/config6 ${PREFIX}/lib/graphviz/config6 chown -R ${SHAREOWN}:${SHAREGRP} ${PREFIX}/lib/graphviz/config6 +# Local tests for OpenBSD +# Can't run built in tests, as requires ksh93 (some specific arguments +# to the typeset builtin). Currently, there is no port. +TEST_TMP=${WRKDIR}/test_tmp +do-regress: + mkdir -p ${TEST_TMP} + cd ${FILESDIR}/tests && for i in *-test.* run_tests.sh; do \ + ${SUBST_CMD} -c $${i} ${TEST_TMP}/$${i}; \ + done + cd ${TEST_TMP} && /bin/sh ./run_tests.sh + # NOTE: When updating this port: # * Check we have commented .la and .a corresponding to unversioned .so files # in the packing list. diff --git a/math/graphviz/files/tests/dot-test.dot b/math/graphviz/files/tests/dot-test.dot new file mode 100644 index 00000000000..d41a4be9abf --- /dev/null +++ b/math/graphviz/files/tests/dot-test.dot @@ -0,0 +1,5 @@ +digraph g { + "a" -> "b"; + "b" -> "c"; + "c" -> "a"; +} diff --git a/math/graphviz/files/tests/dot-test.dot.expect b/math/graphviz/files/tests/dot-test.dot.expect new file mode 100644 index 00000000000..09dc1924039 --- /dev/null +++ b/math/graphviz/files/tests/dot-test.dot.expect @@ -0,0 +1,11 @@ +digraph g { + node [label="\N"]; + graph [bb="0,0,81,180"]; + a [pos="54,162", width="0.75", height="0.5"]; + b [pos="27,90", width="0.75", height="0.5"]; + c [pos="54,18", width="0.75", height="0.5"]; + a -> b [pos="e,33.54,107.96 47.601,144.41 44.486,136.34 40.666,126.43 37.165,117.35"]; + b -> c [pos="e,47.46,35.956 33.399,72.411 36.514,64.335 40.334,54.431 43.835,45.355"]; + c -> a [pos="e,57.654,143.91 57.654,36.092 59.676,46.431 61.981,59.91 63,72 64.344,87.943 64.344,92.057 63,108 62.283,116.5 60.931,125.69 59.488\ +,133.99"]; +} diff --git a/math/graphviz/tests/guile-test.scm b/math/graphviz/files/tests/guile-test.scm similarity index 67% rename from math/graphviz/tests/guile-test.scm rename to math/graphviz/files/tests/guile-test.scm index 657d68992ea..f4f084db47f 100644 --- a/math/graphviz/tests/guile-test.scm +++ b/math/graphviz/files/tests/guile-test.scm @@ -1,4 +1,4 @@ -(load-extension "/usr/local/lib/graphviz/guile/libgv_guile.so" "SWIG_init"); +(load-extension "${LOCALBASE}/lib/graphviz/guile/libgv_guile.so" "SWIG_init"); (define g (digraph "g")); (define n1 (node g "a")); @@ -10,5 +10,5 @@ (define e3 (edge n3 n1)); (layout g "dot"); -(render g "xlib"); +(render g "dot"); diff --git a/math/graphviz/files/tests/guile-test.scm.expect b/math/graphviz/files/tests/guile-test.scm.expect new file mode 100644 index 00000000000..09dc1924039 --- /dev/null +++ b/math/graphviz/files/tests/guile-test.scm.expect @@ -0,0 +1,11 @@ +digraph g { + node [label="\N"]; + graph [bb="0,0,81,180"]; + a [pos="54,162", width="0.75", height="0.5"]; + b [pos="27,90", width="0.75", height="0.5"]; + c [pos="54,18", width="0.75", height="0.5"]; + a -> b [pos="e,33.54,107.96 47.601,144.41 44.486,136.34 40.666,126.43 37.165,117.35"]; + b -> c [pos="e,47.46,35.956 33.399,72.411 36.514,64.335 40.334,54.431 43.835,45.355"]; + c -> a [pos="e,57.654,143.91 57.654,36.092 59.676,46.431 61.981,59.91 63,72 64.344,87.943 64.344,92.057 63,108 62.283,116.5 60.931,125.69 59.488\ +,133.99"]; +} diff --git a/math/graphviz/files/tests/neato-test.nto b/math/graphviz/files/tests/neato-test.nto new file mode 100644 index 00000000000..6694d6fb563 --- /dev/null +++ b/math/graphviz/files/tests/neato-test.nto @@ -0,0 +1,7 @@ +graph g { + 1 -- 2; + 2 -- 3; + 4 -- 3; + 5 -- 3; + 3 -- 1; +} diff --git a/math/graphviz/files/tests/neato-test.nto.expect b/math/graphviz/files/tests/neato-test.nto.expect new file mode 100644 index 00000000000..14d8346be85 --- /dev/null +++ b/math/graphviz/files/tests/neato-test.nto.expect @@ -0,0 +1,14 @@ +graph g { + node [label="\N"]; + graph [bb="0,0,176.35,163.87"]; + 1 [pos="41.352,25.566", width="0.75", height="0.5"]; + 2 [pos="108.39,18", width="0.75", height="0.5"]; + 3 [pos="82.599,90.149", width="0.75", height="0.5"]; + 4 [pos="27,145.87", width="0.75", height="0.5"]; + 5 [pos="149.35,131.88", width="0.75", height="0.5"]; + 1 -- 2 [pos="68.233,22.532 72.604,22.039 77.133,21.528 81.504,21.034"]; + 2 -- 3 [pos="102.02,35.835 98.018,47.018 92.885,61.375 88.901,72.52"]; + 4 -- 3 [pos="42.193,130.65 50.038,122.78 59.582,113.22 67.425,105.36"]; + 5 -- 3 [pos="129.32,119.36 120.88,114.08 111.06,107.94 102.61,102.66"]; + 3 -- 1 [pos="71.977,73.517 65.866,63.95 58.21,51.962 52.081,42.366"]; +} diff --git a/math/graphviz/tests/perl-test.pl b/math/graphviz/files/tests/perl-test.pl similarity index 90% rename from math/graphviz/tests/perl-test.pl rename to math/graphviz/files/tests/perl-test.pl index b70e2844300..e0a9534c288 100644 --- a/math/graphviz/tests/perl-test.pl +++ b/math/graphviz/files/tests/perl-test.pl @@ -12,4 +12,4 @@ gv::edge($n2, $n3) ; gv::edge($n3, $n1) ; gv::layout($g, 'dot'); -gv::render($g, 'xlib' ); +gv::render($g, 'dot' ); diff --git a/math/graphviz/files/tests/perl-test.pl.expect b/math/graphviz/files/tests/perl-test.pl.expect new file mode 100644 index 00000000000..b7f6fdb31af --- /dev/null +++ b/math/graphviz/files/tests/perl-test.pl.expect @@ -0,0 +1,10 @@ +graph test { + node [label="\N"]; + graph [bb="0,0,81,180"]; + a [pos="54,162", width="0.75", height="0.5"]; + b [pos="27,90", width="0.75", height="0.5"]; + c [pos="54,18", width="0.75", height="0.5"]; + a -- b [pos="47.601,144.41 43.36,133.41 37.811,119.03 33.54,107.96"]; + b -- c [pos="33.399,72.411 37.64,61.414 43.189,47.027 47.46,35.956"]; + c -- a [pos="57.654,36.092 59.676,46.431 61.981,59.91 63,72 64.344,87.943 64.344,92.057 63,108 61.981,120.09 59.676,133.57 57.654,143.91"]; +} diff --git a/math/graphviz/files/tests/run_tests.sh b/math/graphviz/files/tests/run_tests.sh new file mode 100644 index 00000000000..293c522187f --- /dev/null +++ b/math/graphviz/files/tests/run_tests.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# $OpenBSD: run_tests.sh,v 1.1 2012/08/31 19:50:01 edd Exp $ +# Simple regression tests for the OpenBSD graphviz port + +# Required due to single threaded interpreters (see README) +export LD_PRELOAD=/usr/lib/libpthread.so + +# Silence deprecated guile constructs +export GUILE_WARN_DEPRECATED=no + +# List of tests to run, of the form: +# compiler:testfile +tests="${LOCALBASE}/bin/guile:guile-test.scm" +tests="${tests} /usr/bin/perl:perl-test.pl" +tests="${tests} ${MODTCL_BIN}:tcl-test.tcl" +tests="${tests} ${LOCALBASE}/bin/dot:dot-test.dot" +tests="${tests} ${LOCALBASE}/bin/neato:neato-test.nto" + +for t in ${tests}; do + compiler=`echo $t | awk -F: '{print $1}'` + infile=`echo $t | awk -F: '{print $2}'` + outfile=${infile}.out + expectfile=${infile}.expect + difffile=${infile}.diff + + echo "Running test: ${infile}" + if ! ${compiler} ${infile} > ${outfile}; then + echo "FAILED (execution failed)" && exit 1 + fi + + if [ ! -f ${expectfile} ]; then + echo "FAILED (missing expected outcome)" && exit 1 + fi + + if ! diff -u ${expectfile} ${outfile} > ${difffile}; then + echo "FAILED (unexpected outcome)" && cat ${difffile} && exit 1 + fi + + rm ${difffile} ${outfile} + echo "PASSED" +done diff --git a/math/graphviz/tests/tcl-test.tcl b/math/graphviz/files/tests/tcl-test.tcl similarity index 94% rename from math/graphviz/tests/tcl-test.tcl rename to math/graphviz/files/tests/tcl-test.tcl index a02c411274c..2f746763b5b 100644 --- a/math/graphviz/tests/tcl-test.tcl +++ b/math/graphviz/files/tests/tcl-test.tcl @@ -17,4 +17,4 @@ set E2 [gv::edge $N2 $N3] set E3 [gv::edge $N3 $N1] gv::layout $G dot -gv::render $G xlib +gv::render $G dot diff --git a/math/graphviz/files/tests/tcl-test.tcl.expect b/math/graphviz/files/tests/tcl-test.tcl.expect new file mode 100644 index 00000000000..18175f2a0be --- /dev/null +++ b/math/graphviz/files/tests/tcl-test.tcl.expect @@ -0,0 +1,11 @@ +digraph G { + node [label="\N"]; + graph [bb="0,0,81,180"]; + a [pos="54,162", width="0.75", height="0.5"]; + b [pos="27,90", width="0.75", height="0.5"]; + c [pos="54,18", width="0.75", height="0.5"]; + a -> b [pos="e,33.54,107.96 47.601,144.41 44.486,136.34 40.666,126.43 37.165,117.35"]; + b -> c [pos="e,47.46,35.956 33.399,72.411 36.514,64.335 40.334,54.431 43.835,45.355"]; + c -> a [pos="e,57.654,143.91 57.654,36.092 59.676,46.431 61.981,59.91 63,72 64.344,87.943 64.344,92.057 63,108 62.283,116.5 60.931,125.69 59.488\ +,133.99"]; +}