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 ensure_blib('Module::Build');
25 #########################
28 my $tmp = MBTest->tmpdir;
31 my $dist = DistGen->new( dir => $tmp, xs => 1 );
35 my $mb = Module::Build->new_from_context;
38 eval {$mb->dispatch('clean')};
41 eval {$mb->dispatch('build')};
45 # Make sure it actually works: that we can call methods in the XS module
47 # Unfortunately, We must do this is a subprocess because some OS will not
48 # release the handle on a dynamic lib until the attaching process terminates
50 ok $mb->run_perl_command(['-Mblib', '-M'.$dist->name, '-e1']);
52 like stdout_of( sub {$mb->run_perl_command([
53 '-Mblib', '-M'.$dist->name,
54 '-we', "print @{[$dist->name]}::okay()"])}), qr/ok$/;
56 like stdout_of( sub {$mb->run_perl_command([
57 '-Mblib', '-M'.$dist->name,
58 '-we', "print @{[$dist->name]}::version()"])}), qr/0.01$/;
60 like stdout_of( sub {$mb->run_perl_command([
61 '-Mblib', '-M'.$dist->name,
62 '-we', "print @{[$dist->name]}::xs_version()"])}), qr/0.01$/;
67 # Try again in a subprocess
68 eval {$mb->dispatch('clean')};
72 $mb->create_build_script;
73 my $script = $mb->build_script;
76 eval {$mb->run_perl_script($script)};
80 # We can't be verbose in the sub-test, because Test::Harness will
81 # think that the output is for the top-level test.
82 eval {$mb->dispatch('test')};
85 eval {$mb->dispatch('clean')};
90 skip( "skipping a Unixish-only tests", 1 )
91 unless $mb->is_unixish;
93 $mb->{config}->push(ld => "FOO=BAR ".$mb->config('ld'));
94 eval {$mb->dispatch('build')};
96 $mb->{config}->pop('ld');
99 eval {$mb->dispatch('realclean')};
102 # Make sure blib/ is gone after 'realclean'
110 ########################################
112 # Try a XS distro with a deep namespace
114 $dist = DistGen->new( name => 'Simple::With::Deep::Name',
115 dir => $tmp, xs => 1 );
119 $mb = Module::Build->new_from_context;
122 $mb->dispatch('build');
125 $mb->dispatch('test');
128 $mb->dispatch('realclean');
135 ########################################
137 # Try a XS distro using a flat directory structure
138 # and a 'dist_name' instead of a 'module_name'
140 $dist = DistGen->new( name => 'Dist-Name', dir => $tmp, xs => 1 );
142 $dist->remove_file('lib/Dist-Name.pm');
143 $dist->remove_file('lib/Dist-Name.xs');
145 $dist->change_build_pl
147 dist_name => 'Dist-Name',
148 dist_version_from => 'Simple.pm',
149 pm_files => { 'Simple.pm' => 'lib/Simple.pm' },
150 xs_files => { 'Simple.xs' => 'lib/Simple.xs' },
153 $dist->add_file('Simple.xs', <<"---");
158 MODULE = Simple PACKAGE = Simple
163 RETVAL = newSVpv( "ok", 0 );
168 $dist->add_file( 'Simple.pm', <<"---" );
176 \@ISA = qw( Exporter DynaLoader );
177 \@EXPORT_OK = qw( okay );
179 bootstrap Simple \$VERSION;
187 Simple - Perl extension for blah blah blah
191 Stub documentation for Simple.
195 A. U. Thor, a.u.thor\@a.galaxy.far.far.away
199 $dist->change_file('t/basic.t', <<"---");
200 use Test::More tests => 2;
206 ok( Simple::okay() eq 'ok' );
213 $mb = Module::Build->new_from_context;
216 $mb->dispatch('build');
219 $mb->dispatch('test');
222 $mb->dispatch('realclean');