Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/motemen/perl5-test-retry
Retry a code block for several times until a test function succeeds
https://github.com/motemen/perl5-test-retry
Last synced: about 1 month ago
JSON representation
Retry a code block for several times until a test function succeeds
- Host: GitHub
- URL: https://github.com/motemen/perl5-test-retry
- Owner: motemen
- License: other
- Created: 2013-02-14T10:44:41.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-09-25T01:27:58.000Z (over 9 years ago)
- Last Synced: 2024-10-15T15:29:48.532Z (3 months ago)
- Language: Perl
- Size: 148 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Test::Retry - Retry test functions on failure
# SYNOPSIS
use Test::Retry;
# Retries for 5 times with 0.5 secs delay each
retry_test {
is func_with_some_random_lag(), $expected;
};# or override existing test functions
BEGIN { Test::Retry->override('is') }
is { func_with_some_random_lag(), $expected };
# DESCRIPTION
Test::Retry provides feature to retry code until a test succeeds (with retry limits).
Useful for tests which involves I/O and requires some wait to pass, for example.
# IMPORTING
Test::Retry exports one function, namely `retry_test`.
Options below are available when you `use` this module:
- max => $n
The maximum count of retries. Affects the exported `retry_test` function.
Defaults to $Test::Retry::MAX\_RETRIES = 5.
- delay => $floating\_secs
The floating seconds after which the next block execution is tried after a failed test.
Affects the exported `retry_test` function.Defaults to $Test::Retry::RETRY\_DELAY = 0.5.
- override => \\@function\_names
Calls `override` (see below) at the timing of `import`.
# FUNCTIONS/METHODS
- retry\_test { ... }
Makes the given block of code re-run if a test inside it is going to fail.
Retry limit and interval are configurable by importing arguments (see above).If the test continues to fail and retry count hits the limit, the test really fails.
- Test::Retry->override(@function\_names);
Overrides the existing test functions in caller package by retrying version of them.
Should be called in BEGIN block for prototyping issues.
Arguments must be passed by a coderef that returns arguments passed to the test function.
For example,
like $io->get(), qr/blahblah/, 'blah';
becomes:
BEGIN { Test::Retry->override('like') }
like { $io->get(), qr/blahblah/, 'blah' };Pretty, heh?
# AUTHOR
motemen
# LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.