4 # lyx_batch.pl testname
11 sub check_precondition();
14 my $builddir = "@CMAKE_BINARY_DIR@";
15 my $userdir = "$builddir/Testing/.lyx";
16 my $workdir = "$builddir/autotests/out-home";
18 my $vsuffix = "@PROGRAM_SUFFIX@";
19 my $lyx_exe = "$builddir/bin/lyx$vsuffix";
20 my $git_exe = "@LYX_GITVERSION@";
22 my $lyxsource = "@LYX_ABS_TOP_SRCDIR@";
23 my $data = "$lyxsource/development/batchtests";
27 create => "beamer_test.tex",
28 commands => ["file-open beamer_test.lyx",
30 "repeat 150 outline-down",
31 "repeat 150 outline-up",
32 "buffer-export pdflatex",
38 command => [$git_exe, "ls-files", "--error-unmatch", "vcs_info_export.lyx"],
41 create => "vcs_info_export.tex",
42 command_line => ["-E", "pdflatex", "vcs_info_export.tex", "$data/vcs_info_export.lyx"],
46 die("Expected argument missing") if (! defined($ARGV[0]));
48 die("Invalid argument") if (! defined($Tests{$test}));
50 my $orig_lyx = "$data/$test.lyx";
51 my $work_lyx = "$workdir/$test.lyx";
52 my $expected = "$data/$test.tex.orig";
53 my $created = "$workdir/$Tests{$test}->{create}";
55 die("File \"$expected\" does not exist") if (! -e $expected);
56 # Create lyx-file to work with
57 copy($orig_lyx, $work_lyx) or die("Copy failed: $!");
61 $ENV{LANGUAGE} = "en_US";
65 my @command = ($lyx_exe, "-userdir", $userdir);
66 if (defined($Tests{$test}->{command_line})) {
67 push(@command, @{$Tests{$test}->{command_line}});
69 if (defined($Tests{$test}->{commands})) {
70 push(@command, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
74 die("Expected ($expected) and created ($created) files differ") if (compare($expected, $created) != 0);
78 sub check_precondition()
80 return if (! defined($Tests{$test}->{precondition}));
81 my $rPrecond = $Tests{$test}->{precondition};
82 my @command = @{$rPrecond->{command}};
83 if (defined($rPrecond->{workdir})) {
84 chdir($rPrecond->{workdir});
86 my $result = system1(@command);
87 print "Pre-condition result = $result\n";
88 die("Pre-condition error") if ($result != 0);
93 my ($exe, @params) = @_;
94 print "Executing:\n\t$exe '" . join("' '", @params) . "'\n";
95 system($exe, @params);