Hello community, here is the log from the commit of package perl-Test-Spec for openSUSE:Factory checked in at 2018-07-28 12:41:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Test-Spec (Old) and /work/SRC/openSUSE:Factory/.perl-Test-Spec.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Test-Spec" Sat Jul 28 12:41:09 2018 rev:15 rq:624419 version:0.54 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Test-Spec/perl-Test-Spec.changes 2017-09-12 19:57:41.107755719 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Test-Spec.new/perl-Test-Spec.changes 2018-07-28 12:41:10.204514301 +0200 @@ -1,0 +2,20 @@ +Mon Mar 5 07:04:07 UTC 2018 - [email protected] + +- updated to 0.54 + see /usr/share/doc/packages/perl-Test-Spec/Changes + + 0.54 Tue Nov 21 12:46:00 MSK 2017 + - `around` method added to allow localized variables and other local setup. + Call `yield` method to run examples by `around` CODE. + Contributed by @akzhan + + - Replace some `use base` with `use parent` and other minor updates. + Contributed by @akzhan + + - Now tested under Perl 5.22-5.26 too + Contributed by @akzhan + + - predictable_destroy spec fixed under Perl 5.8 + Contributed by @akzhan + +------------------------------------------------------------------- Old: ---- Test-Spec-0.53.tar.gz New: ---- Test-Spec-0.54.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Test-Spec.spec ++++++ --- /var/tmp/diff_new_pack.JqKJE9/_old 2018-07-28 12:41:10.768515384 +0200 +++ /var/tmp/diff_new_pack.JqKJE9/_new 2018-07-28 12:41:10.772515393 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Test-Spec # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,25 +17,27 @@ Name: perl-Test-Spec -Version: 0.53 +Version: 0.54 Release: 0 %define cpan_name Test-Spec Summary: Write tests in a declarative specification style -License: Artistic-1.0 or GPL-1.0+ +License: Artistic-1.0 OR GPL-1.0-or-later Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Test-Spec/ -Source0: https://cpan.metacpan.org/authors/id/A/AN/ANDYJONES/%{cpan_name}-%{version}.tar.gz +Source0: https://cpan.metacpan.org/authors/id/A/AK/AKZHAN/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros +BuildRequires: perl(Devel::GlobalPhase) BuildRequires: perl(Package::Stash) >= 0.23 BuildRequires: perl(TAP::Parser) BuildRequires: perl(Test::Deep) >= 0.103 BuildRequires: perl(Test::More) >= 0.88 BuildRequires: perl(Test::Trap) BuildRequires: perl(Tie::IxHash) +Requires: perl(Devel::GlobalPhase) Requires: perl(Package::Stash) >= 0.23 Requires: perl(TAP::Parser) Requires: perl(Test::Deep) >= 0.103 ++++++ Test-Spec-0.53.tar.gz -> Test-Spec-0.54.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/.travis.yml new/Test-Spec-0.54/.travis.yml --- old/Test-Spec-0.53/.travis.yml 2017-08-15 11:40:37.000000000 +0200 +++ new/Test-Spec-0.54/.travis.yml 2017-11-21 10:41:18.000000000 +0100 @@ -1,6 +1,9 @@ language: perl perl: + - "5.26" + - "5.24" + - "5.22" - "5.20" - "5.18" - "5.16" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/Changes new/Test-Spec-0.54/Changes --- old/Test-Spec-0.53/Changes 2017-08-16 10:50:05.000000000 +0200 +++ new/Test-Spec-0.54/Changes 2017-11-21 10:56:07.000000000 +0100 @@ -1,5 +1,19 @@ Revision history for Perl extension Test::Spec. +0.54 Tue Nov 21 12:46:00 MSK 2017 + - `around` method added to allow localized variables and other local setup. + Call `yield` method to run examples by `around` CODE. + Contributed by @akzhan + + - Replace some `use base` with `use parent` and other minor updates. + Contributed by @akzhan + + - Now tested under Perl 5.22-5.26 too + Contributed by @akzhan + + - predictable_destroy spec fixed under Perl 5.8 + Contributed by @akzhan + 0.53 Wed Aug 16 09:49:00 BST 2017 - POD links are clickable Contributed by @manwar (issue #42) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/MANIFEST new/Test-Spec-0.54/MANIFEST --- old/Test-Spec-0.53/MANIFEST 2017-08-16 10:53:04.000000000 +0200 +++ new/Test-Spec-0.54/MANIFEST 2017-11-21 11:06:56.000000000 +0100 @@ -10,6 +10,7 @@ MANIFEST README.md t/another_shared_examples_spec.pl +t/around.t t/auto_inherit.t t/data_sharing.t t/define.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/META.json new/Test-Spec-0.54/META.json --- old/Test-Spec-0.53/META.json 2017-08-16 10:53:04.000000000 +0200 +++ new/Test-Spec-0.54/META.json 2017-11-21 11:06:56.000000000 +0100 @@ -4,13 +4,13 @@ "Philip Garrett <[email protected]>" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", + "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", - "version" : 2 + "version" : "2" }, "name" : "Test-Spec", "no_index" : { @@ -33,6 +33,7 @@ "runtime" : { "requires" : { "Carp" : "0", + "Devel::GlobalPhase" : "0", "Exporter" : "0", "List::Util" : "0", "Package::Stash" : "0.23", @@ -57,6 +58,5 @@ "web" : "https://github.com/kingpong/perl-Test-Spec" } }, - "version" : "0.53", - "x_serialization_backend" : "JSON::PP version 2.94" + "version" : "0.54" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/META.yml new/Test-Spec-0.54/META.yml --- old/Test-Spec-0.53/META.yml 2017-08-16 10:53:03.000000000 +0200 +++ new/Test-Spec-0.54/META.yml 2017-11-21 11:06:55.000000000 +0100 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' +generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -19,6 +19,7 @@ - inc requires: Carp: '0' + Devel::GlobalPhase: '0' Exporter: '0' List::Util: '0' Package::Stash: '0.23' @@ -32,5 +33,4 @@ resources: bugtracker: https://github.com/kingpong/perl-Test-Spec/issues repository: https://github.com/kingpong/perl-Test-Spec -version: '0.53' -x_serialization_backend: 'CPAN::Meta::YAML version 0.011' +version: '0.54' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/Makefile.PL new/Test-Spec-0.54/Makefile.PL --- old/Test-Spec-0.53/Makefile.PL 2017-08-15 11:40:37.000000000 +0200 +++ new/Test-Spec-0.54/Makefile.PL 2017-11-21 10:32:05.000000000 +0100 @@ -18,7 +18,8 @@ 'constant' => 0, }, TEST_REQUIRES => { - 'TAP::Parser' => 0, + 'TAP::Parser' => 0, + 'Devel::GlobalPhase' => 0, }, ABSTRACT_FROM => 'lib/Test/Spec.pm', # retrieve abstract from module AUTHOR => 'Philip Garrett <[email protected]>', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/README.md new/Test-Spec-0.54/README.md --- old/Test-Spec-0.53/README.md 2017-08-15 11:40:37.000000000 +0200 +++ new/Test-Spec-0.54/README.md 2017-11-21 10:32:05.000000000 +0100 @@ -27,12 +27,13 @@ This module requires these other modules and libraries: * constant + * Devel::GlobalPhase (for tests) * List::Util * Package::Stash (>= 0.23) * Scalar::Util (XS version) - * TAP::Parser + * TAP::Parser (for tests) * Test::Deep (>= 0.103) - * Test::More + * Test::More (>= 0.88) * Test::Trap * Tie::IxHash diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/lib/Test/Spec/Context.pm new/Test-Spec-0.54/lib/Test/Spec/Context.pm --- old/Test-Spec-0.53/lib/Test/Spec/Context.pm 2017-08-15 11:40:37.000000000 +0200 +++ new/Test-Spec-0.54/lib/Test/Spec/Context.pm 2017-11-21 10:32:05.000000000 +0100 @@ -14,7 +14,10 @@ use Test::Spec::Example; use Test::Spec::TodoExample; -our $_StackDepth = 0; +our @CARP_NOT = (); + +my $_StackDepth = 0; +my $_AroundStackDepth = 1; sub new { my $class = shift; @@ -124,6 +127,11 @@ return $self->{_after_blocks} ||= []; } +sub around_blocks { + my $self = shift; + return $self->{_around_blocks} ||= []; +} + sub tests { my $self = shift; return $self->{_tests} ||= []; @@ -383,8 +391,9 @@ $context->contextualize($code, $example); } -# Runs $code within a context (specifically, having been wrapped with -# on_enter/on_leave setup and teardown). +# Runs $code within a context (specifically, having been wrapped +# with on_enter/on_leave setup and teardown, +# and with around blocks). sub contextualize { my ($self,$code,$example) = @_; local $Test::Spec::_Current_Context = $self; @@ -397,6 +406,8 @@ push @errs, $@ if $@; if (not @errs) { + $code = $self->wrap_code_with_around_blocks($code,$example); + eval { $code->($example) }; push @errs, $@ if $@; } @@ -422,6 +433,46 @@ return; } +# Wraps $code within a context with around blocks. +sub wrap_code_with_around_blocks { + my ($self,$code,$example) = @_; + for (@{ $self->around_blocks }) { + $code = $self->wrap_code_with_around_block($code,$_,$example); + } + return $code; +} + +# Wraps $code within a context with around block. +sub wrap_code_with_around_block { + my ($self,$inner_code,$block,$example) = @_; + + my $this = $self; + Scalar::Util::weaken($this); + + return sub { + my $yield_ok = 0; + local $Test::Spec::Yield = sub { + $yield_ok = 1; + $inner_code->($example); + }; + $this && $this->_debug(sub { + printf STDERR "%s[around CODE %s] %s {\n", '__' x $_AroundStackDepth, $self->_debug_name, "$block"; + $_AroundStackDepth++; + }); + + $block->{code}->($example); + + $this && $this->_debug(sub { + $_AroundStackDepth--; + printf STDERR "%s[/around CODE %s] %s }\n", '__' x $_AroundStackDepth, $self->_debug_name, "$block"; + }); + unless ($yield_ok) { + local @CARP_NOT = qw( Test::Spec Test::Spec::Example ); + Carp::croak "around CODE doesn't call yield"; + } + }; +} + # # Copyright (c) 2010-2011 by Informatics Corporation of America. # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/lib/Test/Spec.pm new/Test-Spec-0.54/lib/Test/Spec.pm --- old/Test-Spec-0.53/lib/Test/Spec.pm 2017-08-16 10:50:24.000000000 +0200 +++ new/Test-Spec-0.54/lib/Test/Spec.pm 2017-11-21 10:57:12.000000000 +0100 @@ -3,9 +3,9 @@ use warnings; use Test::Trap (); # load as early as possible to override CORE::exit -our $VERSION = '0.53'; +our $VERSION = '0.54'; -use base qw(Exporter); +use parent 'Exporter'; use Carp (); use Exporter (); @@ -19,17 +19,22 @@ our @EXPORT = qw(runtests describe xdescribe context xcontext it xit they xthey - before after spec_helper + before after around yield spec_helper *TODO share shared_examples_for it_should_behave_like ); our @EXPORT_OK = ( @EXPORT, qw(DEFINITION_PHASE EXECUTION_PHASE $Debug) ); our %EXPORT_TAGS = ( all => \@EXPORT_OK, constants => [qw(DEFINITION_PHASE EXECUTION_PHASE)] ); +our @CARP_NOT = (); our $_Current_Context; our %_Package_Contexts; our %_Package_Phase; our %_Package_Tests; our %_Shared_Example_Groups; +our $Yield = sub { + local @CARP_NOT = qw( Test::Spec ); + Carp::croak "yield can be called only by around CODE"; +}; # Avoid polluting the Spec namespace by loading these other modules into # what's essentially a mixin class. When you write "use Test::Spec", @@ -70,7 +75,7 @@ eval qq{ package $callpkg; - use base 'Test::Spec'; + use parent 'Test::Spec'; # allow Test::Spec usage errors to be reported via Carp our \@CARP_NOT = qw($callpkg); }; @@ -216,6 +221,22 @@ }); } +# around CODE +sub around(&) { + my $package = caller; + my $code = pop; + if (ref($code) ne 'CODE') { + Carp::croak "expected subroutine reference as last argument"; + } + my $context = _autovivify_context($package); + push @{ $context->around_blocks }, { code => $code }; +} + +# yield +sub yield() { + $Yield->(); +} + # make context() an alias for describe() sub context(@); BEGIN { *context = \&describe } @@ -731,6 +752,29 @@ C<after "all"> blocks run I<after> C<after "each"> blocks. +=item around CODE + +Defines code to be run around tests in the current describe block are +run. This code must call C<yield>.. + + our $var = 0; + + describe "Something" => sub { + around { + local $var = 1; + yield; + }; + + it "should have localized var" => sub { + is $var, 1; + }; + }; + +This CODE will run around each example. + +=item yield + +Runs examples in context of C<around> block. =item shared_examples_for DESCRIPTION => CODE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/t/around.t new/Test-Spec-0.54/t/around.t --- old/Test-Spec-0.53/t/around.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Test-Spec-0.54/t/around.t 2017-11-21 10:32:05.000000000 +0100 @@ -0,0 +1,51 @@ +#!/usr/bin/env perl +# +# around.pl +# +# Test cases for arounded specs (around). +# +######################################################################## +# + +use Test::Spec; +use FindBin qw($Bin); +BEGIN { require "$Bin/test_helper.pl" }; + +our $local_var = 5; + +describe "around method" => sub { + around { + local $local_var = 4; + yield; + }; + it "should have localized var" => sub { is $local_var, 4 }; + + describe "inner" => sub { + around( sub { + local $local_var = 15; + yield; + }); + + it "should have localized var" => sub { is $local_var, 15 }; + it "should pass an example instance" => sub { isa_ok shift, "Test::Spec::Example" }; + }; + + describe "another inner" => sub { + around { + local $local_var = 7; + yield; + }; + + it "should have localized var" => sub { is $local_var, 7 }; + it "should pass an example instance" => sub { isa_ok shift, "Test::Spec::Example" }; + }; +}; + +describe "yield method" => sub { + it "should be died without any around" => sub { + eval { yield }; + like $@, qr/yield/; + }; +}; + +runtests(@ARGV) unless caller; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-Spec-0.53/t/predictable_destroy.pl new/Test-Spec-0.54/t/predictable_destroy.pl --- old/Test-Spec-0.53/t/predictable_destroy.pl 2017-08-15 11:40:37.000000000 +0200 +++ new/Test-Spec-0.54/t/predictable_destroy.pl 2017-11-21 10:32:05.000000000 +0100 @@ -10,11 +10,11 @@ package Testcase::Spec::PredictableDestroy; use Test::Spec; - +use Devel::GlobalPhase qw( global_phase ); { package Foo; sub new { bless {}, $_[0] } - sub DESTROY { warn("$_[0] DESTROYED IN ${^GLOBAL_PHASE}") } + sub DESTROY { warn("$_[0] DESTROYED IN ". global_phase) } }; describe "Test::Spec::Mocks" => sub {
