[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/02: Add automatic tests on mom examples
From: |
Bertrand Garrigues |
Subject: |
[groff] 01/02: Add automatic tests on mom examples |
Date: |
Fri, 23 Nov 2018 19:06:17 -0500 (EST) |
bgarrigues pushed a commit to branch master
in repository groff.
commit a828035c84b1a186ebdbd5c8070b0e9516b67e83
Author: Bertrand Garrigues <address@hidden>
Date: Sat Nov 24 00:17:11 2018 +0100
Add automatic tests on mom examples
* m4/groff.m4 (GROFF_PDFTOOLS): check presence of some pdf tools.
* configure.ac: use 'GROFF_PDFTOOLS', add new AM conditional.
* contrib/mom/examples/test-mom.sh.in: new file that use 'pdfinfo'
and 'pdfimages' to make some basic checks on mom examples.
---
ChangeLog | 9 +++++
configure.ac | 5 ++-
contrib/hdtbl/examples/test-hdtbl.sh.in | 2 +-
contrib/mom/examples/test-mom.sh.in | 72 +++++++++++++++++++++++++++++++++
contrib/mom/mom.am | 14 ++++++-
m4/groff.m4 | 12 +++++-
6 files changed, 110 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5145cd6..6300ba8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-24 Bertrand Garrigues <address@hidden>
+
+ Add automatic tests on mom examples
+
+ * m4/groff.m4 (GROFF_PDFTOOLS): check presence of some pdf tools.
+ * configure.ac: use 'GROFF_PDFTOOLS', add new AM conditional.
+ * contrib/mom/examples/test-mom.sh.in: new file that use 'pdfinfo'
+ and 'pdfimages' to make some basic checks on mom examples.
+
2018-11-21 G. Branden Robinson <address@hidden>
tmac/sv.tmac: Set Swedish hyphenation flags to 32.
diff --git a/configure.ac b/configure.ac
index 9d0f52b..cb2bd10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,7 @@ AC_PROG_MKDIR_P
GROFF_PROG_XPMTOPPM
PKG_PROG_PKG_CONFIG
GROFF_UCHARDET
+GROFF_PDFTOOLS
# use a dummy substitution if no csh hack is necessary to avoid errors
# with non-GNU sed programs
@@ -199,6 +200,7 @@ AM_CONDITIONAL([BUILD_PDFEXAMPLES], [test -n
"$make_pdfexamples"])
AM_CONDITIONAL([BUILD_OTHERDOC], [test -n "$make_otherdoc"])
AM_CONDITIONAL([BUILD_EXAMPLES], [test -n "$make_examples"])
AM_CONDITIONAL([INSTALL_SHIPPED_HTML], [test -n
"$make_install_shipped_htmldoc"])
+AM_CONDITIONAL([HAVE_PDFTOOLS], [test "x$groff_have_pdftools" = "xyes" ])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([test-groff], [chmod +x test-groff])
@@ -226,7 +228,8 @@ echo "\
fi
echo "\
URW fonts for pdf : $groff_have_urw_fonts
- Use uchardet library for preconv: $groff_have_uchardet"
+ Use uchardet library for preconv: $groff_have_uchardet
+ pdftools for distcheck : $groff_have_pdftools"
echo "\
----------------------------------------------------------------------"
diff --git a/contrib/hdtbl/examples/test-hdtbl.sh.in
b/contrib/hdtbl/examples/test-hdtbl.sh.in
index 915dfb9..0f6cd6f 100644
--- a/contrib/hdtbl/examples/test-hdtbl.sh.in
+++ b/contrib/hdtbl/examples/test-hdtbl.sh.in
@@ -24,7 +24,7 @@
builddir="@abs_top_builddir@"
gs_program="@GHOSTSCRIPT@"
ret=0
-# $1 file, $2 expected number of lines
+# $1 file, $2 expected number of pages
check_number_pages()
{
echo "Checking $1"
diff --git a/contrib/mom/examples/test-mom.sh.in
b/contrib/mom/examples/test-mom.sh.in
new file mode 100644
index 0000000..f523674
--- /dev/null
+++ b/contrib/mom/examples/test-mom.sh.in
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Copyright (C) 2018- Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff 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, see <http://www.gnu.org/licenses/>.
+#
+
+builddir="@abs_top_builddir@"
+examplesdir="$builddir/contrib/mom/examples"
+ret=0
+list="
+ letter.pdf
+ mom-pdf.pdf
+ mon_premier_doc.pdf
+ sample_docs.pdf
+ slide-demo.pdf
+ typesetting.pdf
+ "
+# $1: pdf file
+# $2: expected number of pages
+check_number_pages()
+{
+ echo "Checking number of pages of $1"
+ n_pages=`pdfinfo $1 | grep Pages | awk '{ print $2}'`
+ if test "$n_pages" != "$2"; then
+ echo " Error: expected $2 pages, found $res pages"
+ ret=255
+ fi
+}
+
+# $1 pdf file
+check_has_images()
+{
+ echo "Checking if $1 has images"
+ n_lines=`pdfimages -list $1 | wc -l `
+ if test $n_lines -le 2; then
+ echo " no images found"
+ ret = 255;
+ fi
+}
+
+for k in $list; do
+ if ! test -f $examplesdir/$k; then
+ echo "File $k not found"
+ exit 255
+ fi
+done
+
+check_number_pages "$examplesdir/letter.pdf" 1
+check_number_pages "$examplesdir/mom-pdf.pdf" 8
+check_number_pages "$examplesdir/mon_premier_doc.pdf" 5
+check_number_pages "$examplesdir/sample_docs.pdf" 12
+check_number_pages "$examplesdir/slide-demo.pdf" 27
+check_number_pages "$examplesdir/typesetting.pdf" 3
+
+check_has_images "$examplesdir/typesetting.pdf"
+check_has_images "$examplesdir/slide-demo.pdf"
+
+exit $ret
diff --git a/contrib/mom/mom.am b/contrib/mom/mom.am
index ab5b71a..b17f1b3 100644
--- a/contrib/mom/mom.am
+++ b/contrib/mom/mom.am
@@ -2,7 +2,6 @@
# Written by Werner Lemberg (address@hidden)
# Automake migration by Bertrand Garrigues
#
-# Last update: 22 Aug 2015
#
# This file is part of groff.
#
@@ -104,6 +103,19 @@ MOMPROCESSEDEXAMPLEFILES = \
contrib/mom/examples/slide-demo.pdf
momprocessedexampledir = $(exampledir)/mom
nodist_momprocessedexample_DATA = $(MOMPROCESSEDEXAMPLEFILES)
+
+if HAVE_PDFTOOLS
+# Small test suite on mom examples
+mom_TESTS = contrib/mom/examples/tests-mom.sh
+TESTS += $(mom_TESTS)
+contrib/mom/examples/tests-mom.sh: $(top_builddir)/config.status \
+ $(MOMPROCESSEDEXAMPLEFILES)
$(top_srcdir)/contrib/mom/examples/test-mom.sh.in
+ sed -e "s|address@hidden@]|$(abs_top_builddir)|g" \
+ $(top_srcdir)/contrib/mom/examples/test-mom.sh.in > $@
+ chmod +x $@
+MOSTLYCLEANFILES += $(mom_TESTS)
+EXTRA_DIST += contrib/mom/examples/test-mom.sh.in
+endif
endif
# For this list of files we add a symlink from $(exampledir)/mom to
$(pdfdocdir)
diff --git a/m4/groff.m4 b/m4/groff.m4
index f9b5f13..1862dd7 100644
--- a/m4/groff.m4
+++ b/m4/groff.m4
@@ -1666,4 +1666,14 @@ AC_DEFUN([GROFF_UCHARDET_CHECK],
fi
])
-
+# pdftools needed for sanity checks
+AC_DEFUN([GROFF_PDFTOOLS],
+ [AC_CHECK_PROG([PDFINFO], [pdfinfo], [found], [missing])
+ AC_CHECK_PROG([PDFFONTS], [pdffonts], [found], [missing])
+ AC_CHECK_PROG([PDFIMAGES], [pdfimages], [found], [missing])
+ if test "x$PDFINFO" = "xfound" -a "x$PDFFONTS" = "xfound" -a "x$PDFIMAGES"
= "xfound"; then
+ groff_have_pdftools=yes;
+ else
+ groff_have_pdftools=no;
+ fi
+ ])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/02: Add automatic tests on mom examples,
Bertrand Garrigues <=
- Prev by Date:
[groff] 02/02: Fix tarball generation: script 'makevarescape.sed' was missing.
- Next by Date:
[groff] 01/01: Fix indent conflicts with nested lists. Simplify parsing for quad values. Fix cover handling. Avoid adding shim space when calculating only. Correct bugs in float handling: spacing, indents, defers. Add INDENT arg to FLOAT. Correct printed page number in "Lists of..." when referring to deferred floats. Correct inconsistencies in tbl handling (floated and non-floated): spacing, indents, labels, captions. Tweak formatting of "Lists of..."
- Previous by thread:
[groff] 02/02: Fix tarball generation: script 'makevarescape.sed' was missing.
- Next by thread:
[groff] 01/01: Fix indent conflicts with nested lists. Simplify parsing for quad values. Fix cover handling. Avoid adding shim space when calculating only. Correct bugs in float handling: spacing, indents, defers. Add INDENT arg to FLOAT. Correct printed page number in "Lists of..." when referring to deferred floats. Correct inconsistencies in tbl handling (floated and non-floated): spacing, indents, labels, captions. Tweak formatting of "Lists of..."
- Index(es):