Skip to content

Commit

Permalink
Bookkeeping changes to verify, minor changes to latexdiff
Browse files Browse the repository at this point in the history
  • Loading branch information
ftilmann committed Dec 6, 2015
1 parent 92c930d commit 27615b3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 22 deletions.
23 changes: 12 additions & 11 deletions latexdiff
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
### - add possibility to store configuration options for latexdiff in a file rather than as options
### - use kdiff3 as a merge tool
### - make style that allows (forward and backjumping with hyperref)
### - make style / latexdiff-vc combo that allows only to output pages with changes DONE
### (remember to update answer on stack exchange: http://tex.stackexchange.com/questions/166049/invisible-markers-in-pdfs-using-pdflatex)
### - --flatten option only expands first including command per line if there is more than one
#
# Version 1.1.1alpha
Expand Down Expand Up @@ -156,7 +154,7 @@ my $COUNTERCMD='(?:footnote|part|chapter|section|subsection|subsubsection|paragr
# they will be succeeded by an \addtocounter{...}{-1}
# for the associated counter such that the overall numbers
# should be the same as in the new file
my @UNSAFEMATHCMD=('qedhere'); # Commands which are definitely unsafe for marking up (amsmath qedhere only tested to not work with UNDERLINE markup)
my @UNSAFEMATHCMD=('qedhere'); # Commands which are definitely unsafe for marking up in math mode (amsmath qedhere only tested to not work with UNDERLINE markup) (only affects WHOLE and COARSE math markup modes). Note that unlike text mode (or FINE math mode0 deleted unsafe commands are not deleted but simply taken outside \DIFdel
###my $CITECMD=0 ; # \cite-type commands which need to be protected within an mbox in UNDERLINE and other modes using ulem; pattern simply designed to never match; will be overwritten later for selected styles
###my $CITE2CMD=0; # \cite-type commands which should be reinstated in deleted blocks
my $MBOXINLINEMATH=0; # if set to 1 then surround marked-up inline maths expression with \mbox ( to get around compatibility
Expand Down Expand Up @@ -257,7 +255,7 @@ $mathmarkup=COARSE;

$verbose=0;
# output debug and intermediate files, set to 0 in final distribution
$debug=1;
$debug=0;
# insert preamble directly after documentclass - experimental feature, set to 0 in final distribution
# Note that this failed with mini example (or other files, where packages used in latexdiff preamble
# are called again with incompatible options in preamble of resulting file)
Expand Down Expand Up @@ -603,10 +601,10 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/);
my ($oldfile, $newfile) = @ARGV;
# check for existence of input files
if ( ! -e $oldfile ) {
die "Input file $oldfile does not exist.";
die "Input file $oldfile does not exist";
}
if ( ! -e $newfile ) {
die "Input file $newfile does not exist.";
die "Input file $newfile does not exist";
}


