File: Build.pm

package info (click to toggle)
libtest-prereq-perl 1.038-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 176 kB
  • ctags: 22
  • sloc: perl: 313; makefile: 4
file content (113 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package Test::Prereq::Build;
use strict;

use base qw(Test::Prereq);
use vars qw($VERSION @EXPORT);

use warnings;
no warnings;

=encoding utf8

=head1 NAME

Test::Prereq::Build - test prerequisites in Module::Build scripts

=head1 SYNOPSIS

   use Test::Prereq::Build;
   prereq_ok();

=cut

$VERSION = '1.038';

use Module::Build;
use Test::Builder;

my $Test = Test::Builder->new;

=head1 METHODS

If you have problems, send me your F<Build.PL>.

This module overrides methods in C<Test::Prereq> to make it work with
C<Module::Build>.

This module does not have any public methods. See L<Test::Prereq>.

To make everything work out with C<Module::Build>, this module overrides
some methods to do nothing.

=over 4

=item create_build_script

=item add_build_element

=item args

=item notes

=back

=head1 AUTHOR

brian d foy, C<< <bdfoy@cpan.org> >>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2002-2014 brian d foy.  All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut


sub import 
	{
	my $self   = shift;
	my $caller = caller;
	no strict 'refs';
	*{$caller.'::prereq_ok'}       = \&prereq_ok;
	
	$Test->exported_to($caller);
	$Test->plan(@_);
	}

sub prereq_ok
	{
	$Test->plan( tests => 1 ) unless $Test->has_plan;
	__PACKAGE__->_prereq_check( @_ );
	}

sub _master_file { 'Build.PL' }

# override Module::Build
sub Module::Build::new
	{
	my $class = shift;

	my %hash = @_;

	my @requires = sort grep $_ ne 'perl', (
		keys %{ $hash{requires} },
		keys %{ $hash{build_requires} },
		keys %{ $hash{configure_requires} },
		keys %{ $hash{recommends} },
		);

	@Test::Prereq::prereqs = @requires;

	# intercept further calls to this object
	return bless {}, __PACKAGE__;
	}

# fake Module::Build methods
sub create_build_script { 1 };
sub add_build_element { 1 };
sub args { 1 };
sub notes { 1 };

1;