4 # lyx_batch.pl testname
11 sub check_precondition();
14 my $builddir = "@CMAKE_BINARY_DIR@";
15 my $userdir = "$builddir/Testing/.lyxbatch";
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";
28 create => ["beamer_test.tex"],
29 commands => ["file-open beamer_test.lyx",
31 "repeat 150 outline-down",
32 "repeat 150 outline-up",
33 "buffer-export pdflatex",
39 command => [$git_exe, "ls-files", "--error-unmatch", "vcs_info_export.lyx"],
43 create => ["vcs_info_export.tex"],
44 command_line => ["-E", "pdflatex", "vcs_info_export.tex", "$data/vcs_info_export.lyx"],
49 create => ["ams-import.pdf", "ams-import.lyx"],
50 commands => ["buffer-new",
51 "buffer-import latex ams-import.tex",
58 die("Expected argument missing") if (! defined($ARGV[0]));
60 die("Invalid argument") if (! defined($Tests{$test}));
65 my $orig_file = "$data/$test.$Tests{$test}->{orig_ext}";
66 my $work_file = "$workdir/$test.$Tests{$test}->{orig_ext}";
67 my $expected = "$data/$test.tex.orig";
69 if (defined($Tests{$test}->{create})) {
70 for my $created (@{$Tests{$test}->{create}}) {
71 push(@created, "$workdir/$created");
74 my $created = $created[0];
76 if (defined($Tests{$test}->{docompare})) {
77 $docompare = $Tests{$test}->{docompare};
79 die("File \"$expected\" does not exist") if ($docompare && ! -e $expected);
80 # Create lyx-file to work with
81 copy($orig_file, $work_file) or die("Copy failed: $!");
82 print "Unlinking " . join(' ', @created) . "\n";
86 $ENV{LANGUAGE} = "en_US";
90 my @command = ($lyx_exe, "-userdir", $userdir);
91 if (defined($Tests{$test}->{command_line})) {
92 push(@command, @{$Tests{$test}->{command_line}});
94 if (defined($Tests{$test}->{commands})) {
95 push(@command, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
99 for my $f (@created) {
100 die("File \"$f\" not created") if (! -e "$f");
102 die("Expected ($expected) and created ($created) files differ") if ($docompare && compare($expected, $created) != 0);
106 sub check_precondition()
108 return if (! defined($Tests{$test}->{precondition}));
109 my $rPrecond = $Tests{$test}->{precondition};
110 my @command = @{$rPrecond->{command}};
111 if (defined($rPrecond->{workdir})) {
112 chdir($rPrecond->{workdir});
114 my $result = system1(@command);
115 print "Pre-condition result = $result\n";
116 die("Pre-condition error") if ($result != 0);
121 my ($exe, @params) = @_;
122 print "Executing:\n\t$exe '" . join("' '", @params) . "'\n";
123 system($exe, @params);