From f5325200f32767aa9b491a4cae32195cc5f49830 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 28 Nov 2019 13:38:02 -0700 Subject: Add a simple integration test Signed-off-by: Sean Whitton --- Makefile | 2 ++ debian/changelog | 6 +++++ test/output.tex | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test | 63 ++++++++++++++++++++++++++++++++++++++++++++++ test/test.bib | 6 +++++ test/test.mdwn | 3 +++ 6 files changed, 157 insertions(+) create mode 100644 Makefile create mode 100644 test/output.tex create mode 100755 test/test create mode 100644 test/test.bib create mode 100644 test/test.mdwn diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..156f6bd --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +check: + test/test diff --git a/debian/changelog b/debian/changelog index 69c1ee7..f24d008 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +pandoc-citeproc-preamble (1.2.5-1) UNRELEASED; urgency=medium + + * Add a simple integration test. + + -- Sean Whitton Thu, 28 Nov 2019 13:37:21 -0700 + pandoc-citeproc-preamble (1.2.4-2) unstable; urgency=medium * Upload to unstable. diff --git a/test/output.tex b/test/output.tex new file mode 100644 index 0000000..b10965f --- /dev/null +++ b/test/output.tex @@ -0,0 +1,77 @@ +\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere +\PassOptionsToPackage{hyphens}{url} +% +\documentclass[]{article} +\usepackage{lmodern} +\usepackage{amssymb,amsmath} +\usepackage{ifxetex,ifluatex} +\usepackage{fixltx2e} % provides \textsubscript +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \usepackage[T1]{fontenc} + \usepackage[utf8]{inputenc} + \usepackage{textcomp} % provides euro and other symbols +\else % if luatex or xelatex + \usepackage{unicode-math} + \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase} +\fi +% use upquote if available, for straight quotes in verbatim environments +\IfFileExists{upquote.sty}{\usepackage{upquote}}{} +% use microtype if available +\IfFileExists{microtype.sty}{% +\usepackage[]{microtype} +\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts +}{} +\IfFileExists{parskip.sty}{% +\usepackage{parskip} +}{% else +\setlength{\parindent}{0pt} +\setlength{\parskip}{6pt plus 2pt minus 1pt} +} +\usepackage{hyperref} +\hypersetup{ + pdfborder={0 0 0}, + breaklinks=true} +\urlstyle{same} % don't use monospace font for urls +\setlength{\emergencystretch}{3em} % prevent overfull lines +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} +\setcounter{secnumdepth}{0} +% Redefines (sub)paragraphs to behave more like sections +\ifx\paragraph\undefined\else +\let\oldparagraph\paragraph +\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} +\fi +\ifx\subparagraph\undefined\else +\let\oldsubparagraph\subparagraph +\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} +\fi + +% set default figure placement to htbp +\makeatletter +\def\fps@figure{htbp} +\makeatother + + +\date{} + +\begin{document} + +\hypertarget{my-document}{% +\section{My document}\label{my-document}} + +With some text, (Author 2019, 200). + +\section*{References} +\setlength{\parindent}{-0.2in} +\singlespacing +\small +\setlength{\leftskip}{0.2in} +\setlength{\parskip}{8pt} +\vspace*{-0.4in} +\noindent + +\hypertarget{refs}{} +\leavevmode\hypertarget{ref-reference}{}% +Author, A. N. 2019. \emph{A Book}. A press. + +\end{document} diff --git a/test/test b/test/test new file mode 100755 index 0000000..a086d91 --- /dev/null +++ b/test/test @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Sean Whitton +# +# This file is part of pandoc-citeproc-preamble. +# +# pandoc-citeproc-preamble 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. +# +# pandoc-citeproc-preamble 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 pandoc-citeproc-preamble. If not, see +# . + +use 5.028; +use strict; +use warnings; + +use File::Spec::Functions qw(rel2abs); +use File::Basename qw(dirname); + +our $output = "output.tex"; + +chdir(dirname(rel2abs(__FILE__))); +unlink $output if -e $output; + +print "testing with ".(`pandoc --version`)[0]; +system "pandoc -s --filter pandoc-citeproc --bibliography=test.bib". + " --filter pandoc-citeproc-preamble". + " -M citeproc-preamble=../examples/default.latex". + " test.mdwn -o $output"; + +# simple finite state machine to check that the preamble was inserted +# in the right place +open my $fh, '<', $output; +my $preamble = 0; +while (<$fh>) { + if ($_ eq "\\section*{References}\n") { + if ($preamble) { + die "preamble inserted twice!\n"; + } else { + $preamble = 1; + } + } elsif (/A Book/) { + if ($preamble) { + say "success: citeproc preamble inserted as expected"; + exit 0; + } else { + die "references inserted before/without preamble!\n"; + } + } +} +if ($preamble) { + die "preamble without references!\n"; +} else { + die "neither preamble nor references found!\n"; +} diff --git a/test/test.bib b/test/test.bib new file mode 100644 index 0000000..5cbef1b --- /dev/null +++ b/test/test.bib @@ -0,0 +1,6 @@ +@book{reference, + title = {A book}, + year = {2019}, + publisher = {A press}, + author = {A. N. Author} +} diff --git a/test/test.mdwn b/test/test.mdwn new file mode 100644 index 0000000..3dd4b84 --- /dev/null +++ b/test/test.mdwn @@ -0,0 +1,3 @@ +# My document + +With some text, [@reference, p. 200]. -- cgit v1.2.3