blob: 656e15f65814f02ef0193abe009fb541feafad3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
use strict;
use warnings;
use lib '.';
use Test::More;
use installer::scpzipfiles;
my $vars = { foo => "bar" };
my %lines;
my $i = 0;
while (<DATA>) {
push @{ $lines{$i++ % 3} }, $_;
}
my @file1 = @{ $lines{0} };
my @file2 = @{ $lines{0} };
# FIXME - Some of the files acted on by these methods contain variables
# of the form "${foo}" which are currently ignored - but if "foo" was ever
# added to the product list variables, they would suddenly start to be
# replaced.
#
# We ought to come up with a better escaping mechanism, and change those
# files to use it...
installer::scpzipfiles::replace_all_ziplistvariables_in_file(\@file1, $vars);
installer::scpzipfiles::replace_all_ziplistvariables_in_rtffile(\@file2, $vars);
is_deeply(\@file1, $lines{1}, 'replace_all_ziplistvariables_in_file works');
is_deeply(\@file2, $lines{2}, 'replace_all_ziplistvariables_in_rtffile works');
done_testing();
__DATA__
This is a test
This is a test
This is a test
A test of ${foo} replacement ${foo} but not ${bar}.
A test of bar replacement bar but not ${bar}.
A test of ${foo} replacement ${foo} but not ${bar}.
A test of RTF $\{foo\} replacement $\{foo\} but not $\{bar\} or ${bar}.
A test of RTF $\{foo\} replacement $\{foo\} but not $\{bar\} or ${bar}.
A test of RTF bar replacement bar but not $\{bar\} or ${bar}.
|