From: Steve Peters Date: Sat, 9 Feb 2008 07:29:21 +0000 (+0000) Subject: Upgrade to Test-Harness-3.08 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=41d86c6b932c287037db3584f7658c067cae5e84;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Test-Harness-3.08 p4raw-id: //depot/perl@33264 --- diff --git a/lib/App/Prove.pm b/lib/App/Prove.pm index f08b82d..275d52e 100644 --- a/lib/App/Prove.pm +++ b/lib/App/Prove.pm @@ -15,11 +15,11 @@ App::Prove - Implements the C command. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION @@ -54,7 +54,7 @@ BEGIN { harness includes modules plugins jobs lib merge parse quiet really_quiet recurse backwards shuffle taint_fail taint_warn timer verbose warnings_fail warnings_warn show_help show_man - show_version test_args state + show_version test_args state dry ); for my $attr (@ATTR) { no strict 'refs'; @@ -192,6 +192,7 @@ sub process_args { 'color!' => \$self->{color}, 'colour!' => \$self->{color}, 'c' => \$self->{color}, + 'D|dry' => \$self->{dry}, 'harness=s' => \$self->{harness}, 'formatter=s' => \$self->{formatter}, 'r|recurse' => \$self->{recurse}, @@ -394,28 +395,38 @@ sub run { elsif ( $self->show_version ) { $self->print_version; } + elsif ( $self->dry ) { + print "$_\n" for $self->_get_tests; + } else { $self->_load_extensions( $self->modules ); $self->_load_extensions( $self->plugins, PLUGINS ); - my $state = $self->{_state}; - if ( defined( my $state_switch = $self->state ) ) { - $state->apply_switch(@$state_switch); - } - - my @tests = $state->get_tests( $self->recurse, @{ $self->argv } ); - - $self->_shuffle(@tests) if $self->shuffle; - @tests = reverse @tests if $self->backwards; local $ENV{TEST_VERBOSE} = 1 if $self->verbose; - $self->_runtests( $self->_get_args, @tests ); + $self->_runtests( $self->_get_args, $self->_get_tests ); } return; } +sub _get_tests { + my $self = shift; + + my $state = $self->{_state}; + if ( defined( my $state_switch = $self->state ) ) { + $state->apply_switch(@$state_switch); + } + + my @tests = $state->get_tests( $self->recurse, @{ $self->argv } ); + + $self->_shuffle(@tests) if $self->shuffle; + @tests = reverse @tests if $self->backwards; + + return @tests; +} + sub _runtests { my ( $self, $args, $harness_class, @tests ) = @_; my $harness = $harness_class->new($args); @@ -552,6 +563,8 @@ calling C. =item C +=item C + =item C =item C diff --git a/lib/App/Prove/State.pm b/lib/App/Prove/State.pm index a82feb3..b689265 100644 --- a/lib/App/Prove/State.pm +++ b/lib/App/Prove/State.pm @@ -20,11 +20,11 @@ App::Prove::State - State storage for the C command. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Base.pm b/lib/TAP/Base.pm index 1364b9e..0aa7e95 100644 --- a/lib/TAP/Base.pm +++ b/lib/TAP/Base.pm @@ -9,11 +9,11 @@ TAP::Base - Base class that provides common functionality to L and =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; my $GOT_TIME_HIRES; diff --git a/lib/TAP/Formatter/Color.pm b/lib/TAP/Formatter/Color.pm index 410daf8..b38ea8f 100644 --- a/lib/TAP/Formatter/Color.pm +++ b/lib/TAP/Formatter/Color.pm @@ -70,11 +70,11 @@ TAP::Formatter::Color - Run Perl test scripts with color =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Formatter/Console.pm b/lib/TAP/Formatter/Console.pm index 08d9736..e5e9ce3 100644 --- a/lib/TAP/Formatter/Console.pm +++ b/lib/TAP/Formatter/Console.pm @@ -52,11 +52,11 @@ TAP::Formatter::Console - Harness output delegate for default console output =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Formatter/Console/ParallelSession.pm b/lib/TAP/Formatter/Console/ParallelSession.pm index 6d4f6d7..2bd9e91 100644 --- a/lib/TAP/Formatter/Console/ParallelSession.pm +++ b/lib/TAP/Formatter/Console/ParallelSession.pm @@ -48,11 +48,11 @@ TAP::Formatter::Console::ParallelSession - Harness output delegate for parallel =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Formatter/Console/Session.pm b/lib/TAP/Formatter/Console/Session.pm index 873f7ee..a4bc4bd 100644 --- a/lib/TAP/Formatter/Console/Session.pm +++ b/lib/TAP/Formatter/Console/Session.pm @@ -36,11 +36,11 @@ TAP::Formatter::Console::Session - Harness output delegate for default console o =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Harness.pm b/lib/TAP/Harness.pm index f024607..2aa3ad4 100644 --- a/lib/TAP/Harness.pm +++ b/lib/TAP/Harness.pm @@ -22,11 +22,11 @@ TAP::Harness - Run test scripts with statistics =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; $ENV{HARNESS_ACTIVE} = 1; $ENV{HARNESS_VERSION} = $VERSION; diff --git a/lib/TAP/Parser.pm b/lib/TAP/Parser.pm index 211bf21..a23151e 100644 --- a/lib/TAP/Parser.pm +++ b/lib/TAP/Parser.pm @@ -19,11 +19,11 @@ TAP::Parser - Parse L output =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; my $DEFAULT_TAP_VERSION = 12; my $MAX_TAP_VERSION = 13; diff --git a/lib/TAP/Parser/Aggregator.pm b/lib/TAP/Parser/Aggregator.pm index ed6846f..479c0af 100644 --- a/lib/TAP/Parser/Aggregator.pm +++ b/lib/TAP/Parser/Aggregator.pm @@ -10,11 +10,11 @@ TAP::Parser::Aggregator - Aggregate TAP::Parser results =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 SYNOPSIS diff --git a/lib/TAP/Parser/Grammar.pm b/lib/TAP/Parser/Grammar.pm index 1f5f2c3..8acfedd 100644 --- a/lib/TAP/Parser/Grammar.pm +++ b/lib/TAP/Parser/Grammar.pm @@ -12,11 +12,11 @@ TAP::Parser::Grammar - A grammar for the Test Anything Protocol. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Iterator.pm b/lib/TAP/Parser/Iterator.pm index 7842d9c..a3ca7ff 100644 --- a/lib/TAP/Parser/Iterator.pm +++ b/lib/TAP/Parser/Iterator.pm @@ -13,11 +13,11 @@ TAP::Parser::Iterator - Internal TAP::Parser Iterator =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 SYNOPSIS diff --git a/lib/TAP/Parser/Iterator/Array.pm b/lib/TAP/Parser/Iterator/Array.pm index 5979943..9d067ef 100644 --- a/lib/TAP/Parser/Iterator/Array.pm +++ b/lib/TAP/Parser/Iterator/Array.pm @@ -11,11 +11,11 @@ TAP::Parser::Iterator::Array - Internal TAP::Parser Iterator =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 SYNOPSIS diff --git a/lib/TAP/Parser/Iterator/Process.pm b/lib/TAP/Parser/Iterator/Process.pm index 985aaf1..664dc8a 100644 --- a/lib/TAP/Parser/Iterator/Process.pm +++ b/lib/TAP/Parser/Iterator/Process.pm @@ -19,11 +19,11 @@ TAP::Parser::Iterator::Process - Internal TAP::Parser Iterator =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 SYNOPSIS diff --git a/lib/TAP/Parser/Iterator/Stream.pm b/lib/TAP/Parser/Iterator/Stream.pm index 73ad147..14523e5 100644 --- a/lib/TAP/Parser/Iterator/Stream.pm +++ b/lib/TAP/Parser/Iterator/Stream.pm @@ -11,11 +11,11 @@ TAP::Parser::Iterator::Stream - Internal TAP::Parser Iterator =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 SYNOPSIS diff --git a/lib/TAP/Parser/Multiplexer.pm b/lib/TAP/Parser/Multiplexer.pm index e9ce60b..6d516c6 100644 --- a/lib/TAP/Parser/Multiplexer.pm +++ b/lib/TAP/Parser/Multiplexer.pm @@ -14,11 +14,11 @@ TAP::Parser::Multiplexer - Multiplex multiple TAP::Parsers =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 SYNOPSIS diff --git a/lib/TAP/Parser/Result.pm b/lib/TAP/Parser/Result.pm index fa5f0a5..9e81cc2 100644 --- a/lib/TAP/Parser/Result.pm +++ b/lib/TAP/Parser/Result.pm @@ -27,11 +27,11 @@ TAP::Parser::Result - TAP::Parser output =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head2 DESCRIPTION diff --git a/lib/TAP/Parser/Result/Bailout.pm b/lib/TAP/Parser/Result/Bailout.pm index d7ae9f1..2ac5450 100644 --- a/lib/TAP/Parser/Result/Bailout.pm +++ b/lib/TAP/Parser/Result/Bailout.pm @@ -12,11 +12,11 @@ TAP::Parser::Result::Bailout - Bailout result token. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Result/Comment.pm b/lib/TAP/Parser/Result/Comment.pm index 607daf7..8e7ddd5 100644 --- a/lib/TAP/Parser/Result/Comment.pm +++ b/lib/TAP/Parser/Result/Comment.pm @@ -12,11 +12,11 @@ TAP::Parser::Result::Comment - Comment result token. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Result/Plan.pm b/lib/TAP/Parser/Result/Plan.pm index ad7f315..3d8db50 100644 --- a/lib/TAP/Parser/Result/Plan.pm +++ b/lib/TAP/Parser/Result/Plan.pm @@ -12,11 +12,11 @@ TAP::Parser::Result::Plan - Plan result token. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Result/Test.pm b/lib/TAP/Parser/Result/Test.pm index e0cee7c..43a3d9a 100644 --- a/lib/TAP/Parser/Result/Test.pm +++ b/lib/TAP/Parser/Result/Test.pm @@ -14,11 +14,11 @@ TAP::Parser::Result::Test - Test result token. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Result/Unknown.pm b/lib/TAP/Parser/Result/Unknown.pm index 94ab7f8..7aac777 100644 --- a/lib/TAP/Parser/Result/Unknown.pm +++ b/lib/TAP/Parser/Result/Unknown.pm @@ -14,11 +14,11 @@ TAP::Parser::Result::Unknown - Unknown result token. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Result/Version.pm b/lib/TAP/Parser/Result/Version.pm index f192f8a..7805997 100644 --- a/lib/TAP/Parser/Result/Version.pm +++ b/lib/TAP/Parser/Result/Version.pm @@ -12,11 +12,11 @@ TAP::Parser::Result::Version - TAP version result token. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Result/YAML.pm b/lib/TAP/Parser/Result/YAML.pm index b3a1ce5..39602f7 100644 --- a/lib/TAP/Parser/Result/YAML.pm +++ b/lib/TAP/Parser/Result/YAML.pm @@ -12,11 +12,11 @@ TAP::Parser::Result::YAML - YAML result token. =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Source.pm b/lib/TAP/Parser/Source.pm index 517b00f..6fa2c79 100644 --- a/lib/TAP/Parser/Source.pm +++ b/lib/TAP/Parser/Source.pm @@ -14,11 +14,11 @@ TAP::Parser::Source - Stream output from some source =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/Source/Perl.pm b/lib/TAP/Parser/Source/Perl.pm index 4181550..2b55b6d 100644 --- a/lib/TAP/Parser/Source/Perl.pm +++ b/lib/TAP/Parser/Source/Perl.pm @@ -16,11 +16,11 @@ TAP::Parser::Source::Perl - Stream Perl output =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; =head1 DESCRIPTION diff --git a/lib/TAP/Parser/YAMLish/Reader.pm b/lib/TAP/Parser/YAMLish/Reader.pm index 2acc47f..d5ab5fc 100644 --- a/lib/TAP/Parser/YAMLish/Reader.pm +++ b/lib/TAP/Parser/YAMLish/Reader.pm @@ -4,7 +4,7 @@ use strict; use vars qw{$VERSION}; -$VERSION = '3.07'; +$VERSION = '3.08'; # TODO: # Handle blessed object syntax @@ -277,7 +277,7 @@ TAP::Parser::YAMLish::Reader - Read YAMLish data from iterator =head1 VERSION -Version 3.07 +Version 3.08 =head1 SYNOPSIS diff --git a/lib/TAP/Parser/YAMLish/Writer.pm b/lib/TAP/Parser/YAMLish/Writer.pm index 2d95b26..b71352a 100644 --- a/lib/TAP/Parser/YAMLish/Writer.pm +++ b/lib/TAP/Parser/YAMLish/Writer.pm @@ -4,9 +4,10 @@ use strict; use vars qw{$VERSION}; -$VERSION = '3.07'; +$VERSION = '3.08'; my $ESCAPE_CHAR = qr{ [ \x00-\x1f \" ] }x; +my $ESCAPE_KEY = qr{ (?: ^\W ) | $ESCAPE_CHAR }x; my @UNPRINTABLE = qw( z x01 x02 x03 x04 x05 x06 a @@ -71,10 +72,11 @@ sub _put { sub _enc_scalar { my $self = shift; my $val = shift; + my $rule = shift; return '~' unless defined $val; - if ( $val =~ /$ESCAPE_CHAR/ ) { + if ( $val =~ /$rule/ ) { $val =~ s/\\/\\\\/g; $val =~ s/"/\\"/g; $val =~ s/ ( [\x00-\x1f] ) / '\\' . $UNPRINTABLE[ ord($1) ] /gex; @@ -103,7 +105,7 @@ sub _write_obj { for my $key ( sort keys %$obj ) { my $value = $obj->{$key}; $self->_write_obj( - $pad . $self->_enc_scalar($key) . ':', + $pad . $self->_enc_scalar( $key, $ESCAPE_KEY ) . ':', $value, $indent + 1 ); } @@ -131,7 +133,7 @@ sub _write_obj { } } else { - $self->_put( $prefix, ' ', $self->_enc_scalar($obj) ); + $self->_put( $prefix, ' ', $self->_enc_scalar( $obj, $ESCAPE_CHAR ) ); } } @@ -147,7 +149,7 @@ TAP::Parser::YAMLish::Writer - Write YAMLish data =head1 VERSION -Version 3.07 +Version 3.08 =head1 SYNOPSIS diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm index 596883a..77814e4 100644 --- a/lib/Test/Harness.pm +++ b/lib/Test/Harness.pm @@ -41,11 +41,11 @@ Test::Harness - Run Perl standard test scripts with statistics =head1 VERSION -Version 3.07 +Version 3.08 =cut -$VERSION = '3.07'; +$VERSION = '3.08'; # Backwards compatibility for exportable variable names. *verbose = *Verbose; @@ -219,6 +219,7 @@ sub _canon { } sub _new_harness { + my $sub_args = shift || {}; if ( defined( my $env_sw = $ENV{HARNESS_PERL_SWITCHES} ) ) { $Switches .= ' ' . $env_sw if ( length($env_sw) ); @@ -251,6 +252,9 @@ sub _new_harness { verbosity => $verbosity, }; + $args->{stdout} = $sub_args->{out} + if exists $sub_args->{out}; + if ( defined( my $env_opt = $ENV{HARNESS_OPTIONS} ) ) { for my $opt ( split /:/, $env_opt ) { if ( $opt =~ /^j(\d*)$/ ) { @@ -336,9 +340,7 @@ sub _check_sequence { sub execute_tests { my %args = @_; - # TODO: Handle out option - - my $harness = _new_harness(); + my $harness = _new_harness( \%args ); my $aggregate = TAP::Parser::Aggregator->new(); my %tot = ( diff --git a/lib/Test/Harness/bin/prove b/lib/Test/Harness/bin/prove index 0888ac9..336229d 100644 --- a/lib/Test/Harness/bin/prove +++ b/lib/Test/Harness/bin/prove @@ -27,6 +27,7 @@ Boolean options: -s, --shuffle Run the tests in random order. -c, --color Colored test output (default). --nocolor Do not color test output. + -D --dry Dry run. Show test that would have run. -f, --failures Only show failed tests. --fork Fork to run harness in multiple processes -m, --merge Merge test scripts' STDERR with their STDOUT. diff --git a/lib/Test/Harness/t/yamlish-writer.t b/lib/Test/Harness/t/yamlish-writer.t index 207fd5e..f7a22c3 100644 --- a/lib/Test/Harness/t/yamlish-writer.t +++ b/lib/Test/Harness/t/yamlish-writer.t @@ -151,6 +151,14 @@ BEGIN { '...', ], }, + { name => 'Funky hash key', + in => { './frob' => 'is_frob' }, + out => [ + '---', + '"./frob": is_frob', + '...', + ] + }, { name => 'Complex', in => { 'bill-to' => { @@ -256,7 +264,7 @@ for my $test (@SCHEDULE) { my $yr = TAP::Parser::YAMLish::Reader->new; # Now try parsing it - my $reader = sub { shift @$got }; + my $reader = sub { shift @$got }; my $parsed = eval { $yr->read($reader) }; ok !$@, "$name: no error" or diag "$@";