summaryrefslogtreecommitdiff
path: root/scripts/t/Dpkg_Substvars.t
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/t/Dpkg_Substvars.t')
-rw-r--r--scripts/t/Dpkg_Substvars.t25
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/t/Dpkg_Substvars.t b/scripts/t/Dpkg_Substvars.t
index ded25ddc8..35ffd0ca5 100644
--- a/scripts/t/Dpkg_Substvars.t
+++ b/scripts/t/Dpkg_Substvars.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 37;
+use Test::More tests => 47;
use Test::Dpkg qw(:paths);
use Dpkg ();
@@ -24,7 +24,7 @@ use Dpkg::Arch qw(get_host_arch);
use_ok('Dpkg::Substvars');
-my $datadir = test_get_data_path('t/Dpkg_Substvars');
+my $datadir = test_get_data_path();
my $expected;
@@ -82,6 +82,23 @@ is($s->get('binary:Version'), '1:2.3.4~5-6.7.8~nmu9+b0', 'binary:Version');
is($s->get('source:Version'), '1:2.3.4~5-6.7.8~nmu9', 'source:Version');
is($s->get('source:Upstream-Version'), '1:2.3.4~5', 'source:Upstream-Version');
+is($s->get($_), undef, 'no ' . $_) foreach qw(source:Synopsis source:Extended-Description);
+$s->set_desc_substvars("short synopsis\nthis is the long\nextended text\n");
+is($s->get('source:Synopsis'), 'short synopsis', 'contents of source:Synopsis');
+is($s->get('source:Extended-Description'), "this is the long\nextended text\n",
+ 'contents of source:Extended-Description');
+
+my %ctrl_fields = (
+ 'Some-Field' => 'some-value',
+ 'Other-Field' => 'other-value',
+ 'Alter-Field' => 'alter-value',
+);
+is($s->get($_), undef, 'no ' . $_) foreach sort keys %ctrl_fields;
+$s->set_field_substvars(\%ctrl_fields, 'ctrl');
+is($s->get('ctrl:Some-Field'), 'some-value', 'contents of ctrl:Some-Field');
+is($s->get('ctrl:Other-Field'), 'other-value', 'contents of ctrl:Other-Field');
+is($s->get('ctrl:Alter-Field'), 'alter-value', 'contents of ctrl:Alter-Field');
+
# Replace stuff
is($s->substvars('This is a string ${var1} with variables ${binary:Version}'),
'This is a string New value with variables 1:2.3.4~5-6.7.8~nmu9+b0',
@@ -97,7 +114,7 @@ is($s->substvars('This is a string with unknown variable ${blubb}'),
'substvars missing');
delete $SIG{__WARN__};
is($output,
- 'Dpkg_Substvars.t: warning: test unknown substitution variable ${blubb}' . "\n",
+ 'Dpkg_Substvars.t: warning: test substitution variable ${blubb} used, but is not defined' . "\n",
'missing variables warning');
# Recursive replace
@@ -117,7 +134,7 @@ $SIG{__WARN__} = sub { $output .= $_[0] };
$s->warn_about_unused();
delete $SIG{__WARN__};
is($output,
- 'Dpkg_Substvars.t: warning: test unused substitution variable ${var2}' . "\n",
+ 'Dpkg_Substvars.t: warning: test substitution variable ${var2} unused, but is defined' . "\n",
'unused variables warnings');
# Disable warnings for a certain variable