3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 use Test
::More tests
=> 4;
27 my $srcdir = $ENV{srcdir
} || '.';
28 my $datadir = "$srcdir/t/dpkg_mergechangelogs";
31 my ($expected_file, @options) = @_;
32 my $fh = File
::Temp
->new();
33 spawn
(exec => [ $ENV{PERL
}, "$srcdir/dpkg-mergechangelogs.pl", @options ],
34 to_handle
=> $fh, error_to_file
=> '/dev/null',
35 wait_child
=> 1, nocheck
=> 1);
36 my $res = compare
($expected_file, $fh->filename);
38 system('diff', '-u', $expected_file, $fh->filename);
40 ok
($res == 0, "merged changelog matches expected one ($expected_file)");
43 my $has_alg_merge = 1;
44 eval 'use Algorithm::Merge;';
49 my @input = ("$datadir/ch-old", "$datadir/ch-a", "$datadir/ch-b");
51 test_merge
("$datadir/ch-merged", @input);
52 test_merge
("$datadir/ch-merged-pr", '-m', @input);
53 test_merge
("$datadir/ch-unreleased-merged", '--merge-unreleased',
54 ("$datadir/ch-unreleased-old",
55 "$datadir/ch-unreleased-a",
56 "$datadir/ch-unreleased-b"));
58 test_merge
("$datadir/ch-merged-basic", @input);
59 test_merge
("$datadir/ch-merged-pr-basic", '-m', @input);
60 test_merge
("$datadir/ch-unreleased-merged-basic", '--merge-unreleased',
61 ("$datadir/ch-unreleased-old",
62 "$datadir/ch-unreleased-a",
63 "$datadir/ch-unreleased-b"));
65 test_merge
("$datadir/ch-badver-merged", ("$datadir/ch-badver-old",
66 "$datadir/ch-badver-a", "$datadir/ch-badver-b"));