in reply to passing args to tests from Module::Build

general method is to create a config file
  • Comment on Re: passing args to tests from Module::Build

Replies are listed 'Best First'.
Re^2: passing args to tests from Module::Build
by Anonymous Monk on Oct 19, 2009 at 13:21 UTC
    Confirmed
    $ module_new dist MB::Module::Name --make=MB [debug] set root to ~/dev/tmp [info] created MB-Module-Name/trunk [info] created MB-Module-Name/tags [info] created MB-Module-Name/branch [info] changed directory to MB-Module-Name/trunk [debug] set root to ~/dev/tmp/MB-Module-Name/trunk [info] created Build.PL [info] created README [info] created Changes [info] created MANIFEST.SKIP [info] created t [info] created t/00_load.t [info] created t/99_pod.t [info] created t/99_podcoverage.t [info] created lib/MB/Module [info] created lib/MB/Module/Name.pm Added to MANIFEST: Build.PL Added to MANIFEST: Changes Added to MANIFEST: lib/MB/Module/Name.pm Added to MANIFEST: MANIFEST Added to MANIFEST: README Added to MANIFEST: t/00_load.t Added to MANIFEST: t/99_pod.t Added to MANIFEST: t/99_podcoverage.t [info] updated manifest $ cd MB-Module-Name/trunk $ perl Build.PL --pi --PIE --Cake Checking whether your kit is complete... Looks good Checking prerequisites... Looks good Creating new 'Build' script for 'MB-Module-Name' version '0.01' $ grep -r Cake . ./_build/build_params: 'Cake' => undef, $ grep -r -i pi . ./_build/build_params: 'pi' => '--PIE' ./_build/build_params: 'extra_compiler_flags' => [], $ perl -MData::Dumper -le " my $conf = do q!./_build/build_params!; pr +int Dumper($$conf[0]) $VAR1 = { 'Cake' => undef, 'ARGV' => [], 'pi' => '--PIE' }; $
    Please note that Module::Build reserves all lowercase parameters for its own use. See also module_new.
Re^2: passing args to tests from Module::Build
by cutlass2006 (Pilgrim) on Oct 19, 2009 at 13:21 UTC
    thx for the reply, I have done this, perhaps its blindingly obvious but I seem to be missing how to then refer to these args in the test files themselves ...
      #!/usr/bin/perl -- ## t/file.t use File::Spec::Functions qw' updir catfile rel2abs '; use File::Basename qw' dirname '; my $thisf = rel2abs(__FILE__); my $thisd = dirname($thisf); my $conff = catfile( $thisd, updir, qw! _build build_params ! ); my $conf = require $conff; my $args = $conf->[0]; my %ARGS = %{$conf->[0] }; print "Cake? $$args{Cake}\n"; print "pi? $ARGS{pi}\n";