mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
17dc24419a
Also add the 'export'- label to this test
97 lines
2.5 KiB
Perl
Executable File
97 lines
2.5 KiB
Perl
Executable File
#! /usr/bin/env perl
|
|
# -*- mode: perl; -*-
|
|
|
|
# lyx_batch.pl testname
|
|
|
|
use strict;
|
|
use warnings;
|
|
use File::Copy;
|
|
use File::Compare;
|
|
|
|
sub check_precondition();
|
|
sub system1(@);
|
|
|
|
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";
|
|
my $git_exe = "@LYX_GITVERSION@";
|
|
|
|
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",
|
|
"buffer-reload dump",
|
|
"lyx-quit"]
|
|
},
|
|
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"],
|
|
}
|
|
);
|
|
|
|
die("Expected argument missing") if (! defined($ARGV[0]));
|
|
my $test = $ARGV[0];
|
|
die("Invalid argument") if (! defined($Tests{$test}));
|
|
|
|
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";
|
|
|
|
check_precondition();
|
|
chdir($workdir);
|
|
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);
|
|
|
|
exit(0);
|
|
|
|
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);
|
|
}
|