#!/usr/bin/perl -w
use
lib
$ENV
{PERL_CORE} ?
'../lib/Module/Build/t/lib'
:
't/lib'
;
use_ok
'Module::Build'
;
ensure_blib(
'Module::Build'
);
my
$tmp
= MBTest->tmpdir;
my
$dist
= DistGen->new(
dir
=>
$tmp
);
$dist
->regen;
$dist
->chdir_in;
sub
run_sample {
my
@args
=
@_
;
local
$Test::Builder::Level
=
$Test::Builder::Level
+ 1;
$dist
->clean;
my
$mb
;
stdout_of(
sub
{
$mb
= Module::Build->new_from_context(
@args
);
} );
return
$mb
;
}
my
$p
=
'install_base'
;
SKIP: {
my
$home
=
$ENV
{HOME} ?
$ENV
{HOME} :
undef
;
if
($^O eq
'VMS'
) {
$home
= VMS::Filespec::unixify(
$home
);
$home
=~ s
}
unless
(
defined
$home
) {
my
@info
=
eval
{
getpwuid
$> };
skip
"No home directory for tilde-expansion tests"
, 14
if
$@;
$home
=
$info
[7];
}
is( run_sample(
$p
=>
'~'
)->
$p
(),
$home
);
is( run_sample(
$p
=>
'~/foo'
)->
$p
(),
"$home/foo"
);
is( run_sample(
$p
=>
'~~'
)->
$p
(),
'~~'
);
is( run_sample(
$p
=>
'~ foo'
)->
$p
(),
'~ foo'
);
is( run_sample(
$p
=>
'~/ foo'
)->
$p
(),
"$home/ foo"
);
is( run_sample(
$p
=>
'~/fo o'
)->
$p
(),
"$home/fo o"
);
is( run_sample(
$p
=>
'foo~'
)->
$p
(),
'foo~'
);
is( run_sample(
prefix
=>
'~'
)->prefix,
$home
);
my
$mb
= run_sample(
install_path
=> {
html
=>
'~/html'
,
lib
=>
'~/lib'
}
);
is(
$mb
->install_destination(
'lib'
),
"$home/lib"
);
is(
$mb
->install_destination(
'binhtml'
),
"$home/html"
);
is(
$mb
->install_destination(
'libhtml'
),
"$home/html"
);
$mb
= run_sample(
install_path
=> {
lib
=>
'~/lib'
} );
is(
$mb
->install_destination(
'lib'
),
"$home/lib"
);
$mb
= run_sample(
destdir
=>
'~'
);
is(
$mb
->destdir,
$home
);
$mb
->
$p
(
'~'
);
is(
$mb
->
$p
(),
'~'
,
'API does not expand tildes'
);
}
SKIP: {
my
@info
=
eval
{
getpwuid
$> };
skip
"No home directory for tilde-expansion tests"
, 1
if
$@;
my
(
$me
,
$home
) =
@info
[0,7];
my
$expected
=
"$home/foo"
;
if
($^O eq
'VMS'
) {
$home
= VMS::Filespec::unixify(
$home
);
$home
=~ s
$expected
=
$home
.
'/../[^/]+'
.
'/foo'
;
}
like( run_sample(
$p
=>
"~$me/foo"
)->
$p
(),
qr($expected)
i );
}
$dist
->remove;