2016-12-03 10:32:19 +00:00
|
|
|
#! /usr/bin/env perl
|
|
|
|
# -*- mode: perl; -*-
|
|
|
|
|
|
|
|
use strict;
|
2017-05-22 06:56:42 +00:00
|
|
|
use warnings;
|
2016-12-03 10:32:19 +00:00
|
|
|
|
2017-05-22 06:56:42 +00:00
|
|
|
# Syntax: prefTest.pl [<var1>=<Subst1> [<var2>=<Subst> ...]] [[ctest parameters]]
|
2016-12-03 10:32:19 +00:00
|
|
|
|
|
|
|
my $bindir = "@CMAKE_BINARY_DIR@";
|
|
|
|
|
|
|
|
my $userdir = "$bindir/Testing/.lyx";
|
|
|
|
|
|
|
|
my %allowedKeys = (
|
|
|
|
"use_converter_needauth_forbidden" => ["true", "false"],
|
|
|
|
"use_converter_needauth" => ["true", "false"],
|
2017-06-01 07:19:29 +00:00
|
|
|
"allow_geometry_session" => ["false"],
|
2016-12-03 10:32:19 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
chdir($bindir);
|
|
|
|
|
|
|
|
# Parse Arguments for strings to substitute
|
|
|
|
|
|
|
|
my %Subst = ();
|
|
|
|
|
|
|
|
my $ctestparams = 0;
|
|
|
|
my @ctestpars = ();
|
2017-06-01 07:19:29 +00:00
|
|
|
for my $arg ("allow_geometry_session=false", @ARGV) {
|
2016-12-03 10:32:19 +00:00
|
|
|
if ($ctestparams) {
|
|
|
|
push(@ctestpars, $arg);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ($arg =~ /^([^=]+)=(.*)$/) {
|
|
|
|
my $key = $1;
|
|
|
|
my $value = $2;
|
|
|
|
my $valid = 0;
|
|
|
|
if (defined($allowedKeys{$key})) {
|
|
|
|
for my $val (@{$allowedKeys{$key}}) {
|
|
|
|
if ($val eq $value) {
|
|
|
|
$valid = 1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($valid) {
|
|
|
|
$Subst{$key} = [$value, 0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
die("invalid key or value specified in \"$arg\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$ctestparams = 1;
|
|
|
|
push(@ctestpars, $arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-24 15:50:49 +00:00
|
|
|
|
2016-12-03 10:32:19 +00:00
|
|
|
if (%Subst) { # Try to do something only if a substitute is requested
|
|
|
|
if (open(FO, '>', "$userdir/preferences.tmp")) {
|
|
|
|
if (open(FI, "$userdir/preferences")) {
|
|
|
|
while (my $l = <FI>) {
|
|
|
|
for my $k (keys %Subst) {
|
|
|
|
if ($l =~ /^\\$k\b/) {
|
|
|
|
$l = "\\$k $Subst{$k}->[0]\n";
|
|
|
|
$Subst{$k}->[1] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print FO $l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for my $k (keys %Subst) {
|
|
|
|
if ($Subst{$k}->[1] == 0) {
|
|
|
|
print FO "\\$k $Subst{$k}->[0]\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rename("$userdir/preferences.tmp", "$userdir/preferences");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $res = 0;
|
|
|
|
if (@ctestpars) {
|
|
|
|
$res = system("ctest", @ctestpars);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit($res);
|