]> git.lyx.org Git - lyx.git/blob - lib/scripts/prefTest.pl.in
Cmake export tests: Modularisation of prefTest.pl
[lyx.git] / lib / scripts / prefTest.pl.in
1 #! /usr/bin/env perl
2 # -*- mode: perl; -*-
3
4 use strict;
5 use warnings;
6
7 # Syntax: prefTest.pl [test|default] [<var1>=<Subst1> [<var2>=<Subst> ...]] [[ctest parameters]]
8 # If the first parameter is "test"
9 #       allow use of -shell-escape in converters and
10 #       allow use of external programs
11 # If the first parameter is "default"
12 #       remove "-shell-escape" from converters and
13 #       forbid use of external programs
14 # Else
15 #       allow use of -shell-escape in converters and
16 #       do not change handling the use of external programs
17 ############################################################
18
19 BEGIN  {
20   unshift(@INC, "@CMAKE_CURRENT_SOURCE_DIR@");
21 }
22
23 use prefTest;
24
25 my $bindir = "@CMAKE_BINARY_DIR@";
26
27 my $userdir = "$bindir/Testing/.lyx";
28
29 my %allowedKeys = (
30   "use_converter_needauth_forbidden" => ["true", "false"],
31   "use_converter_needauth" => ["true", "false"],
32   "allow_geometry_session" => ["false"],
33     );
34
35 my %Converter = ();
36
37 chdir($bindir);
38
39 # Parse Arguments for strings to substitute
40
41 my %Subst = ();
42
43 my @ctestpars = ();
44
45 my $shell_escapes = 1;
46 my $handle_argv = "";
47 if (defined($ARGV[0]) && ($ARGV[0] =~ /^(test|default)$/)) {
48   $handle_argv = $1;
49   shift(@ARGV);
50 }
51
52 if ($handle_argv eq "test") {
53   @ctestpars = &getSubstitutes(\%allowedKeys, \%Subst,
54                                "allow_geometry_session=false",
55                                "use_converter_needauth_forbidden=false",
56                                "use_converter_needauth=false", @ARGV);
57 }
58 elsif ($handle_argv eq "default") {
59   $shell_escapes = 0;
60   @ctestpars = &getSubstitutes(\%allowedKeys, \%Subst,
61                                "allow_geometry_session=false",
62                                "use_converter_needauth_forbidden=true",
63                                "use_converter_needauth=true", @ARGV);
64 }
65 else {
66   @ctestpars = &getSubstitutes(\%allowedKeys, \%Subst,
67                                "allow_geometry_session=false", @ARGV);
68 }
69
70 &getConverters($userdir, \%Converter, $shell_escapes);
71
72 &applyChanges($userdir, \%Subst, \%Converter, $shell_escapes);
73
74 my $res = 0;
75 if (@ctestpars) {
76   $res = system("ctest", @ctestpars);
77 }
78
79 exit($res);
80