Skip to content

Commit

Permalink
Add verbose option to harness
Browse files Browse the repository at this point in the history
  • Loading branch information
Leont committed May 24, 2017
1 parent 292b8f8 commit 53db2fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bin/prove6
Expand Up @@ -19,7 +19,7 @@ sub load(Str $classname) {

multi sub MAIN(
Bool :l($lib), Bool :b($blib), Bool :$timer = False, Int :j($jobs) = 1,
Bool :$ignore-exit = False, Bool :$trap = False,
Bool :$ignore-exit = False, Bool :$trap = False, Bool :v($verbose),
Bool :$shuffle = False, Str :$err = 'stderr', Bool :$reverse = False,
Str :e($exec), Str :$harness, Str :$reporter, Str :I($incdir),
*@files) {
Expand All @@ -41,6 +41,7 @@ multi sub MAIN(
with $reporter {
%more<reporter-class> = load($reporter);
}
%more<volume> = TAP::Verbose if $verbose;
my @sources = @files.map(*.IO).flatmap(&listall);
@sources = $shuffle ?? @sources.pick(*) !! @sources.sort;
@sources = @sources.reverse if $reverse;
Expand Down
22 changes: 19 additions & 3 deletions lib/TAP.pm
Expand Up @@ -68,6 +68,21 @@ role Entry::Handler {
method end-entries() { }
}

class Output does Entry::Handler {
has IO::Handle $.handle = $*OUT;
method handle-entry(Entry $entry) {
$!handle.say(~$entry);
}
method end-entries() {
$!handle.flush;
}
method open(Str $filename) {
my $handle = open $filename, :w;
$handle.autoflush(True);
return Output.new(:$handle);
}
}

class Collector does Entry::Handler {
has @.entries;
submethod BUILD() { }
Expand Down Expand Up @@ -948,7 +963,8 @@ class Harness {

has SourceHandler @.handlers = SourceHandler::Perl6.new();
has IO::Handle $.output = $*OUT;
has TAP::Reporter:U $.reporter-class = $!output.t ?? TAP::Reporter::Console !! TAP::Reporter::Text;
has Formatter::Volume $.volume = Normal;
has TAP::Reporter:U $.reporter-class = ($!output.t && $!volume < Verbose) ?? TAP::Reporter::Console !! TAP::Reporter::Text;
has Int:D $.jobs = 1;
has Bool:D $.timer = False;
subset ErrValue where any(IO::Handle:D, Supply, 'stderr', 'ignore', 'merge');
Expand All @@ -970,7 +986,7 @@ class Harness {
TAP::Aggregator.new(:$!ignore-exit);
}
method make-handlers(Str $name) {
();
$.volume == Verbose ?? TAP::Output.new(:handle($.output)) !! ()
}
method make-source(Str $name) {
@!handlers.max(*.can-handle($name)).make-source($name, :$!err);
Expand All @@ -980,7 +996,7 @@ class Harness {
method run(*@sources) {
my $killed = Promise.new;
my $aggregator = self.make-aggregator;
my $reporter = $!reporter-class.new(:names(@sources), :$!timer, :$!ignore-exit);
my $reporter = $!reporter-class.new(:names(@sources), :$!timer, :$!ignore-exit, :$!volume);

if $!jobs > 1 {
my @working;
Expand Down

0 comments on commit 53db2fe

Please sign in to comment.