From 3c05da1bdef2a6e2142b4fcac974e7e3fc0db93c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 7 Aug 2024 15:30:09 +0200 Subject: Merging upstream version 1.22.7. Signed-off-by: Daniel Baumann --- scripts/t/Dpkg_Substvars.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'scripts/t/Dpkg_Substvars.t') 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; -- cgit v1.2.3