Skip to content

Commit

Permalink
Cpan fixes (#1658)
Browse files Browse the repository at this point in the history
* Avoid all git related stuff in Makefile unless within a git clone

* Don't require specific version of ANSIColor

* Don't use timeout for daemon tests

* Remove pointless test math/aa (using problematic aa.cls)

* Add new test feedback case

* Add a fake testcase that provides hidden version info to ease interpretation of cpantesters

* Remove obsolete tests math/aa from MANIFEST

* fix typo

* Fix POD typo
  • Loading branch information
brucemiller authored Sep 30, 2021
1 parent 2b503fd commit e270463
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 118 deletions.
4 changes: 1 addition & 3 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ lib/LaTeXML/texmf/lxRDFa.sty
#==================================================
# Test Suite.
#==================================================
t/000_test_context.t
t/00_unittest.t
t/002_unit_findfile.t
t/05_tokenize.t
Expand Down Expand Up @@ -1337,9 +1338,6 @@ t/keyval_options/xkvdop6a.xml
t/keyval_options/xkvdop6b.pdf
t/keyval_options/xkvdop6b.tex
t/keyval_options/xkvdop6b.xml
t/math/aa.pdf
t/math/aa.tex
t/math/aa.xml
t/math/ambiguous_relations.pdf
t/math/ambiguous_relations.tex
t/math/ambiguous_relations.xml
Expand Down
55 changes: 31 additions & 24 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ WriteMakefile(NAME => 'LaTeXML',
'XML::LibXSLT' => 1.58,
},
EXE_FILES => ['bin/latexml', 'bin/latexmlpost', 'bin/latexmlfind', 'bin/latexmlmath', 'bin/latexmlc'],
macro => $MORE_MACROS,
macro => $MORE_MACROS,
# link to github location to newer MakeMaker
(eval { ExtUtils::MakeMaker->VERSION(6.46) } ? (META_MERGE => {
'meta-spec' => { version => 2 },
Expand All @@ -110,50 +110,57 @@ print STDERR ('=' x 55), "\n",
#**********************************************************************

#======================================================================
# Record the current (svn) repository revision number
# Record the current git revision (last commit)
sub record_revision {
# Don't copy the Version template to the installation; it's not needed
push(@EXCLUSIONS, 'blib/lib/LaTeXML/Version.in');
# This should be the top-level directory, so it's revision should represent the whole project
$$MORE_MACROS{REVISION_BASE} = $FindBin::RealBin;
# This is where the REVISION gets stored (along with VERSION, etc)
$$MORE_MACROS{REVISION_FILE} = '$(INST_LIBDIR)/LaTeXML/Version.pm';
# Get the current revision
# This should be done SAFELY; and work even if svnversion isn't available (esp, windows, mac...)
# (When it isn't there's an error, but REVISION ends up "" ... exactly right, I think?)
## This command is appropriate for svn
## $$MORE_MACROS{REVISION} = '$(shell svnversion $(REVISION_BASE))';
## This command is appropriate for git (I think)
if ((-e '.git') && (system("git --version") == 0)) { # If a git checkout & can run git?
print STDERR "\n"; # space out messages
$$MORE_MACROS{REVISION} = '$(shell git log --max-count=1 --abbrev-commit --pretty="%h")'; }
# Extract the previously recorded revision from the revision file (awkward)
$$MORE_MACROS{OLD_REVISION}
= '$(shell $(PERLRUN) -ne "chomp;if(s/.*?REVISION\s*=\s*\'// && s/\s*\'.*//){print;}" < $(REVISION_FILE))';
# Get the current revision --- SAFELY !!!!
# Don't do anything extra unless we appear to be a git clone.
# We'll assume such systems have a better make supporting $(shell ... ????
my $is_gitclone = (-e '.git') && (system("git --version") == 0);
if ($is_gitclone) { # If a git checkout & can run git?
print STDERR "\n"; # space out messages
$$MORE_MACROS{REVISION} = '$(shell git log --max-count=1 --abbrev-commit --pretty="%h")';
# Extract the previously recorded revision from the revision file (awkward)
$$MORE_MACROS{OLD_REVISION}
= '$(shell $(PERLRUN) -ne "chomp;if(s/.*?REVISION\s*=\s*\'// && s/\s*\'.*//){print;}" < $(REVISION_FILE))'; }
# Substitute the revision into the revision template
$$MORE_MACROS{RECORD_REVISION} = '$(PERLRUN) -pe "s@__REVISION__@$(REVISION)@" ';

# Have concerns about the $(noecho), but otherwise, it's annoying!
# it prints _every_ time you make, even if it doesn't update!

# This is for all systems, copies Version.in to Version.pm
$MORE_MAKERULES .= <<'RecordRevision';
# Record the svn revision in the Version module, for more informative diagnostics
pure_all :: $(REVISION_FILE) update_revision
# Always set revision if version module template is newer
pure_all :: $(REVISION_FILE)
# Always set version if version module template is newer
$(REVISION_FILE): lib/LaTeXML/Version.in
$(NOECHO) $(MKPATH) $(INST_LIBDIR)/LaTeXML
$(RECORD_REVISION) lib/LaTeXML/Version.in > $(REVISION_FILE)
# update version if stored revision if not current
RecordRevision

# This is for git clones only, and updates revision to last commit
if ($is_gitclone) {
$MORE_MAKERULES .= <<'UpdateRevision';
# For git clones, record the git revision in the Version module
pure_all :: update_revision
update_revision:
$(NOECHO) $(MKPATH) $(INST_LIBDIR)/LaTeXML
- $(NOECHO) $(PERLRUN) -e "exit(1) unless '$(REVISION)' eq '$(OLD_REVISION)';" \
|| $(RECORD_REVISION) lib/LaTeXML/Version.in > $(REVISION_FILE)
RecordRevision
UpdateRevision
}
return; }

#======================================================================
# We'll compile the RecDescent grammar during make; don't need to install grammar.
sub compile_MathGrammar {
Expand Down Expand Up @@ -205,8 +212,8 @@ MakeGrammar
# embedded spaces.
sub install_TeXStyles {
if (!$TEXMF) {
$KPSE_TOOLCHAIN = "--miktex-admin" if ($ENV{"LATEXML_KPSEWHICH_MIKTEX_ADMIN"}); # assume miktex admin on windows CI
if (system("kpsewhich --version $KPSE_TOOLCHAIN") == 0) { # can run kpsewhich?
$KPSE_TOOLCHAIN = "--miktex-admin" if ($ENV{"LATEXML_KPSEWHICH_MIKTEX_ADMIN"}); # assume miktex admin on windows CI
if (system("kpsewhich --version $KPSE_TOOLCHAIN") == 0) { # can run kpsewhich?
$TEXMF = `kpsewhich --expand-var='\$TEXMFLOCAL' $KPSE_TOOLCHAIN`;
# Strip the quotes (they appear in windows, when spaces in pathnames(?))
# These quotes inhibit pasting pathnames togheter,
Expand Down
2 changes: 1 addition & 1 deletion lib/LaTeXML/Common/Error.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use LaTeXML::Common::Object;
use LaTeXML::Util::Pathname;
use LaTeXML::Core::Token qw(T_CS);
use Time::HiRes;
use Term::ANSIColor 2.01 qw(colored colorstrip);
use Term::ANSIColor qw(colored colorstrip);

use base qw(Exporter);
our @EXPORT = (
Expand Down
10 changes: 5 additions & 5 deletions lib/LaTeXML/Util/Radix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ my @rmletters = ('i', 'v', 'x', 'l', 'c', 'd', 'm'); # [CONSTANT]
sub radix_roman {
my ($n) = @_;
my $div = 1000;
my $s = ($n > $div ? ('m' x int($n / $div)) : '');
my $p = 4;
my $s = ($n > $div ? ('m' x int($n / $div)) : '');
my $p = 4;
while ($n %= $div) {
$div /= 10;
my $d = int($n / $div);
if ($d % 5 == 4) { $s .= $rmletters[$p]; $d++; }
if ($d > 4) { $s .= $rmletters[$p + int($d / 5)]; $d %= 5; }
if ($d) { $s .= $rmletters[$p] x $d; }
if ($d > 4) { $s .= $rmletters[$p + int($d / 5)]; $d %= 5; }
if ($d) { $s .= $rmletters[$p] x $d; }
$p -= 2; }
return $s; }

Expand Down Expand Up @@ -140,7 +140,7 @@ Converts the number as a uppercase roman numeral
(Internal) Converts the number into one or symbols taken from C<symbols>.
==back
=back
=head1 AUTHOR
Expand Down
4 changes: 2 additions & 2 deletions lib/LaTeXML/Util/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ sub check_requirements {
@required_packages = @$reqmts; }
elsif (ref $reqmts eq 'HASH') {
@required_packages = (ref $$reqmts{packages} eq 'ARRAY' ? @{ $$reqmts{packages} } : $$reqmts{packages});
$texlive_min = $$reqmts{texlive_min} || 0; }
$texlive_min = $$reqmts{texlive_min} || 0; }
foreach my $reqmt (@required_packages) {
if (pathname_kpsewhich($reqmt) || pathname_find($reqmt)) { }
else {
Expand Down Expand Up @@ -257,12 +257,12 @@ sub daemon_ok {
['quiet', ''],
['quiet', ''],
['quiet', ''],
['timeout', 10],
['autoflush', 1],
['timestamp', '0'],
['nodefaultresources', ''],
['xsltparameter', 'LATEXML_VERSION:TEST'],
['nocomments', '']);
#### ['timeout', 10],

my $latexmlc = catfile($FindBin::Bin, '..', 'blib', 'script', 'latexmlc');
$latexmlc =~ s/^\.\///;
Expand Down
42 changes: 42 additions & 0 deletions t/000_test_context.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- CPERL -*-
#**********************************************************************
# Record testing context for LaTeXML
#**********************************************************************
use LaTeXML;
use LaTeXML::Util::Test;
use File::Which;

# Show the context in which we're running tests.
# in particular, the versions of things which tend to cause problems,
# and which aren't as obvious from a CPAN Tester's page.
sub show_context {
my @context = ("", "LaTeXML version $LaTeXML::VERSION");
# Find libxml2, libxslt
{
require XML::LibXML;
require XML::LibXSLT;
push(@context, "XML::LibXML $XML::LibXML::VERSION; libxml2 "
. XML::LibXML::LIBXML_RUNTIME_VERSION());
push(@context, "XML::LibXSLT $XML::LibXSLT::VERSION; libxslt "
. XML::LibXSLT::LIBXSLT_RUNTIME_VERSION()); }

# kpsewhich has it's own version, we need the version from tex, itself; So find tex:
if (my $path = $ENV{LATEXML_KPSEWHICH}) {
if (($path =~ s/kpsewhich/tex/i) && (-X $path)) {
$tex = $path; } }
if (!$tex) { # Else look for executable
$tex = which("tex"); }
if ($tex && open(my $texfh, '-|', $tex, '--version')) { # If we found one, hope it has TeX Live version in it's --version
my $texv = <$texfh>;
push(@context, $texv); # 1st line only
close($texfh); }
else {
push(@context, "No TeX"); }

my $ok = ok(1, "Test Context");
diag(join("\n ", @context));
return $ok; }

plan tests => 1;
show_context();

Binary file removed t/math/aa.pdf
Binary file not shown.
19 changes: 0 additions & 19 deletions t/math/aa.tex

This file was deleted.

64 changes: 0 additions & 64 deletions t/math/aa.xml

This file was deleted.

0 comments on commit e270463

Please sign in to comment.