4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
9 my ($have_c_compiler, $C_support_feature) = check_compiler();
11 if (! $C_support_feature) {
12 plan skip_all => 'C_support not enabled';
13 } elsif ( !$have_c_compiler ) {
14 plan skip_all => 'C_support enabled, but no compiler found';
20 #########################
25 my $tmp = MBTest->tmpdir;
28 my $dist = DistGen->new( dir => $tmp, xs => 1 );
31 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
32 my $mb = Module::Build->new_from_context;
35 eval {$mb->dispatch('clean')};
38 eval {$mb->dispatch('build')};
42 # Make sure it actually works: that we can call methods in the XS module
44 # Unfortunately, We must do this is a subprocess because some OS will not
45 # release the handle on a dynamic lib until the attaching process terminates
47 ok $mb->run_perl_command(['-Mblib', '-M'.$dist->name, '-e1']);
49 like stdout_of( sub {$mb->run_perl_command([
50 '-Mblib', '-M'.$dist->name,
51 '-we', "print @{[$dist->name]}::okay()"])}), qr/ok$/;
53 like stdout_of( sub {$mb->run_perl_command([
54 '-Mblib', '-M'.$dist->name,
55 '-we', "print @{[$dist->name]}::version()"])}), qr/0.01$/;
57 like stdout_of( sub {$mb->run_perl_command([
58 '-Mblib', '-M'.$dist->name,
59 '-we', "print @{[$dist->name]}::xs_version()"])}), qr/0.01$/;
64 # Try again in a subprocess
65 eval {$mb->dispatch('clean')};
69 $mb->create_build_script;
70 my $script = $mb->build_script;
73 eval {$mb->run_perl_script($script)};
77 # We can't be verbose in the sub-test, because Test::Harness will
78 # think that the output is for the top-level test.
79 eval {$mb->dispatch('test')};
82 eval {$mb->dispatch('clean')};
87 skip( "skipping a Unixish-only tests", 1 )
88 unless $mb->is_unixish;
90 $mb->{config}->push(ld => "FOO=BAR ".$mb->config('ld'));
91 eval {$mb->dispatch('build')};
93 $mb->{config}->pop('ld');
96 eval {$mb->dispatch('realclean')};
99 # Make sure blib/ is gone after 'realclean'
104 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
108 ########################################
110 # Try a XS distro with a deep namespace
112 $dist = DistGen->new( name => 'Simple::With::Deep::Name',
113 dir => $tmp, xs => 1 );
115 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
117 $mb = Module::Build->new_from_context;
120 $mb->dispatch('build');
123 $mb->dispatch('test');
126 $mb->dispatch('realclean');
130 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
134 ########################################
136 # Try a XS distro using a flat directory structure
137 # and a 'dist_name' instead of a 'module_name'
139 $dist = DistGen->new( name => 'Dist-Name', dir => $tmp, xs => 1 );
141 $dist->remove_file('lib/Dist-Name.pm');
142 $dist->remove_file('lib/Dist-Name.xs');
144 $dist->change_build_pl
146 dist_name => 'Dist-Name',
147 dist_version_from => 'Simple.pm',
148 pm_files => { 'Simple.pm' => 'lib/Simple.pm' },
149 xs_files => { 'Simple.xs' => 'lib/Simple.xs' },
152 $dist->add_file('Simple.xs', <<"---");
157 MODULE = Simple PACKAGE = Simple
162 RETVAL = newSVpv( "ok", 0 );
167 $dist->add_file( 'Simple.pm', <<"---" );
175 \@ISA = qw( Exporter DynaLoader );
176 \@EXPORT_OK = qw( okay );
178 bootstrap Simple \$VERSION;
186 Simple - Perl extension for blah blah blah
190 Stub documentation for Simple.
194 A. U. Thor, a.u.thor\@a.galaxy.far.far.away
198 $dist->change_file('t/basic.t', <<"---");
199 use Test::More tests => 2;
205 ok( Simple::okay() eq 'ok' );
209 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
212 $mb = Module::Build->new_from_context;
215 $mb->dispatch('build');
218 $mb->dispatch('test');
221 $mb->dispatch('realclean');
225 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";