Commit | Line | Data |
f207111d |
1 | package TAP::Harness::IgnoreNonessentialDzilAutogeneratedTests; |
2 | |
3 | use warnings; |
4 | use strict; |
5 | |
6 | use base 'TAP::Harness'; |
1e735709 |
7 | use File::Spec (); |
8 | use IPC::Open3 'open3'; |
9 | use File::Temp (); |
f207111d |
10 | |
11 | my $frivolous_test_map = { |
12 | # Test based on the extremely dep-heavy, *prone to failures* Test::CheckDeps |
13 | # |
14 | 't/00-check-deps.t' => [ |
15 | qr|^\Q# this test was generated with Dist::Zilla::Plugin::Test::CheckDeps|m, |
16 | |
17 | # older non-annotated versions |
18 | qr|use \s+ Test::CheckDeps .*? ^\Qcheck_dependencies('suggests')\E .*? \QBAIL_OUT("Missing dependencies") if !Test::More->builder->is_passing|smx, |
19 | ], |
20 | |
21 | # "does everything compile" tests are useless by definition - this is what the |
22 | # rest of the test suite is for |
23 | # |
24 | 't/00-compile.t' => [ |
25 | qr|^\Q# this test was generated with Dist::Zilla::Plugin::Test::Compile|m, |
26 | ], |
27 | }; |
28 | |
29 | sub aggregate_tests { |
30 | my ($self, $aggregate, @all_tests) = @_; |
31 | |
32 | my ($run_tests, $skip_tests); |
33 | |
34 | TESTFILE: |
35 | for (@all_tests) { |
36 | my $fn = File::Spec::Unix->catpath( File::Spec->splitpath( $_ ) ); |
37 | |
38 | if (my $REs = $frivolous_test_map->{$fn}) { |
39 | my $slurptest = do { local (@ARGV, $/) = $fn; <> }; |
40 | $slurptest =~ $_ and push @$skip_tests, $fn and next TESTFILE for @$REs; |
41 | } |
42 | |
43 | push @$run_tests, $fn; |
44 | } |
45 | |
46 | if ($skip_tests) { |
47 | |
1e735709 |
48 | for my $tfn (@$skip_tests) { |
f207111d |
49 | |
1e735709 |
50 | (my $tfn_flattened = $tfn) =~ s|/|_|g; |
51 | |
52 | my $log_file = File::Temp->new( |
53 | DIR => '/tmp', |
54 | TEMPLATE => "AutoGenTest_${tfn_flattened}_XXXXX", |
55 | SUFFIX => '.txt', |
56 | ); |
57 | |
58 | # FIXME I have no idea why the fileno dance is necessary - will investigate later |
59 | # All I know is that if I pass in just $log_file - open3 ignores it >:( |
60 | my $pid = open3(undef, '>&'.fileno($log_file), undef, $^X, qw(-I blib -I arch/lib), $tfn ); |
f207111d |
61 | waitpid ($pid, 0); |
1e735709 |
62 | my $ex = $?; |
63 | |
64 | if ($ex) { |
65 | # use qx as opposed to another open3 until I figure out the above |
66 | close $log_file or die "Unable to close $log_file: $!"; |
67 | chomp( my $url = `/usr/bin/nopaste -q -s Shadowcat -d $log_file < $log_file` ); |
f207111d |
68 | |
1e735709 |
69 | $tfn .= "[would NOT have passed: $ex / $url]"; |
70 | } |
f207111d |
71 | } |
72 | |
73 | print STDERR "=== Skipping nonessential autogenerated tests: @$skip_tests\n"; |
74 | } |
75 | |
76 | return $self->SUPER::aggregate_tests($aggregate, @$run_tests); |
77 | } |
78 | |
79 | 1; |