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",
33 "repeat 150 outline-down",
39 command => [$git_exe, "ls-files", "--error-unmatch", "vcs_info_export.lyx"],
42 create => "vcs_info_export.tex",
43 command_line => ["-E", "pdflatex", "vcs_info_export.tex", "$data/vcs_info_export.lyx"],
47 die("Expected argument missing") if (! defined($ARGV[0]));
49 die("Invalid argument") if (! defined($Tests{$test}));
51 my $orig_lyx = "$data/$test.lyx";
52 my $work_lyx = "$workdir/$test.lyx";
53 my $expected = "$data/$test.tex.orig";
54 my $created = "$workdir/$Tests{$test}->{create}";
56 die("File \"$expected\" does not exist") if (! -e $expected);
57 # Create lyx-file to work with
58 copy($orig_lyx, $work_lyx) or die("Copy failed: $!");
62 $ENV{LANGUAGE} = "en_US";
66 my @command = ($lyx_exe, "-userdir", $userdir);
67 if (defined($Tests{$test}->{command_line})) {
68 push(@command, @{$Tests{$test}->{command_line}});
70 if (defined($Tests{$test}->{commands})) {
71 push(@command, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
75 die("Expected ($expected) and created ($created) files differ") if (compare($expected, $created) != 0);
79 sub check_precondition()
81 return if (! defined($Tests{$test}->{precondition}));
82 my $rPrecond = $Tests{$test}->{precondition};
83 my @command = @{$rPrecond->{command}};
84 if (defined($rPrecond->{workdir})) {
85 chdir($rPrecond->{workdir});
87 my $result = system1(@command);
88 print "Pre-condition result = $result\n";
89 die("Pre-condition error") if ($result != 0);
94 my ($exe, @params) = @_;
95 print "Executing:\n\t$exe '" . join("' '", @params) . "'\n";
96 system($exe, @params);