Expand Down Expand Up @@ -942,9 +940,9 @@ if ( $debug ) {
print RAWDIFF $diffbo;
close(RAWDIFF);
}
print STDERR "(",exetime()," s)\n","Postprocessing body. \n " if $verbose;
print STDERR "(",exetime()," s)\n","Postprocessing body. \n" if $verbose;
postprocess($diffbo);
####print "POSTPROCESS NEW:\n$newbody\n ";
####print "POSTPROCESS NEW:\n$newbody\n";
$diffall =join("\n",@diffpreamble) ;
# add visible labels
if (defined($visiblelabel)) {
Expand Down Expand Up @@ -1711,17 +1709,20 @@ sub extractcommands {
sub iscmd {
my ($cmd,$regexar,$regexexcl)=@_;
my ($ret)=0;
### print STDERR "DEBUG: iscmd($cmd) in @$regexar\n" if $debug;
foreach $pat ( @$regexar ) {
if ( $cmd =~ m/^${pat}$/ ) {
$ret=1 ;
last;
}
}
return 0 unless $ret;
### print STDERR "DEBUG: Maybe\n" if $debug;
foreach $pat ( @$regexexcl ) {
### print STDERR "DEBUG iscmd: checking |$cmd| against |$pat|\n";
return 0 if ( $cmd =~ m/^${pat}$/ );
}
### print STDERR "DEBUG: Yes\n" if $debug;
return 1;
}

Expand Down Expand Up @@ -1890,7 +1891,7 @@ sub marktags {
# ""
local @SAFECMDLIST=(".*");
local @SAFECMDEXCL=('\\','\\\\',@UNSAFEMATHCMD);
### print STDERR "DEBUG: Command $command argtext ",join(",",@argtext),"\n" if $debug;
### print STDERR "DEBUG: Command $command argtext ",join(",",@argtext),"\n" if $debug;
push(@$retval,$command,marktags("","",$open,$close,"","",$comment,\@argtext)#@argtext
,$closingbracket);
} else {
Expand All @@ -1904,7 +1905,7 @@ sub marktags {
push (@$retval,$opencmd) if $cmd==-1 ;
push (@$retval,$close,$opencmd) if $cmd==0 ;
$word =~ s/\n/\n${opencmd}/sg if $cmdcomment ; # if opencmd is a comment, repeat this at the beginning of every line
### print STDERR "MARKTAGS: Add command |$word|\n";
### print STDERR "MARKTAGS: Add command |$word|\n";
push (@$retval,$word);
$cmd=1;
}
Expand All @@ -1921,7 +1922,7 @@ sub marktags {
###print STDERR "DEBUG Mboxsafecmd detected:$word:\n" if $debug ;
push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}$AUXCMD\n" );
} else {
# $word is a normal word or a safe command (not in MBOXCMDLIST
# $word is a normal word or a safe command (not in MBOXCMDLIST)
push (@$retval,$word);
}
$cmd=0;
Expand Down
60 changes: 49 additions & 11 deletions testsuite/verify
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/csh
set refversion=1.1.0
set refversion=1.1.1alpha
# for comparison with 0.5:
#set options="-V -t UNDERLINE -s SAFE -f FLOATSAFE --disable-citation-markup"
set options="-V -t UNDERLINE -s SAFE -f FLOATSAFE "
#set options="-V -t UNDERLINE -s SAFE -f FLOATSAFE --math-markup=3"

set reportfile=report.txt

#setenv INTERACTIVE
alias latexdiff ../latexdiff
#alias latexdiff ../dist/latexdiff-fast
Expand All @@ -16,8 +18,11 @@ delequ latin9 pollack move-equation nomarkup subscript doubledollar \
DIFDELCMDBUG eqnarray subscriptm delequ2 schneider gennady umesh underwood endfloat outerrise \
delequ3 delequ4 "simplefrac --allow-spaces" "master --flatten" titlediffTest2 exampleDiff bornd2 \
"rolla --math-markup=2" mini "complex-maths --math-markup=1" margalit circonflex mwe-comment "apacite-test --flatten" quoteddollarunderscore units )

#set testroots= ( test subscript )
# ttest-siunitx ttest-glossaries ttest-chem ttest-cleveref


if ( $#argv >= 1 ) then
if ( $argv[1] == "--reset" ) then
echo "Running verify in RESET mode, ie. save all differences with version number $refversion for later use, overwriting if necessary."
Expand All @@ -38,6 +43,11 @@ set failed
set noexist
set failedrun
set pdfout
if ( ! $?reset ) then
echo "Report of diff test:" > $reportfile
latexdiff --version >>& $reportfile
echo "--------" >> $reportfile
endif
while ( $#testroots >= 1 )
#foreach test ( $testroots)
echo $testroots[1]
Expand All @@ -49,23 +59,34 @@ while ( $#testroots >= 1 )
set eopt
endif
set sample=$sample[1]
printf "%-20s :" $sample[1] >> $reportfile
echo "========================================="
echo "Differencing ${sample}-old.tex ${sample}-new.tex (using $eopt)"
latexdiff $options $eopt ${sample}-old.tex ${sample}-new.tex > ${sample}-diff.tex
( latexdiff $options $eopt ${sample}-old.tex ${sample}-new.tex > ${sample}-diff.tex) >& ${sample}-latexdiff.log
# diff ${sample}-diff-$refversion.tex ${sample}-diff.tex
# sum up the quoted calculation times

if ( $?reset ) then
\cp ${sample}-diff.tex ${sample}-diff-$refversion.tex
\cp ${sample}-latexdiff.log ${sample}-latexdiff-$refversion.log
else
if (! -e ${sample}-diff-$refversion.tex ) then
echo "Reference version ${sample}-diff-$refversion.tex does not exist."
set noexist = ( $noexist $sample )
echo " noref" >> $reportfile
goto run
endif
echo "Comparing ${sample}-diff-$refversion.tex and ${sample}-diff.tex (body only)"
sed -n '/begin{document}/,/end{document}/ p' ${sample}-diff-$refversion.tex > tmp-ref.$$.tex
sed -n '/begin{document}/,/end{document}/ p' ${sample}-diff.tex > tmp-cur.$$.tex
echo "Comparing ${sample}-diff-$refversion.tex and ${sample}-diff.tex (removing latexdiff date stamp)"
# remove 2 lines after pattern
sed -e '/%DIF LATEXDIFF DIFFERENCE FILE/,+2d' ${sample}-diff-$refversion.tex > tmp-ref.$$.tex
sed -e '/%DIF LATEXDIFF DIFFERENCE FILE/,+2d' ${sample}-diff.tex > tmp-cur.$$.tex
### # isolate body
### sed -n '/begin{document}/,/end{document}/ p' ${sample}-diff-$refversion.tex > tmp-ref.$$.tex
### sed -n '/begin{document}/,/end{document}/ p' ${sample}-diff.tex > tmp-cur.$$.tex
diff -q tmp-ref.$$.tex tmp-cur.$$.tex
\rm tmp-{cur,ref}.$$.tex
if ( $status ) then
echo -n " -fail">> $reportfile
if (! $run) diff -c ${sample}-diff-$refversion.tex ${sample}-diff.tex
echo "\07"
echo "Comparison of ${sample}-old.tex and ${sample}-new.tex gave different results to reference version. See above for detailed listing."
Expand All @@ -74,8 +95,15 @@ while ( $#testroots >= 1 )
endif
set failed = ( $failed $sample )
else
echo -n " ok" >> $reportfile
echo "Passed comparison..."
endif
# calculate running time from summing reported time
set totaltime=`perl -ne 'if (/\(([0-9.]*) s\)/){$sum+=$1; } END {print $sum }' ${sample}-latexdiff.log`
set totaltimeref=`perl -ne 'if (/\(([0-9.]*) s\)/){$sum+=$1; } END {print $sum }' ${sample}-latexdiff-$refversion.log`
# timediff[1] absolute diff. timediff[2] % percentage diff rel. to old
set timediff=( `echo $totaltime $totaltimeref | awk '{ diff=$1-$2; print diff, 100*diff/($2+0.005) }'` )
printf " %5.2f s ( %6.2f s)\n" $totaltime $timediff[1] >> $reportfile
endif
run:
if ( $run ) then
Expand All @@ -89,15 +117,25 @@ run:
endif
endif
end
if ( ! $?reset && $#failed >= 1 ) then


#if ( ! $?reset && $#failed >= 1 ) then
if ( ! $?reset ) then
cat $reportfile
unset flagdummy
foreach fail ( $failed )
set flagdummy
echo kdiff3 ${fail}-diff-$refversion.tex ${fail}-diff.tex
end
echo ""
echo "The following test(s) failed:"
echo $failed
echo "The following test(s) did not have a reference version available:"
echo $noexist
if ($?flagdummy ) then
echo ""
echo "The following test(s) failed:"
echo $failed
endif
if ( "x$noexist" != x ) then
echo "The following test(s) did not have a reference version available:"
echo $noexist
endif
endif

if ( $run ) then
Expand Down

0 comments on commit 27615b3

Please sign in to comment.