3 # Copyright © 2016 Guillem Jover <guillem@debian.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
24 use File
::Path
qw(make_path remove_tree
);
25 use File
::Temp
qw(tempdir
);
31 my $srcdir = $ENV{srcdir
} || '.';
32 my $builddir = $ENV{builddir
} || '.';
33 my $tmpdir = 't.tmp/t-trigdeferred';
42 /root/pathname/file-trigger pkg-a pkg-b pkg-c
43 named-trigger pkg-1 pkg-2 pkg-3
44 parse-trigger pkg:a pkg+b pkg.0 0-pkg
48 <T='/root/pathname/file-trigger' P='pkg-a' P='pkg-b' P='pkg-c' E>
49 <T='named-trigger' P='pkg-1' P='pkg-2' P='pkg-3' E>
50 <T='parse-trigger' P='pkg:a' P='pkg+b' P='pkg.0' P='0-pkg' E>
51 <T=':other-trigger' P='-' E>
56 \b # invalid character
80 original
=> 'missing newline',
84 plan tests
=> scalar(@deferred) * 3;
90 my ($pathname, $text) = @_;
92 open my $fh, '>', $pathname or die "cannot touch $pathname: $!";
97 sub test_trigdeferred
{
100 my $admindir = "$tmpdir";
102 # Check triggers deferred file parsing.
103 make_path
("$admindir/triggers");
105 foreach my $test (@deferred) {
106 make_file
("$admindir/triggers/Unincorp", $test->{original
});
108 spawn
(exec => [ './c-trigdeferred', $admindir ],
109 nocheck
=> 1, to_string
=> \
$stdout, error_to_string
=> \
$stderr);
110 my $exitcode = $?
>> 8;
112 is
($exitcode, $test->{exitcode
}, 'trigger deferred expected exitcode');
113 if ($test->{exitcode
} == 0) {
114 is
($stderr, '', 'trigger deferred expected stderr');
115 is
($stdout, $test->{expected
}, 'trigger deferred expected stdout');
117 isnt
($stderr, '', 'trigger deferred expected stderr');
118 isnt
($stdout, undef, 'trigger deferred expected stdout');