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