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';
15 } elsif ( $^O eq 'VMS' ) {
16 plan skip_all => 'Child test output confuses harness';
22 #########################
27 my $tmp = MBTest->tmpdir;
30 my $dist = DistGen->new( dir => $tmp, xs => 1 );
33 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
34 my $mb = Module::Build->new_from_context;
37 eval {$mb->dispatch('clean')};
40 eval {$mb->dispatch('build')};
44 # Make sure it actually works: that we can call methods in the XS module
46 # Unfortunately, We must do this is a subprocess because some OS will not
47 # release the handle on a dynamic lib until the attaching process terminates
49 ok $mb->run_perl_command(['-Mblib', '-M'.$dist->name, '-e1']);
51 like stdout_of( sub {$mb->run_perl_command([
52 '-Mblib', '-M'.$dist->name,
53 '-we', "print @{[$dist->name]}::okay()"])}), qr/ok$/;
55 like stdout_of( sub {$mb->run_perl_command([
56 '-Mblib', '-M'.$dist->name,
57 '-we', "print @{[$dist->name]}::version()"])}), qr/0.01$/;
59 like stdout_of( sub {$mb->run_perl_command([
60 '-Mblib', '-M'.$dist->name,
61 '-we', "print @{[$dist->name]}::xs_version()"])}), qr/0.01$/;
66 # Try again in a subprocess
67 eval {$mb->dispatch('clean')};
71 $mb->create_build_script;
72 my $script = $mb->build_script;
75 eval {$mb->run_perl_script($script)};
79 # We can't be verbose in the sub-test, because Test::Harness will
80 # think that the output is for the top-level test.
81 eval {$mb->dispatch('test')};
84 eval {$mb->dispatch('clean')};
89 skip( "skipping a Unixish-only tests", 1 )
90 unless $mb->is_unixish;
92 $mb->{config}->push(ld => "FOO=BAR ".$mb->config('ld'));
93 eval {$mb->dispatch('build')};
95 $mb->{config}->pop('ld');
98 eval {$mb->dispatch('realclean')};
101 # Make sure blib/ is gone after 'realclean'
106 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
110 ########################################
112 # Try a XS distro with a deep namespace
114 $dist = DistGen->new( name => 'Simple::With::Deep::Name',
115 dir => $tmp, xs => 1 );
117 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
119 $mb = Module::Build->new_from_context;
122 $mb->dispatch('build');
125 $mb->dispatch('test');
128 $mb->dispatch('realclean');
132 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
136 ########################################
138 # Try a XS distro using a flat directory structure
139 # and a 'dist_name' instead of a 'module_name'
141 $dist = DistGen->new( name => 'Dist-Name', dir => $tmp, xs => 1 );
143 $dist->remove_file('lib/Dist-Name.pm');
144 $dist->remove_file('lib/Dist-Name.xs');
146 $dist->change_build_pl
148 dist_name => 'Dist-Name',
149 dist_version_from => 'Simple.pm',
150 pm_files => { 'Simple.pm' => 'lib/Simple.pm' },
151 xs_files => { 'Simple.xs' => 'lib/Simple.xs' },
154 $dist->add_file('Simple.xs', <<"---");
159 MODULE = Simple PACKAGE = Simple
164 RETVAL = newSVpv( "ok", 0 );
169 $dist->add_file( 'Simple.pm', <<"---" );
177 \@ISA = qw( Exporter DynaLoader );
178 \@EXPORT_OK = qw( okay );
180 bootstrap Simple \$VERSION;
188 Simple - Perl extension for blah blah blah
192 Stub documentation for Simple.
196 A. U. Thor, a.u.thor\@a.galaxy.far.far.away
200 $dist->change_file('t/basic.t', <<"---");
201 use Test::More tests => 2;
207 ok( Simple::okay() eq 'ok' );
211 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
214 $mb = Module::Build->new_from_context;
217 $mb->dispatch('build');
220 $mb->dispatch('test');
223 $mb->dispatch('realclean');
227 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";