Skip to content

kentnl/Test-WithTaint

Repository files navigation

NAME

Test::WithTaint - Ensure a Test is run reliably with taint

SYNOPSIS

# re-execute self with tainting t/foo-tainting.t
use Test::WithTaint;

# execute a different script with tainting
use Test::WithTaint -exec => 't/foo.t'

DESCRIPTION

This module aims to facilitate taint testing in several ways.

  • Permit skipping taint-dependent tests in the event a future Perl release lacks taint support

  • Permit forcing taint mode on a test that is not already running in taint mode

  • Simplify running the an existing test both in and out of taint mode

  • Clean up environment when invoking taint-dependent tests to avoid common traps in taint + %ENV

USAGE

Simple Mode

This mode is the most recommended usage, and it adds a layer of safety that is too hard to achieve with a hash-bang trick.

# inside foo.t
use Test::WithTaint;

Here, the default behavior is to:

  • Check your Perl supports tainting, and skip the test if it does not.

  • Check your Perl is running in taint mode, and continue execution if it is.

  • In the event Perl is NOT running in taint mode, clean up the environment slightly and re-execute the test under taint mode.

Indirect Mode

This mode is a variation on SimpleMode designed to reduce code duplication.

# inside foo-tainted.t
use Test::WithTaint -exec => 't/foo.t';

This:

  • Checks Perl supports tainting, and skips the test if it does not.

  • Cleans up the environment, and Forcefully invokes the test passed to -exec with exec;

AUTHOR

Kent Fredric <kentnl@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

About

Ensure a Test is run reliably with taint

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages