summaryrefslogtreecommitdiffstats
path: root/scripts/t/Dpkg_Substvars.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:30:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:30:09 +0000
commit3c05da1bdef2a6e2142b4fcac974e7e3fc0db93c (patch)
tree9532e637f47d6ff7246ccbabb62d4e2b4b5908df /scripts/t/Dpkg_Substvars.t
parentAdding debian version 1.22.6. (diff)
downloaddpkg-3c05da1bdef2a6e2142b4fcac974e7e3fc0db93c.tar.xz
dpkg-3c05da1bdef2a6e2142b4fcac974e7e3fc0db93c.zip
Merging upstream version 1.22.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/t/Dpkg_Substvars.t')
-rw-r--r--scripts/t/Dpkg_Substvars.t28
1 files changed, 27 insertions, 1 deletions
diff --git a/scripts/t/Dpkg_Substvars.t b/scripts/t/Dpkg_Substvars.t
index 61ac027..b1c5b1b 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 => 56;
+use Test::More tests => 60;
use Test::Dpkg qw(:paths);
use Dpkg ();
@@ -247,6 +247,32 @@ is($output, '', 'disabled unused variables warnings');
$s->delete('var_used');
+# Required variables
+my $sr;
+
+$expected = <<'VARS';
+required-var!=Required value
+VARS
+$sr = Dpkg::Substvars->new("$datadir/substvars-req");
+is($sr->output(), $expected, 'Required variable preserved');
+
+is($sr->substvars('This is a string with missing the required variable'),
+ 'This is a string with missing the required variable',
+ 'substvars required substitution missing');
+
+eval {
+ $sr->warn_about_unused();
+ 1;
+};
+$output = $@ // q{};
+is($output,
+ 'Dpkg_Substvars.t: error: required substitution variable ${required-var} not used' . "\n",
+ 'substvars required substitution not used');
+
+is($sr->substvars('This is a string with a required variable ${required-var}'),
+ 'This is a string with a required variable Required value',
+ 'substvars required substitution present');
+
# Variable filters
my $sf;