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:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:30:08 +0000
commit44cf9c6d2d274eac37502e835155f7e985f1b8e6 (patch)
tree9576ba968924c5b9a55ba9e14f4f26184c62c7d4 /scripts/t/Dpkg_Substvars.t
parentAdding upstream version 1.22.6. (diff)
downloaddpkg-44cf9c6d2d274eac37502e835155f7e985f1b8e6.tar.xz
dpkg-44cf9c6d2d274eac37502e835155f7e985f1b8e6.zip
Adding upstream version 1.22.7.upstream/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;