build: Workaround Tap::Harness verbose misbehavior on parallel mode
[dpkg.git] / build-aux / test-runner
blobd73369b27cccb15273841e559e505976121b2b68
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use TAP::Harness;
8 my $srcroot = $ENV{abs_top_srcdir};
9 my $binroot = $ENV{abs_top_builddir};
11 # Setup the environment
12 $ENV{LC_ALL} = 'C';
13 $ENV{DPKG_COLORS} = 'never';
14 $ENV{PATH} = "$binroot/src:$binroot/scripts:$binroot/utils:$ENV{PATH}";
16 my %options;
17 # XXX: We need force the file formatter to workaround verbose + parallel
18 # not working correctly, as the console formatter eats the test output,
19 # see <https://github.com/Perl-Toolchain-Gang/Test-Harness/issues/105>.
20 if ($ENV{TEST_VERBOSE} && $ENV{TEST_PARALLEL} > 1) {
21 $options{formatter_class} = 'TAP::Formatter::File';
24 my $harness = TAP::Harness->new({
25 exec => sub {
26 my (undef, $test) = @_;
27 return [ $test ] if $test !~ m/\.t$/ and -x $test;
28 return
30 lib => [
31 "$srcroot/scripts",
32 "$srcroot/dselect/methods"
34 color => 1,
35 verbosity => $ENV{TEST_VERBOSE},
36 jobs => $ENV{TEST_PARALLEL},
37 failures => 1,
38 %options,
39 });
41 my $aggregate = $harness->runtests(@ARGV);
42 die "FAIL: test suite has errors\n" if $aggregate->has_errors;