2018-01-14 12:47:27 +00:00
|
|
|
#! /usr/bin/env perl
|
|
|
|
# -*- mode: perl; -*-
|
|
|
|
|
|
|
|
# lyx_batch.pl testname
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use File::Copy;
|
|
|
|
use File::Compare;
|
|
|
|
|
2018-01-17 11:25:22 +00:00
|
|
|
sub check_precondition();
|
|
|
|
sub system1(@);
|
|
|
|
|
2018-01-14 12:47:27 +00:00
|
|
|
my $builddir = "@CMAKE_BINARY_DIR@";
|
|
|
|
my $userdir = "$builddir/Testing/.lyx";
|
|
|
|
my $workdir = "$builddir/autotests/out-home";
|
|
|
|
|
|
|
|
my $vsuffix = "@PROGRAM_SUFFIX@";
|
|
|
|
my $lyx_exe = "$builddir/bin/lyx$vsuffix";
|
2018-01-17 11:25:22 +00:00
|
|
|
my $git_exe = "@LYX_GITVERSION@";
|
2018-01-14 12:47:27 +00:00
|
|
|
|
|
|
|
my $lyxsource = "@LYX_ABS_TOP_SRCDIR@";
|
|
|
|
my $data = "$lyxsource/development/batchtests";
|
|
|
|
|
|
|
|
my %Tests = (
|
|
|
|
beamer_test => {
|
|
|
|
create => "beamer_test.tex",
|
|
|
|
commands => ["file-open beamer_test.lyx",
|
|
|
|
"buffer-begin",
|
|
|
|
"repeat 150 outline-down",
|
|
|
|
"repeat 150 outline-up",
|
|
|
|
"buffer-export pdflatex",
|
|
|
|
"repeat 150 outline-down",
|
|
|
|
"buffer-reload dump",
|
|
|
|
"lyx-quit"]
|
2018-01-17 11:25:22 +00:00
|
|
|
},
|
|
|
|
vcs_info_export => {
|
|
|
|
precondition => {
|
|
|
|
command => [$git_exe, "ls-files", "--error-unmatch", "vcs_info_export.lyx"],
|
|
|
|
workdir => "$data",
|
|
|
|
},
|
|
|
|
create => "vcs_info_export.tex",
|
|
|
|
command_line => ["-E", "pdflatex", "vcs_info_export.tex", "$data/vcs_info_export.lyx"],
|
2018-01-14 12:47:27 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-01-17 11:25:22 +00:00
|
|
|
die("Expected argument missing") if (! defined($ARGV[0]));
|
2018-01-14 12:47:27 +00:00
|
|
|
my $test = $ARGV[0];
|
2018-01-17 11:25:22 +00:00
|
|
|
die("Invalid argument") if (! defined($Tests{$test}));
|
2018-01-14 12:47:27 +00:00
|
|
|
|
|
|
|
my $orig_lyx = "$data/$test.lyx";
|
|
|
|
my $work_lyx = "$workdir/$test.lyx";
|
|
|
|
my $expected = "$data/$test.tex.orig";
|
|
|
|
my $created = "$workdir/$Tests{$test}->{create}";
|
|
|
|
|
|
|
|
die("File \"$expected\" does not exist") if (! -e $expected);
|
|
|
|
# Create lyx-file to work with
|
|
|
|
copy($orig_lyx, $work_lyx) or die("Copy failed: $!");
|
|
|
|
unlink($created);
|
|
|
|
$ENV{LANG} = "en";
|
|
|
|
$ENV{LC_ALL} = "C";
|
|
|
|
$ENV{LANGUAGE} = "en_US";
|
|
|
|
|
2018-01-17 11:25:22 +00:00
|
|
|
check_precondition();
|
2018-01-14 12:47:27 +00:00
|
|
|
chdir($workdir);
|
2018-01-17 11:25:22 +00:00
|
|
|
my @command = ($lyx_exe, "-userdir", $userdir);
|
|
|
|
if (defined($Tests{$test}->{command_line})) {
|
|
|
|
push(@command, @{$Tests{$test}->{command_line}});
|
|
|
|
}
|
|
|
|
if (defined($Tests{$test}->{commands})) {
|
|
|
|
push(@command, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
|
|
|
|
}
|
|
|
|
|
|
|
|
system1(@command);
|
|
|
|
die("Expected ($expected) and created ($created) files differ") if (compare($expected, $created) != 0);
|
2018-01-14 12:47:27 +00:00
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
2018-01-17 11:25:22 +00:00
|
|
|
sub check_precondition()
|
|
|
|
{
|
|
|
|
return if (! defined($Tests{$test}->{precondition}));
|
|
|
|
my $rPrecond = $Tests{$test}->{precondition};
|
|
|
|
my @command = @{$rPrecond->{command}};
|
|
|
|
if (defined($rPrecond->{workdir})) {
|
|
|
|
chdir($rPrecond->{workdir});
|
|
|
|
}
|
|
|
|
my $result = system1(@command);
|
|
|
|
print "Pre-condition result = $result\n";
|
|
|
|
die("Pre-condition error") if ($result != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub system1(@)
|
|
|
|
{
|
|
|
|
my ($exe, @params) = @_;
|
|
|
|
print "Executing:\n\t$exe '" . join("' '", @params) . "'\n";
|
|
|
|
system($exe, @params);
|
|
|
|
}
|