6 # Syntax: ReplaceValuesprefTest.pl [<var1>=<Subst1> [<var2>=<Subst> ...]] [[ctest parameters]]
8 my $bindir = "@CMAKE_BINARY_DIR@";
10 my $userdir = "$bindir/Testing/.lyx";
13 "use_converter_needauth_forbidden" => ["true", "false"],
14 "use_converter_needauth" => ["true", "false"],
17 # Bindings used by some tests
18 # used file is "$userdir/bind/user.bind"
20 # Empty for now, example below
21 # "A-h" => ["dialog-hide", "findreplaceadv"],
26 # Parse Arguments for strings to substitute
34 push(@ctestpars, $arg);
37 if ($arg =~ /^([^=]+)=(.*)$/) {
41 if (defined($allowedKeys{$key})) {
42 for my $val (@{$allowedKeys{$key}}) {
50 $Subst{$key} = [$value, 0];
53 die("invalid key or value specified in \"$arg\"");
58 push(@ctestpars, $arg);
63 if (%Subst) { # Try to do something only if a substitute is requested
64 if (open(FO, '>', "$userdir/preferences.tmp")) {
65 if (open(FI, "$userdir/preferences")) {
66 while (my $l = <FI>) {
67 for my $k (keys %Subst) {
68 if ($l =~ /^\\$k\b/) {
69 $l = "\\$k $Subst{$k}->[0]\n";
76 for my $k (keys %Subst) {
77 if ($Subst{$k}->[1] == 0) {
78 print FO "\\$k $Subst{$k}->[0]\n";
81 rename("$userdir/preferences.tmp", "$userdir/preferences");
85 if (open(FO, '>', "$userdir/userbind.tmp")) {
87 if (open(FI, "$userdir/bind/user.bind")) {
88 while (my $l = <FI>) {
90 for my $k (keys %bindings) {
91 if ($l =~ /^\s*\\bind\s+\"$k\"/) {
93 if (! defined($used{$k})) {
95 $l = "\\bind \"$k\" \"" . join(' ', @{$bindings{$k}}) . "\"\n";
100 print FO $l if (! $found);
106 print FO "## This file is automatically generated by lyx\n";
107 print FO "## All modifications will be lost\n";
109 print FO "Format 4\n\n";
111 for my $k (keys %bindings) {
112 if (! defined($used{$k})) {
114 my $l = "\\bind \"$k\" \"" . join(' ', @{$bindings{$k}}) . "\"\n";
119 rename("$userdir/userbind.tmp", "$userdir/bind/user.bind");
124 $res = system("ctest", @ctestpars);