Skip to content

Commit

Permalink
xparse fixes for older texlives (brucemiller#1204)
Browse files Browse the repository at this point in the history
* avoid spacing issues from texlive 2018

* xparse test for texlive > 2018

* robust when tex missing

* skip marker

* refactor to local rules
  • Loading branch information
dginev authored and brucemiller committed Sep 5, 2019
1 parent 8870c75 commit a11b274
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -1546,4 +1546,4 @@ t/tokenize/verb.tex
t/tokenize/verb.xml
t/tokenize/verbata.pdf
t/tokenize/verbata.tex
t/tokenize/verbata.xml
t/tokenize/verbata.xml
43 changes: 40 additions & 3 deletions lib/LaTeXML/Util/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ our @EXPORT = (qw(&latexml_ok &latexml_tests),
sub latexml_tests {
my ($directory, %options) = @_;
my $DIR;
if ($options{texlive_min} && (texlive_version() < $options{texlive_min})) {
plan skip_all => "Requirement minimal texlive $options{texlive_min} not met.";
return done_testing(); }
if (!opendir($DIR, $directory)) {
# Can't read directory? Fail (assumed single) test.
return do_fail($directory, "Couldn't read directory $directory:$!"); }
Expand Down Expand Up @@ -78,14 +81,29 @@ sub latexml_tests {
sub check_requirements {
my ($test, $ntests, @reqmts) = @_;
foreach my $reqmts (@reqmts) {
next unless defined $reqmts;
foreach my $reqmt (!$reqmts ? () : (ref $reqmts ? @$reqmts : $reqmts)) {
next unless $reqmts;
my @required_packages = ();
my $texlive_min = 0;
if (!(ref $reqmts)) {
@required_packages = ($reqmts); }
elsif (ref $reqmts eq 'ARRAY') {
@required_packages = @$reqmts; }
elsif (ref $reqmts eq 'HASH') {
@required_packages = $$reqmts{packages};
$texlive_min = $$reqmts{texlive_min} || 0; }
foreach my $reqmt (@required_packages) {
if (pathname_kpsewhich($reqmt) || pathname_find($reqmt)) { }
else {
my $message = "Missing requirement $reqmt for $test";
diag("Skip: $message");
skip($message, $ntests);
return 0; } } }
return 0; } }
# Check if specific texlive versions are required for this test
if ($texlive_min && (texlive_version() < $texlive_min)) {
my $message = "Minimal texlive $texlive_min requirement not met for $test";
diag("Skip: $message");
skip($message, $ntests);
return 0; } }
return 1; }

sub do_fail {
Expand Down Expand Up @@ -289,6 +307,25 @@ sub get_filecontent {
}
return \@lines; }

our $texlive_version;

sub texlive_version {
if (defined $texlive_version) {
return $texlive_version; }
my $extra_flag = '';
if ($ENV{"APPVEYOR"}) {
# disabled under windows for now
return 0; }
if (my $tex = which("tex")) {
my $version_string = `$tex --version`;
if ($version_string =~ /TeX Live (\d+)/) {
$texlive_version = int($1); }
else {
$texlive_version = 0; } }
else {
$texlive_version = 0; }
return $texlive_version; }

# TODO: Reconsider what else we need to test, ideas below:

# Tier 1.3: Math setups with embedding variations
Expand Down
7 changes: 6 additions & 1 deletion t/83_expl3.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
use LaTeXML::Util::Test;

latexml_tests("t/expl3",
requires => { tilde_tricks => 'expl3.sty', xparse => ['expl3.sty','xparse.sty'] });
requires => {
tilde_tricks => 'expl3.sty',
xparse => {
texlive_min => 2018,
packages => ['expl3.sty','xparse.sty']
} } );
Binary file modified t/expl3/xparse.pdf
Binary file not shown.
4 changes: 3 additions & 1 deletion t/expl3/xparse.tex
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
\documentclass{article}
\usepackage{xparse}
\begin{document}
% example from documentation at: https://mirror.las.iastate.edu/tex-archive/macros/latex/contrib/l3packages/xparse.pdf
\NewDocumentCommand {\conjugate} { m O{#1ed} O{#2} } {(#1,#2,#3)}
\begin{document}
\conjugate {walk} % => (walk,walked,walked)

\conjugate {find} [found] % => (find,found,found)

\conjugate {do} [did] [done] % => (do,did,done)
\end{document}
8 changes: 7 additions & 1 deletion t/expl3/xparse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<resource src="LaTeXML.css" type="text/css"/>
<resource src="ltx-article.css" type="text/css"/>
<para xml:id="p1">
<p>(walk,walked,walked) (find,found,found) (do,did,done)</p>
<p>(walk,walked,walked)</p>
</para>
<para xml:id="p2">
<p>(find,found,found)</p>
</para>
<para xml:id="p3">
<p>(do,did,done)</p>
</para>
</document>

0 comments on commit a11b274

Please sign in to comment.