Skip to content

Instantly share code, notes, and snippets.

@dagolden
Created February 5, 2014 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagolden/8826725 to your computer and use it in GitHub Desktop.
Save dagolden/8826725 to your computer and use it in GitHub Desktop.
diff --git a/lib/TAP/Harness.pm b/lib/TAP/Harness.pm
index 53d8d18..592b74b 100644
--- a/lib/TAP/Harness.pm
+++ b/lib/TAP/Harness.pm
@@ -415,6 +415,8 @@ Any keys for which the value is C<undef> will be ignored.
$self->jobs(1) unless defined $self->jobs;
+ $self->rules($self->_load_test_plan) unless defined $self->rules;
+
local $default_class{formatter_class} = 'TAP::Formatter::File'
unless -t ( $arg_for{stdout} || \*STDOUT ) && !$ENV{HARNESS_NOTTY};
@@ -445,6 +447,20 @@ Any keys for which the value is C<undef> will be ignored.
return $self;
}
+
+ sub _load_test_plan {
+ my ($plan_file) = grep { -r } qw(./.testplan.yml t/.testplan.yml);
+ if ( $plan_file ) {
+ require CPAN::Meta::YAML;
+ open my $fh, "<:utf8", $plan_file
+ or die "Couldn't open $plan_file: $!";
+ my $yaml_text = do { local $/; <$fh> };
+ my $yaml = CPAN::Meta::YAML->read_string($yaml_text)
+ or die CPAN::Meta::YAML->errstr;
+ return $yaml->[0];
+ }
+ return;
+ }
}
##############################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment