mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Cmake tests: Added check to inspect created pdf in test "AMS-import"
If the command "comparepdf" is found, it will be used. Also the script lyx_batch.pl is now easier to expand for possible new comparision tools.
This commit is contained in:
parent
8a2392bcec
commit
aca3031352
BIN
development/batchtests/ams-import.pdf
Normal file
BIN
development/batchtests/ams-import.pdf
Normal file
Binary file not shown.
26
development/batchtests/ams-import.tex
Normal file
26
development/batchtests/ams-import.tex
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
\documentclass{amsart}
|
||||||
|
|
||||||
|
\theoremstyle{plain}
|
||||||
|
\newtheorem{thm}{\protect\theoremname}[section]
|
||||||
|
%\newtheorem{thm}{\protect\theoremname}% => works
|
||||||
|
\newtheorem{cor}[thm]{\protect\corollaryname}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\section{Introduction}
|
||||||
|
|
||||||
|
We assume
|
||||||
|
|
||||||
|
\begin{thm}
|
||||||
|
For every $\epsilon>0$, there is a constant $\delta>0$ so that if
|
||||||
|
\end{thm}
|
||||||
|
|
||||||
|
\begin{cor}
|
||||||
|
For every $\epsilon>0$, there is a constant $\delta>0$ so that if
|
||||||
|
\end{cor}
|
||||||
|
|
||||||
|
\begin{thm}
|
||||||
|
There exists a positive constant $C_2$ so that
|
||||||
|
\end{thm}
|
||||||
|
|
||||||
|
\end{document}
|
||||||
|
|
@ -10,6 +10,13 @@ if (UNIX)
|
|||||||
# include(../PyCompile)
|
# include(../PyCompile)
|
||||||
endif()
|
endif()
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/prefTest.pl.in" "${CMAKE_BINARY_DIR}/prefTest.pl" @ONLY)
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/prefTest.pl.in" "${CMAKE_BINARY_DIR}/prefTest.pl" @ONLY)
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/checkKeys.pl.in" "${CMAKE_BINARY_DIR}/checkKeys.pl" @ONLY)
|
||||||
|
find_program(COMPAREPDF_EXECUTABLE comparepdf)
|
||||||
|
if (COMPAREPDF_EXECUTABLE MATCHES "-NOTFOUND")
|
||||||
|
message(STATUS "comparepdf (= \"${COMPAREPDF_EXECUTABLE}\") not found ==> no pdf comparision in test AMS-import")
|
||||||
|
else()
|
||||||
|
message(STATUS "found COMPAREPDF_EXECUTABLE = ${COMPAREPDF_EXECUTABLE}")
|
||||||
|
endif()
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lyx_batch.pl.in" "${CMAKE_BINARY_DIR}/lyx_batch.pl" @ONLY)
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lyx_batch.pl.in" "${CMAKE_BINARY_DIR}/lyx_batch.pl" @ONLY)
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,9 +8,10 @@ use warnings;
|
|||||||
use File::Copy;
|
use File::Copy;
|
||||||
use File::Compare;
|
use File::Compare;
|
||||||
|
|
||||||
sub check_precondition();
|
sub checkPrecondition();
|
||||||
sub system1(@);
|
sub system1(@);
|
||||||
sub add_files($$);
|
sub addFiles($$$);
|
||||||
|
sub mycompare($$$);
|
||||||
|
|
||||||
my $builddir = "@CMAKE_BINARY_DIR@";
|
my $builddir = "@CMAKE_BINARY_DIR@";
|
||||||
my $userdir = "$builddir/Testing/.lyxbatch";
|
my $userdir = "$builddir/Testing/.lyxbatch";
|
||||||
@ -23,19 +24,20 @@ my $qt_version = "@LYX_USE_QT@";
|
|||||||
|
|
||||||
my $lyxsource = "@LYX_ABS_TOP_SRCDIR@";
|
my $lyxsource = "@LYX_ABS_TOP_SRCDIR@";
|
||||||
my $data = "$lyxsource/development/batchtests";
|
my $data = "$lyxsource/development/batchtests";
|
||||||
|
my $comparepdf = "@COMPAREPDF_EXECUTABLE@";
|
||||||
|
|
||||||
# src_files := Files to be copied from lyx-source to build-dir
|
# src_files := Files to be copied from lyx-source to build-dir
|
||||||
# create := Files which are expected to be created in the build-dir
|
# check := List of tripples
|
||||||
# original := Files in the lyx-source, corresponding to the created ones,
|
# created file (in build-dir)
|
||||||
# which we provide for comparison
|
# expected file (in source dir, to be compared with the created one)
|
||||||
# commands := List of commands (lyx-functions) to be executed by lyx in a batch
|
# eventually system command to compare files
|
||||||
|
# commands := List of commands (lyx-functions) to be executed by lyx in a batch
|
||||||
# precondition: system commands to be executed prior to the test
|
# precondition: system commands to be executed prior to the test
|
||||||
# command_line: List of parameters to be used on the lyx-command-line
|
# command_line: List of parameters to be used on the lyx-command-line
|
||||||
my %Tests = (
|
my %Tests = (
|
||||||
beamer_test => {
|
beamer_test => {
|
||||||
src_files => ["beamer_test.lyx"],
|
src_files => ["beamer_test.lyx"],
|
||||||
create => ["beamer_test.tex"],
|
check => [["beamer_test.tex", "beamer_test.tex.orig"]],
|
||||||
original => ["beamer_test.tex.orig"],
|
|
||||||
commands => ["file-open beamer_test.lyx",
|
commands => ["file-open beamer_test.lyx",
|
||||||
"buffer-begin",
|
"buffer-begin",
|
||||||
"repeat 150 outline-down",
|
"repeat 150 outline-down",
|
||||||
@ -50,14 +52,13 @@ my %Tests = (
|
|||||||
workdir => "$data",
|
workdir => "$data",
|
||||||
},
|
},
|
||||||
src_files => ["vcs_info_export.lyx"],
|
src_files => ["vcs_info_export.lyx"],
|
||||||
create => ["vcs_info_export.tex"],
|
check => [["vcs_info_export.tex", "vcs_info_export.tex.orig"]],
|
||||||
original => ["vcs_info_export.tex.orig"],
|
|
||||||
command_line => ["-E", "pdflatex", "vcs_info_export.tex", "$data/vcs_info_export.lyx"],
|
command_line => ["-E", "pdflatex", "vcs_info_export.tex", "$data/vcs_info_export.lyx"],
|
||||||
},
|
},
|
||||||
"ams-import" => {
|
"ams-import" => {
|
||||||
src_files => ["ams-import.tex"],
|
src_files => ["ams-import.tex"],
|
||||||
create => ["ams-import.pdf", "ams-import.lyx"],
|
check => [["ams-import.pdf", "ams-import.pdf", $comparepdf],
|
||||||
original => [undef, undef],
|
["ams-import.lyx"]],
|
||||||
commands => ["buffer-new",
|
commands => ["buffer-new",
|
||||||
"buffer-import latex ams-import.tex",
|
"buffer-import latex ams-import.tex",
|
||||||
"buffer-write",
|
"buffer-write",
|
||||||
@ -73,9 +74,11 @@ die("Invalid argument") if (! defined($Tests{$test}));
|
|||||||
if (! -e $userdir) {
|
if (! -e $userdir) {
|
||||||
mkdir($userdir);
|
mkdir($userdir);
|
||||||
}
|
}
|
||||||
my @expected = &add_files($data, $Tests{$test}->{original});
|
my @expected = &addFiles($data, $Tests{$test}->{check},1);
|
||||||
|
|
||||||
my @created = &add_files($workdir, $Tests{$test}->{create});
|
my @created = &addFiles($workdir, $Tests{$test}->{check}, 0);
|
||||||
|
|
||||||
|
my @comparecommand = &addFiles(undef, $Tests{$test}->{check}, 2);
|
||||||
|
|
||||||
# Copy src-files to work with
|
# Copy src-files to work with
|
||||||
for my $f (@{$Tests{$test}->{src_files}}) {
|
for my $f (@{$Tests{$test}->{src_files}}) {
|
||||||
@ -88,31 +91,35 @@ $ENV{LANG} = "en";
|
|||||||
$ENV{LC_ALL} = "C";
|
$ENV{LC_ALL} = "C";
|
||||||
$ENV{LANGUAGE} = "en_US";
|
$ENV{LANGUAGE} = "en_US";
|
||||||
|
|
||||||
check_precondition();
|
&checkPrecondition();
|
||||||
chdir($workdir);
|
chdir($workdir);
|
||||||
my @command = ($lyx_exe, "-userdir", $userdir);
|
my @command = ($lyx_exe, "-userdir", $userdir);
|
||||||
if (defined($Tests{$test}->{command_line})) {
|
if (defined($Tests{$test}->{command_line})) {
|
||||||
push(@command, @{$Tests{$test}->{command_line}});
|
push(@command, @{$Tests{$test}->{command_line}});
|
||||||
}
|
}
|
||||||
if (defined($Tests{$test}->{commands})) {
|
if (defined($Tests{$test}->{commands}->[0])) {
|
||||||
if ($qt_version eq "QT5") {
|
if ($qt_version eq "QT5") {
|
||||||
push(@command, "-platform", "offscreen");
|
push(@command, "-platform", "offscreen");
|
||||||
}
|
}
|
||||||
push(@command, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
|
if (defined($Tests{$test}->{commands}->[1])) { # more than one command
|
||||||
|
push(@command, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
push(@command, "-x", $Tests{$test}->{commands}->[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
system1(@command);
|
&system1(@command);
|
||||||
for my $f (@created) {
|
|
||||||
die("File \"$f\" not created") if (! -e "$f");
|
|
||||||
}
|
|
||||||
for (my $i = 0; defined($created[$i]); $i++) {
|
for (my $i = 0; defined($created[$i]); $i++) {
|
||||||
if (defined($expected[$i])) {
|
die("File \"$created[$i]\" not created") if (! -e "$created[$i]");
|
||||||
die("Expected ($expected[$i]) and created ($created[$i]) files differ") if (compare($expected[$i], $created[$i]) != 0);
|
if (defined($expected[$i])) {
|
||||||
|
die("Expected ($expected[$i]) and created ($created[$i]) files differ") if (&mycompare($comparecommand[$i], $expected[$i], $created[$i]) != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
sub check_precondition()
|
sub checkPrecondition()
|
||||||
{
|
{
|
||||||
return if (! defined($Tests{$test}->{precondition}));
|
return if (! defined($Tests{$test}->{precondition}));
|
||||||
my $rPrecond = $Tests{$test}->{precondition};
|
my $rPrecond = $Tests{$test}->{precondition};
|
||||||
@ -120,7 +127,7 @@ sub check_precondition()
|
|||||||
if (defined($rPrecond->{workdir})) {
|
if (defined($rPrecond->{workdir})) {
|
||||||
chdir($rPrecond->{workdir});
|
chdir($rPrecond->{workdir});
|
||||||
}
|
}
|
||||||
my $result = system1(@command);
|
my $result = &system1(@command);
|
||||||
print "Pre-condition result = $result\n";
|
print "Pre-condition result = $result\n";
|
||||||
die("Pre-condition error") if ($result != 0);
|
die("Pre-condition error") if ($result != 0);
|
||||||
}
|
}
|
||||||
@ -129,23 +136,69 @@ sub system1(@)
|
|||||||
{
|
{
|
||||||
my ($exe, @params) = @_;
|
my ($exe, @params) = @_;
|
||||||
print "Executing:\n\t$exe '" . join("' '", @params) . "'\n";
|
print "Executing:\n\t$exe '" . join("' '", @params) . "'\n";
|
||||||
system($exe, @params);
|
return(system($exe, @params));
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a list of file paths
|
# Create a list of file paths
|
||||||
# dir: result-dir
|
# dir: result-dir
|
||||||
# rBases: List of base-names
|
# rBases: List of base-names
|
||||||
sub add_files($$)
|
sub addFiles($$$)
|
||||||
{
|
{
|
||||||
my ($dir, $rBases) = @_;
|
my ($tdir, $rrBases, $idx) = @_;
|
||||||
|
my $dir;
|
||||||
|
if (defined($tdir)) {
|
||||||
|
$dir = "$tdir/";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$dir = "";
|
||||||
|
}
|
||||||
my @result = ();
|
my @result = ();
|
||||||
for my $f (@{$rBases}) {
|
for my $rf (@{$rrBases}) {
|
||||||
if (defined($f)) {
|
my $path = undef;
|
||||||
push(@result, "$dir/$f");
|
if (defined($rf) && defined($rf->[$idx])) {
|
||||||
}
|
$path = "$dir$rf->[$idx]";
|
||||||
else {
|
|
||||||
push(@result, undef);
|
|
||||||
}
|
}
|
||||||
|
push(@result, $path);
|
||||||
}
|
}
|
||||||
return(@result);
|
return(@result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub mycompare($$$)
|
||||||
|
{
|
||||||
|
my ($cmd, $expected, $created) = @_;
|
||||||
|
my $result;
|
||||||
|
if (defined($cmd)) { # system command desired
|
||||||
|
my @params = ();
|
||||||
|
if ($cmd =~ /NOTFOUND/) {
|
||||||
|
# no check is done due to missing executable
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($cmd =~ /comparepdf/) {
|
||||||
|
push(@params, "-ca", "-v=1", $expected, $created);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die("unknown system command $cmd");
|
||||||
|
}
|
||||||
|
my $error = "";
|
||||||
|
if (&system1($cmd, @params) != 0) {
|
||||||
|
if ($? == -1) {
|
||||||
|
$error = sprintf("failed to execute: $cmd");
|
||||||
|
}
|
||||||
|
elsif ($? & 127) {
|
||||||
|
$error = sprintf("$cmd with signal %d, %s coredump",
|
||||||
|
($? & 127), ($? & 128) ? 'with' : 'without');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$error = sprintf("child $cmd exited with value %d", $? >> 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
die($error) if ($error ne "");
|
||||||
|
}
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# defaut text comparision
|
||||||
|
$result = compare($created, $expected);
|
||||||
|
}
|
||||||
|
return($result);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user