3 # Test ~ expansion from command line arguments.
6 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
7 use MBTest tests => 15;
11 my $tmp = MBTest->tmpdir;
14 my $dist = DistGen->new( dir => $tmp );
17 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
25 local $Test::Builder::Level = $Test::Builder::Level + 1;
31 $mb = Module::Build->new_from_context( @args );
38 my $p = 'install_base';
41 my $home = $ENV{HOME} ? $ENV{HOME} : undef;
42 skip "Needs case and syntax tweaks for VMS", 14 if $^O eq 'VMS';
43 unless (defined $home) {
44 my @info = eval { getpwuid $> };
45 skip "No home directory for tilde-expansion tests", 14 if $@;
49 is( run_sample( $p => '~' )->$p(), $home );
51 is( run_sample( $p => '~/foo' )->$p(), "$home/foo" );
53 is( run_sample( $p => '~~' )->$p(), '~~' );
55 is( run_sample( $p => '~ foo' )->$p(), '~ foo' );
57 is( run_sample( $p => '~/ foo')->$p(), "$home/ foo" );
59 is( run_sample( $p => '~/fo o')->$p(), "$home/fo o" );
61 is( run_sample( $p => 'foo~' )->$p(), 'foo~' );
63 is( run_sample( prefix => '~' )->prefix,
66 my $mb = run_sample( install_path => { html => '~/html',
69 is( $mb->install_destination('lib'), "$home/lib" );
70 # 'html' is translated to 'binhtml' & 'libhtml'
71 is( $mb->install_destination('binhtml'), "$home/html" );
72 is( $mb->install_destination('libhtml'), "$home/html" );
74 $mb = run_sample( install_path => { lib => '~/lib' } );
75 is( $mb->install_destination('lib'), "$home/lib" );
77 $mb = run_sample( destdir => '~' );
78 is( $mb->destdir, $home );
81 is( $mb->$p(), '~', 'API does not expand tildes' );
84 # Again, with named users
86 skip "Needs case and syntax tweaks for VMS", 1 if $^O eq 'VMS';
87 my @info = eval { getpwuid $> };
88 skip "No home directory for tilde-expansion tests", 1 if $@;
89 my ($me, $home) = @info[0,7];
91 is( run_sample( $p => "~$me/foo")->$p(), "$home/foo" );
96 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";