The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::Settings - Ask or tell when certain types of tests should be run

VERSION

version 0.001

SYNOPSIS

Check the current settings

  use Test::Settings qw(:all);

  if (want_smoke) {
    printf("I must be a smoke tester\n");
  }  

  if (want_non_interactive) { ... }
  if (want_extended) { ... }
  if (want_author) { ... }
  if (want_release) { ... }

Change settings

  enable_smoke;
  enable_non_interactive;
  enable_extended;
  enable_author;
  enable_release;

  disable_smoke;
  disable_non_interactive;
  disable_extended;
  disable_author;
  disable_release;

Helper - see the settings as a string

  print current_settings;

DESCRIPTION

There are a number of Environment variables used to control how tests should behave, and sometimes these can change names or meaning.

This library tries to provide a consistent interface so that testers/toolchain users can determine the state of testing without having to care about the intricacies behind the scenes.

Inspecting the state of things

Currently, the following methods are provided to see what the current state of testing options are. Unless explicitly requested by a user or tool, these will usually all return false.

want_smoke

  if (want_smoke) { ... }

Returns true if we are currently being run by a smoker or a 'robot'.

want_non_interactive

  if (want_non_interactive) { ... }

Returns true if we are in non-interactive mode. This means tests should not prompt the user for information.

want_extended

  if (want_extended) { ... }

Returns true if extended testing has been requested. Often modules will ship with extra (non author/release) tests that users may opt in to run.

want_author

  if (want_author) { ... }

Returns true if author testing has been requested. Author tests are used during development time only.

want_release

  if (want_release) { ... }

Returns true if release testing has been requested. Release tests are used when a new release of a distribution is going to be built to check sanity before pushing to CPAN.

Changing the state of things

The methods below allow modification of the state of testing. This can be used by smokers and build tools to inform testing tools how to run.

enable_smoke

disable_smoke

  enable_smoke();
  disable_smoke();

This enables or disables (default) smoke testing.

enable_non_interactive

disable_non_interactive

  enable_non_interactive();
  disable_non_interactive();

This enables or disables (default) non-interactive testing.

enable_extended

disable_extended

  enable_extended();
  disable_extended();

This enables or disables (default) extended testing.

enable_author

disable_author

  enable_author();
  disable_author();

This enables or disables (default) author testing.

enable_release

disable_release

  enable_release();
  disable_release();

This enables or disables (default) release testing.

Extra information

If you'd like a quick representation of the current state of things, the methods below will help you inspect them.

current_settings

  my $str = current_settings();
  print $str;

Displays a table of the current settings of all wants.

SEE ALSO

Test::Is - Skip test in a declarative way, following the Lancaster Consensus

AUTHOR

Matthew Horsfall (alh) - <wolfsage@gmail.com>

LICENSE

You may distribute this code under the same terms as Perl itself.