The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Module::Install::ExtendsMakeTest - Assembles test targets for `make` with code snippets

SYNOPSIS

inside Makefile.PL:

  use inc::Module::Install;
  tests 't/*t';
  
  # create a new test target
  extends_make_test(
      includes           => ["$ENV{HOME}/perl5/lib"],
      modules            => [qw/Foo Bar/],
      before_run_scripts => [qw/before.pl/],
      after_run_scripts  => [qw/after.pl/],
      before_run_codes   => ['print "start -> ", scalar localtime, "\n"'],
      after_run_codes    => ['print "end   -> ", scalar localtime, "\n"'],
      tests              => ['t/baz/*t'],
      env                => { PERL_ONLY => 1 },
      target             => 'foo',     # create make foo target
      alias              => 'testall', # make testall is run the make foo
  );

maybe make foo is:

  perl "-MExtUtils::Command::MM" "-I/home/xaicron/perl5/lib" "-MFoo" "-MBar" "-e" "do 'before.pl'; sub { print \"start -> \", scalar localtime, \"\n\" }->(); test_harness(0, 'inc'); do 'after.pl'; sub { print \"end -> \", scalar localtime, \"\n\" }->();" t/baz/*t

DESCRIPTION

Module::Install::ExtendsMakeTest creates make test variations with code snippets. This helps module developers to test their distributions with various conditions, e.g. under PERL_ONLY=1 or the control of some testing modules.

FUNCTIONS

extends_make_test(%args)

Defines a new test target with %args.

%args are:

includes => \@include_paths

Sets include paths.

  extends_make_test(
      includes => ['/path/to/inc'],
  );

  # `make test` will be something like this:
  perl -I/path/to/inc  -MExtUtils::Command::MM -e "test_harness(0, 'inc')" t/*t
modules => \@module_names

Sets modules which are loaded before running test_harness().

  extends_make_test(
      modules => ['Foo', 'Bar::Baz'],
  );
  
  # `make test` will be something like this:
  perl -MFoo -MBar::Baz -MExtUtils::Command::MM -e "test_harness(0, 'inc')" t/*t
before_run_script => \@scripts

Sets scripts to run before running test_harness().

  extends_make_test(
      before_run_script => ['tool/before_run_script.pl'],
  );
  
  # `make test` will be something like this:
  perl -MExtUtils::Command::MM -e "do 'tool/before_run_script.pl; test_harness(0, 'inc')" t/*t
after_run_script => \@scripts

Sets scripts to run after running test_harness().

  use inc::Module::Install;
  tests 't/*t';
  extends_make_test(
      after_run_script => ['tool/after_run_script.pl'],
  );
  
  # `make test` will be something like this:
  perl -MExtUtils::Command::MM -e "test_harness(0, 'inc'); do 'tool/before_run_script.pl;" t/*t
before_run_codes => \@codes

Sets perl codes to run before running test_harness().

  use inc::Module::Install;
  tests 't/*t';
  extends_make_test(
      before_run_codes => ['print scalar localtime , "\n"', sub { system qw/cat README/ }],
  );
  
  # `make test` will be something like this:
  perl -MExtUtils::Command::MM "sub { print scalar localtme, "\n" }->(); sub { system 'cat', 'README' }->(); test_harness(0, 'inc')" t/*t

The perl codes runs before_run_scripts runs later.

after_run_codes => \@codes

Sets perl codes to run after running test_harness().

  use inc::Module::Install;
  tests 't/*t';
  extends_make_test(
      after_run_codes => ['print scalar localtime , "\n"', sub { system qw/cat README/ }],
  );
  
  # `make test` will be something like this:
  perl -MExtUtils::Command::MM "test_harness(0, 'inc'); sub { print scalar localtme, "\n" }->(); sub { system 'cat', 'README' }->();" t/*t

The perl codes runs after_run_scripts runs later.

target => $name

Sets a new make target of the test.

  use inc::Module::Install;
  tests 't/*t';
  extends_make_test(
      before_run_script => 'tool/force-pp.pl',
      target            => 'test_pp',
  );
  
  # `make test_pp` will be something like this:
  perl -MExtUtils::Command::MM -e "do 'tool/force-pp.pl'; test_harness(0, 'inc')" t/*t
alias => $name

Sets an alias of the test.

  extends_make_test(
      before_run_script => 'tool/force-pp.pl',
      target            => 'test_pp',
      alias             => 'testall',
  );
  
  # `make test_pp` and `make testall` will be something like this:
  perl -MExtUtils::Command::MM -e "do 'tool/force-pp.pl'; test_harness(0, 'inc')" t/*t
env => \%env

Sets environment variables.

  extends_make_test(
      env => {
          FOO => 'bar',
      },
  );
  
  # `make test` will be something like this:
  perl -MExtUtils::Command::MM -e "\$ENV{q{FOO}} = q{bar}; test_harness(0, 'inc')" t/*t
tests => \@test_files

Sets test files to run.

  extends_make_test(
      tests  => ['t/foo.t', 't/bar.t'],
      env    => { USE_FOO => 1 },
      target => 'test_foo',
  );

  # `make test_foo` will be something like this:
  perl -MExtUtils::Command::MM -e "$ENV{USE_FOO} = 1 test_harness(0, 'inc')" t/foo.t t/bar.t

replace_default_make_test(%args)

Override the default `make test` with %args.

Same argument as extends_make_test(), but `target` and `alias` are not allowed.

AUTHOR

Yuji Shimada <xaicron {at} cpan.org>

Goro Fuji (gfx) <gfuji at cpan.org>

SEE ALSO

Module::Install

LICENSE

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