On 2016/01/15 10:04, Reinhold Straub wrote:
> Hi,
> 
> pdfgrep has a testsuite based on devel/dejagnu now. Unfortunately, some 
> patches are necessary to make tests work on OpenBSD.
> 
> I put pledge(2) calls into the source code, too.

Nice. I think the combination of PCRE and (often untrusted) PDF files
makes this a useful target for pledge.

If people are interested in looking at adding pledge to other ports,
I have a little list of other ports where it might be both a) useful
and b) reasonably sane.

Comments inline:

> -# $OpenBSD: Makefile,v 1.3 2015/08/25 16:28:04 jca Exp $
> +# $OpenBSD: Makefile,v 1.4 2015/08/25 16:28:04 jca Exp $

please leave the $OpenBSD lines alone in diffs, CVS handles them
automatically.

> -MODULES =            gcc4
> -MODGCC4_ARCHS =              *
> -MODGCC4_LANGS =              c++
> +MODULES =               gcc4
> +MODGCC4_ARCHS =         *
> +MODGCC4_LANGS =         c++

this chunk is replacing good whitespace with bad ;)

> +TEST_DEPENDS =          devel/dejagnu print/texlive/base

and please use the standard format here like most other Makefiles
(new line for each dep).

Here's a diff including the above, the patches from your tar.gz in
the diff (which you can't do easily yourself with anoncvs), and with
some other whitespace cleanup. I also added a TEST_FLAGS so we can
see what dejagnu is doing.

There's one test failure in regex.exp: it seems minor so I won't hold
up committing because of this, but do you know what that's about?
It is not related to the pledge patch.

[...]
Running ./pdfgrep.tests/regex.exp ...
PASS: Match line after double match
PASS: Match line after double match -- fixed string
PASS: Match line after double match -- PCRE
FAIL: Empty pattern -- error from pdfgrep
[...]

Anyway it's working fine for me, I've tested with password-protected
files as well (and I can't think of any of the command-line options
that might change required pledges), so if you're still happy with
this I can go ahead and commit.

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/pdfgrep/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- Makefile    25 Aug 2015 16:28:04 -0000      1.3
+++ Makefile    15 Jan 2016 11:56:14 -0000
@@ -2,7 +2,7 @@
 
 COMMENT =              tool to search text in PDF files
 
-DISTNAME =             pdfgrep-1.4.0
+DISTNAME =             pdfgrep-1.4.1
 
 CATEGORIES =           textproc
 
@@ -10,22 +10,25 @@ HOMEPAGE =          https://pdfgrep.org/
 
 MAINTAINER =           Reinhold Straub <demarc...@web.de>
 
-#GPLv2+
+# GPLv2+
 PERMIT_PACKAGE_CDROM = Yes
 
 MODULES =              gcc4
 MODGCC4_ARCHS =                *
 MODGCC4_LANGS =                c++
 
-WANTLIB +=             c m pthread stdc++ poppler-cpp pcre
+WANTLIB +=             c m pthread poppler-cpp pcre
 
 MASTER_SITES =         https://pdfgrep.org/download/
 
 LIB_DEPENDS =          print/poppler
+TEST_DEPENDS =         devel/dejagnu \
+                       print/texlive/base
 
 CONFIGURE_ENV =                LDFLAGS="-L${X11BASE}/lib"
 CONFIGURE_STYLE =      gnu
 
 MAKE_FLAGS =           CXX="${CXX}"
+TEST_FLAGS =           RUNTESTFLAGS="--all"
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/pdfgrep/distinfo,v
retrieving revision 1.2
diff -u -p -r1.2 distinfo
--- distinfo    25 Aug 2015 16:28:04 -0000      1.2
+++ distinfo    15 Jan 2016 11:56:14 -0000
@@ -1,2 +1,2 @@
-SHA256 (pdfgrep-1.4.0.tar.gz) = MwwRG5GpIRbVpnZsGx0i3NeVkonXNHHZNEsLBHX8quI=
-SIZE (pdfgrep-1.4.0.tar.gz) = 125269
+SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw=
+SIZE (pdfgrep-1.4.1.tar.gz) = 151926
Index: patches/patch-src_pdfgrep_cc
===================================================================
RCS file: patches/patch-src_pdfgrep_cc
diff -N patches/patch-src_pdfgrep_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_pdfgrep_cc        15 Jan 2016 11:56:14 -0000
@@ -0,0 +1,27 @@
+$OpenBSD$
+--- src/pdfgrep.cc.orig        Wed Sep 16 21:06:49 2015
++++ src/pdfgrep.cc     Fri Jan 15 11:39:19 2016
+@@ -569,6 +569,11 @@ void handle_poppler_errors(const std::string &msg, voi
+ 
+ int main(int argc, char** argv)
+ {
++      if (pledge("stdio rpath ioctl", NULL) == -1) {
++              fprintf ( stderr, "pdfgrep: pledge\n" );
++              exit ( 1 );
++      }
++
+       init_colors();
+ 
+       enum re_engine_type {
+@@ -773,6 +778,11 @@ int main(int argc, char** argv)
+       } else if (context == -2) {
+               // on non-terminals, always print the whole line
+               context = -1;
++      }
++
++      if (pledge("stdio rpath", NULL) == -1) {
++              fprintf ( stderr, "pdfgrep: pledge\n" );
++              exit ( 1 );
+       }
+ 
+       if (excludes_empty(includes))
Index: patches/patch-testsuite_Makefile_in
===================================================================
RCS file: patches/patch-testsuite_Makefile_in
diff -N patches/patch-testsuite_Makefile_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-testsuite_Makefile_in 15 Jan 2016 11:56:14 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- testsuite/Makefile.in.orig Tue Sep 29 18:18:42 2015
++++ testsuite/Makefile.in      Tue Sep 29 18:18:27 2015
+@@ -643,7 +643,7 @@ uninstall-am:
+ .PRECIOUS: Makefile
+ 
+ 
+-export DEJAGNU
++# export DEJAGNU
+ 
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
Index: patches/patch-testsuite_lib_pdfgrep_exp
===================================================================
RCS file: patches/patch-testsuite_lib_pdfgrep_exp
diff -N patches/patch-testsuite_lib_pdfgrep_exp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-testsuite_lib_pdfgrep_exp     15 Jan 2016 11:56:14 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- testsuite/lib/pdfgrep.exp.orig     Wed Jan 13 15:06:57 2016
++++ testsuite/lib/pdfgrep.exp  Wed Jan 13 15:12:42 2016
+@@ -213,7 +213,7 @@ proc reset_configuration {} {
+ 
+ # The directory where the PDFs will be generated.
+ # NOTE This will frequently be removed, so don't put important data there
+-set pdfdir [exec mktemp --tmpdir -d pdfgrep_tests.XXXXXXXXXX]
++set pdfdir [exec mktemp -d /tmp/pdfgrep_tests.XXXXXXXXXX]
+ 
+ 
+ # Delete $pdfdir recursively and create it anew
Index: patches/patch-testsuite_pdfgrep_tests_exit_status_exp
===================================================================
RCS file: patches/patch-testsuite_pdfgrep_tests_exit_status_exp
diff -N patches/patch-testsuite_pdfgrep_tests_exit_status_exp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-testsuite_pdfgrep_tests_exit_status_exp       15 Jan 2016 
11:56:14 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+--- testsuite/pdfgrep.tests/exit_status.exp.orig       Wed Jan 13 15:07:29 2016
++++ testsuite/pdfgrep.tests/exit_status.exp    Wed Jan 13 15:10:27 2016
+@@ -8,7 +8,7 @@ clear_pdfdir
+ set pdf [mkpdf exit-status "foobar"]
+ 
+ pdfgrep foobar $pdf
+-
++expect eof
+ expect_exit_status 0
+ 
+ ########################################
+@@ -40,5 +40,5 @@ clear_pdfdir
+ 
+ # $pdf doesn't exist anymore
+ pdfgrep foobar $pdf
+-
++expect eof
+ expect_exit_status 2
Index: patches/patch-testsuite_pdfgrep_tests_usage_exp
===================================================================
RCS file: patches/patch-testsuite_pdfgrep_tests_usage_exp
diff -N patches/patch-testsuite_pdfgrep_tests_usage_exp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-testsuite_pdfgrep_tests_usage_exp     15 Jan 2016 11:56:14 
-0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- testsuite/pdfgrep.tests/usage.exp.orig     Wed Jan 13 15:07:55 2016
++++ testsuite/pdfgrep.tests/usage.exp  Wed Jan 13 15:11:50 2016
+@@ -5,7 +5,7 @@ expect {
+     -re "^Usage: .*" { pass $test }
+     default { fail $test }
+ }
+-
++expect eof
+ expect_exit_status 2
+ 
+ # Also look that nothing is written to stdout

Reply via email to