Engage nuclear option of travis testing
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / lib / TAP / Harness / IgnoreNonessentialDzilAutogeneratedTests.pm
1 package TAP::Harness::IgnoreNonessentialDzilAutogeneratedTests;
2
3 use warnings;
4 use strict;
5
6 use base 'TAP::Harness';
7 use File::Spec;
8 use IPC::Open2 'open2';
9
10 my $frivolous_test_map = {
11 # Test based on the extremely dep-heavy, *prone to failures* Test::CheckDeps
12 #
13   't/00-check-deps.t' => [
14     qr|^\Q# this test was generated with Dist::Zilla::Plugin::Test::CheckDeps|m,
15
16     # older non-annotated versions
17     qr|use \s+ Test::CheckDeps .*? ^\Qcheck_dependencies('suggests')\E .*? \QBAIL_OUT("Missing dependencies") if !Test::More->builder->is_passing|smx,
18   ],
19
20 # "does everything compile" tests are useless by definition - this is what the
21 # rest of the test suite is for
22 #
23   't/00-compile.t' => [
24     qr|^\Q# this test was generated with Dist::Zilla::Plugin::Test::Compile|m,
25   ],
26 };
27
28 sub aggregate_tests {
29   my ($self, $aggregate, @all_tests) = @_;
30
31   my ($run_tests, $skip_tests);
32
33   TESTFILE:
34   for (@all_tests) {
35     my $fn = File::Spec::Unix->catpath( File::Spec->splitpath( $_ ) );
36
37     if (my $REs = $frivolous_test_map->{$fn}) {
38       my $slurptest = do { local (@ARGV, $/) = $fn; <> };
39       $slurptest =~ $_ and push @$skip_tests, $fn and next TESTFILE for @$REs;
40     }
41
42     push @$run_tests, $fn;
43   }
44
45   if ($skip_tests) {
46
47     for (@$skip_tests) {
48
49       my $pid = open2(File::Spec->devnull, undef, $^X, qw(-I blib -I arch/lib), $_ )
50         or die "Sub-proc failed: $!";
51       waitpid ($pid, 0);
52
53       $_ .= "[would NOT have passed: $?]" if $?;
54     }
55
56     print STDERR "=== Skipping nonessential autogenerated tests: @$skip_tests\n";
57   }
58
59   return $self->SUPER::aggregate_tests($aggregate, @$run_tests);
60 }
61
62 1;