]> git.lyx.org Git - lyx.git/blob - lib/scripts/lyx_batch.pl.in
Cmake tests: New test for the outliner with beamer
[lyx.git] / lib / scripts / lyx_batch.pl.in
1 #! /usr/bin/env perl
2 # -*- mode: perl; -*-
3
4 # lyx_batch.pl testname
5
6 use strict;
7 use warnings;
8 use File::Copy;
9 use File::Compare;
10
11 my $builddir = "@CMAKE_BINARY_DIR@";
12 my $userdir = "$builddir/Testing/.lyx";
13 my $workdir = "$builddir/autotests/out-home";
14
15 my $vsuffix = "@PROGRAM_SUFFIX@";
16 my $lyx_exe = "$builddir/bin/lyx$vsuffix";
17
18 my $lyxsource = "@LYX_ABS_TOP_SRCDIR@";
19 my $data = "$lyxsource/development/batchtests";
20
21 my %Tests = (
22   beamer_test => {
23     create => "beamer_test.tex",
24     commands => ["file-open beamer_test.lyx",
25                  "buffer-begin",
26                  "repeat 150 outline-down",
27                  "repeat 150 outline-up",
28                  "buffer-export pdflatex",
29                  "repeat 150 outline-down",
30                  "buffer-reload dump",
31                  "lyx-quit"]
32   }
33     );
34
35 exit(1) if (! defined($ARGV[0]));
36 my $test = $ARGV[0];
37 exit(2) if (! defined($Tests{$test}));
38
39 my $orig_lyx = "$data/$test.lyx";
40 my $work_lyx = "$workdir/$test.lyx";
41 my $expected = "$data/$test.tex.orig";
42 my $created = "$workdir/$Tests{$test}->{create}";
43
44 die("File \"$expected\" does not exist") if (! -e $expected);
45 # Create lyx-file to work with
46 copy($orig_lyx, $work_lyx) or die("Copy failed: $!");
47 unlink($created);
48 $ENV{LANG} = "en";
49 $ENV{LC_ALL} = "C";
50 $ENV{LANGUAGE} = "en_US";
51
52 chdir($workdir);
53 system($lyx_exe, "-userdir", $userdir, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
54 die("Expected and created files differ") if (compare($expected, $created) != 0);
55
56 exit(0);
57