diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:35:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:35:28 +0000 |
commit | ea314d2f45c40a006c0104157013ab4b857f665f (patch) | |
tree | 3ef2971cb3675c318b8d9effd987854ad3f6d3e8 /scripts/t/dpkg_mergechangelogs.t | |
parent | Initial commit. (diff) | |
download | dpkg-ea314d2f45c40a006c0104157013ab4b857f665f.tar.xz dpkg-ea314d2f45c40a006c0104157013ab4b857f665f.zip |
Adding upstream version 1.22.4.upstream/1.22.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/t/dpkg_mergechangelogs.t')
-rw-r--r-- | scripts/t/dpkg_mergechangelogs.t | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/t/dpkg_mergechangelogs.t b/scripts/t/dpkg_mergechangelogs.t new file mode 100644 index 0000000..646cd2f --- /dev/null +++ b/scripts/t/dpkg_mergechangelogs.t @@ -0,0 +1,66 @@ +#!/usr/bin/perl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +use strict; +use warnings; + +use Test::More tests => 4; + +use File::Spec; +use File::Compare; +use File::Temp; + +use Dpkg::IPC; + +my $srcdir = $ENV{srcdir} || '.'; +my $datadir = "$srcdir/t/dpkg_mergechangelogs"; + +sub test_merge { + my ($expected_file, @options) = @_; + my $fh = File::Temp->new(); + spawn(exec => [ $ENV{PERL}, "$srcdir/dpkg-mergechangelogs.pl", @options ], + to_handle => $fh, error_to_file => '/dev/null', + wait_child => 1, nocheck => 1); + my $res = compare($expected_file, $fh->filename); + if ($res) { + system('diff', '-u', $expected_file, $fh->filename); + } + ok($res == 0, "merged changelog matches expected one ($expected_file)"); +} + +my $has_alg_merge = 1; +eval 'use Algorithm::Merge;'; +if ($@) { + $has_alg_merge = 0; +} + +my @input = ("$datadir/ch-old", "$datadir/ch-a", "$datadir/ch-b"); +if ($has_alg_merge) { + test_merge("$datadir/ch-merged", @input); + test_merge("$datadir/ch-merged-pr", '-m', @input); + test_merge("$datadir/ch-unreleased-merged", '--merge-unreleased', + ("$datadir/ch-unreleased-old", + "$datadir/ch-unreleased-a", + "$datadir/ch-unreleased-b")); +} else { + test_merge("$datadir/ch-merged-basic", @input); + test_merge("$datadir/ch-merged-pr-basic", '-m', @input); + test_merge("$datadir/ch-unreleased-merged-basic", '--merge-unreleased', + ("$datadir/ch-unreleased-old", + "$datadir/ch-unreleased-a", + "$datadir/ch-unreleased-b")); +} +test_merge("$datadir/ch-badver-merged", ("$datadir/ch-badver-old", + "$datadir/ch-badver-a", "$datadir/ch-badver-b")); |