1
0

Accepting request 351708 from devel:languages:perl

1

OBS-URL: https://build.opensuse.org/request/show/351708
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/perl-Test-Exception?expand=0&rev=32
This commit is contained in:
Dominique Leuenberger 2016-01-04 08:20:43 +00:00 committed by Git OBS Bridge
commit a965b684b6
4 changed files with 132 additions and 117 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d92ccb566d93140abc93b07ec4c13e9b14c8f8f7d7858a2ab575d83b3bb51b26
size 14801

BIN
Test-Exception-0.43.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Sat Jan 2 10:16:17 UTC 2016 - coolo@suse.com
- updated to 0.43
see /usr/share/doc/packages/perl-Test-Exception/Changes
-------------------------------------------------------------------
Sat Dec 26 10:16:52 UTC 2015 - coolo@suse.com
- updated to 0.41
see /usr/share/doc/packages/perl-Test-Exception/Changes
0.40 [2015-12-21]
- Updated for Test2
------------------------------------------------------------------- -------------------------------------------------------------------
Sun Jun 7 09:05:54 UTC 2015 - coolo@suse.com Sun Jun 7 09:05:54 UTC 2015 - coolo@suse.com

View File

@ -1,7 +1,7 @@
# #
# spec file for package perl-Test-Exception # spec file for package perl-Test-Exception
# #
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -17,10 +17,10 @@
Name: perl-Test-Exception Name: perl-Test-Exception
Version: 0.400000 Version: 0.430000
Release: 0 Release: 0
%define cpan_version 0.40 %define cpan_version 0.43
Provides: perl(Test::Exception) = 0.400000 Provides: perl(Test::Exception) = 0.430000
%define cpan_name Test-Exception %define cpan_name Test-Exception
Summary: Test exception-based code Summary: Test exception-based code
License: Artistic-1.0 or GPL-1.0+ License: Artistic-1.0 or GPL-1.0+
@ -43,170 +43,170 @@ Requires: perl(Test::Builder::Tester) >= 1.07
%description %description
This module provides a few convenience methods for testing exception based This module provides a few convenience methods for testing exception based
code. It is built with the Test::Builder manpage and plays happily with the code. It is built with Test::Builder and plays happily with Test::More and
Test::More manpage and friends. friends.
If you are not already familiar with the Test::More manpage now would be If you are not already familiar with Test::More now would be the time to go
the time to go take a look. take a look.
You can specify the test plan when you 'use Test::Exception' in the same You can specify the test plan when you 'use Test::Exception' in the same
way as 'use Test::More'. See the Test::More manpage for details. way as 'use Test::More'. See Test::More for details.
NOTE: Test::Exception only checks for exceptions. It will ignore other NOTE: Test::Exception only checks for exceptions. It will ignore other
methods of stopping program execution - including exit(). If you have an methods of stopping program execution - including exit(). If you have an
exit() in evalled code Test::Exception will not catch this with any of its exit() in evalled code Test::Exception will not catch this with any of its
testing functions. testing functions.
NOTE: This module uses the Sub::Uplevel manpage and relies on overriding NOTE: This module uses Sub::Uplevel and relies on overriding
'CORE::GLOBAL::caller' to hide your test blocks from the call stack. If 'CORE::GLOBAL::caller' to hide your test blocks from the call stack. If
this use of global overrides concerns you, the the Test::Fatal manpage this use of global overrides concerns you, the Test::Fatal module offers a
module offers a more minimalist alternative. more minimalist alternative.
* *throws_ok* * *throws_ok*
Tests to see that a specific exception is thrown. throws_ok() has two Tests to see that a specific exception is thrown. throws_ok() has two
forms: forms:
throws_ok BLOCK REGEX, TEST_DESCRIPTION throws_ok BLOCK REGEX, TEST_DESCRIPTION
throws_ok BLOCK CLASS, TEST_DESCRIPTION throws_ok BLOCK CLASS, TEST_DESCRIPTION
In the first form the test passes if the stringified exception matches In the first form the test passes if the stringified exception matches the
the give regular expression. For example: give regular expression. For example:
throws_ok { read_file( 'unreadable' ) } qr/No file/, 'no file'; throws_ok { read_file( 'unreadable' ) } qr/No file/, 'no file';
If your perl does not support 'qr//' you can also pass a regex-like If your perl does not support 'qr//' you can also pass a regex-like string,
string, for example: for example:
throws_ok { read_file( 'unreadable' ) } '/No file/', 'no file'; throws_ok { read_file( 'unreadable' ) } '/No file/', 'no file';
The second form of throws_ok() test passes if the exception is of the The second form of throws_ok() test passes if the exception is of the same
same class as the one supplied, or a subclass of that class. For example: class as the one supplied, or a subclass of that class. For example:
throws_ok { $foo->bar } "Error::Simple", 'simple error'; throws_ok { $foo->bar } "Error::Simple", 'simple error';
Will only pass if the 'bar' method throws an Error::Simple exception, or Will only pass if the 'bar' method throws an Error::Simple exception, or a
a subclass of an Error::Simple exception. subclass of an Error::Simple exception.
You can get the same effect by passing an instance of the exception you You can get the same effect by passing an instance of the exception you
want to look for. The following is equivalent to the previous example: want to look for. The following is equivalent to the previous example:
my $SIMPLE = Error::Simple->new; my $SIMPLE = Error::Simple->new;
throws_ok { $foo->bar } $SIMPLE, 'simple error'; throws_ok { $foo->bar } $SIMPLE, 'simple error';
Should a throws_ok() test fail it produces appropriate diagnostic Should a throws_ok() test fail it produces appropriate diagnostic messages.
messages. For example: For example:
not ok 3 - simple error not ok 3 - simple error
# Failed test (test.t at line 48) # Failed test (test.t at line 48)
# expecting: Error::Simple exception # expecting: Error::Simple exception
# found: normal exit # found: normal exit
Like all other Test::Exception functions you can avoid prototypes by Like all other Test::Exception functions you can avoid prototypes by
passing a subroutine explicitly: passing a subroutine explicitly:
throws_ok( sub {$foo->bar}, "Error::Simple", 'simple error' ); throws_ok( sub {$foo->bar}, "Error::Simple", 'simple error' );
A true value is returned if the test succeeds, false otherwise. On exit A true value is returned if the test succeeds, false otherwise. On exit $@
$@ is guaranteed to be the cause of death (if any). is guaranteed to be the cause of death (if any).
A description of the exception being checked is used if no optional test A description of the exception being checked is used if no optional test
description is passed. description is passed.
NOTE: Remember when you 'die $string_without_a_trailing_newline' perl NOTE: Remember when you 'die $string_without_a_trailing_newline' perl will
will automatically add the current script line number, input line number automatically add the current script line number, input line number and a
and a newline. This will form part of the string that throws_ok regular newline. This will form part of the string that throws_ok regular
expressions match against. expressions match against.
* *dies_ok* * *dies_ok*
Checks that a piece of code dies, rather than returning normally. For Checks that a piece of code dies, rather than returning normally. For
example: example:
sub div { sub div {
my ( $a, $b ) = @_; my ( $a, $b ) = @_;
return $a / $b; return $a / $b;
}; };
dies_ok { div( 1, 0 ) } 'divide by zero detected'; dies_ok { div( 1, 0 ) } 'divide by zero detected';
# or if you don't like prototypes # or if you don't like prototypes
dies_ok( sub { div( 1, 0 ) }, 'divide by zero detected' ); dies_ok( sub { div( 1, 0 ) }, 'divide by zero detected' );
A true value is returned if the test succeeds, false otherwise. On exit A true value is returned if the test succeeds, false otherwise. On exit $@
$@ is guaranteed to be the cause of death (if any). is guaranteed to be the cause of death (if any).
Remember: This test will pass if the code dies for any reason. If you Remember: This test will pass if the code dies for any reason. If you care
care about the reason it might be more sensible to write a more specific about the reason it might be more sensible to write a more specific test
test using throws_ok(). using throws_ok().
The test description is optional, but recommended. The test description is optional, but recommended.
* *lives_ok* * *lives_ok*
Checks that a piece of code doesn't die. This allows your test script to Checks that a piece of code doesn't die. This allows your test script to
continue, rather than aborting if you get an unexpected exception. For continue, rather than aborting if you get an unexpected exception. For
example: example:
sub read_file { sub read_file {
my $file = shift; my $file = shift;
local $/; local $/;
open my $fh, '<', $file or die "open failed ($!)\n"; open my $fh, '<', $file or die "open failed ($!)\n";
$file = <FILE>; $file = <FILE>;
return $file; return $file;
}; };
my $file;
lives_ok { $file = read_file('test.txt') } 'file read';
# or if you don't like prototypes
lives_ok( sub { $file = read_file('test.txt') }, 'file read' );
Should a lives_ok() test fail it produces appropriate diagnostic
messages. For example:
not ok 1 - file read
# Failed test (test.t at line 15)
# died: open failed (No such file or directory)
A true value is returned if the test succeeds, false otherwise. On exit
$@ is guaranteed to be the cause of death (if any).
The test description is optional, but recommended.
* *lives_and*
Run a test that may throw an exception. For example, instead of doing:
my $file; my $file;
lives_ok { $file = read_file('answer.txt') } 'read_file worked'; lives_ok { $file = read_file('test.txt') } 'file read';
is $file, "42", 'answer was 42';
You can use lives_and() like this:
lives_and { is read_file('answer.txt'), "42" } 'answer is 42';
# or if you don't like prototypes # or if you don't like prototypes
lives_and(sub {is read_file('answer.txt'), "42"}, 'answer is 42'); lives_ok( sub { $file = read_file('test.txt') }, 'file read' );
Which is the same as doing Should a lives_ok() test fail it produces appropriate diagnostic messages.
For example:
is read_file('answer.txt'), "42\n", 'answer is 42'; not ok 1 - file read
unless 'read_file('answer.txt')' dies, in which case you get the same
kind of error as lives_ok()
not ok 1 - answer is 42
# Failed test (test.t at line 15) # Failed test (test.t at line 15)
# died: open failed (No such file or directory) # died: open failed (No such file or directory)
A true value is returned if the test succeeds, false otherwise. On exit A true value is returned if the test succeeds, false otherwise. On exit $@
$@ is guaranteed to be the cause of death (if any). is guaranteed to be the cause of death (if any).
The test description is optional, but recommended. The test description is optional, but recommended.
* *lives_and*
Run a test that may throw an exception. For example, instead of doing:
my $file;
lives_ok { $file = read_file('answer.txt') } 'read_file worked';
is $file, "42", 'answer was 42';
You can use lives_and() like this:
lives_and { is read_file('answer.txt'), "42" } 'answer is 42';
# or if you don't like prototypes
lives_and(sub {is read_file('answer.txt'), "42"}, 'answer is 42');
Which is the same as doing
is read_file('answer.txt'), "42\n", 'answer is 42';
unless 'read_file('answer.txt')' dies, in which case you get the same kind
of error as lives_ok()
not ok 1 - answer is 42
# Failed test (test.t at line 15)
# died: open failed (No such file or directory)
A true value is returned if the test succeeds, false otherwise. On exit $@
is guaranteed to be the cause of death (if any).
The test description is optional, but recommended.
%prep %prep
%setup -q -n %{cpan_name}-%{cpan_version} %setup -q -n %{cpan_name}-%{cpan_version}
find . -type f -print0 | xargs -0 chmod 644 find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
%build %build
%{__perl} Makefile.PL INSTALLDIRS=vendor %{__perl} Makefile.PL INSTALLDIRS=vendor