File: 27_build_requires_and_include.t

package info (click to toggle)
libmodule-install-perl 1.21-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 636 kB
  • sloc: perl: 3,569; makefile: 13
file content (71 lines) | stat: -rw-r--r-- 1,855 bytes parent folder | download | duplicates (3)
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
use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More;
use File::Spec;
use YAML::Tiny;
use lib 't/lib';
use MyTest;

plan tests => 14;

SCOPE: {  # see if test_requires works correctly
	ok( create_dist('Foo', { 'Makefile.PL' => <<"END_DSL" }), 'create_dist' );
use strict;
use warnings;
use inc::Module::Install 0.81;
name          'Foo';
perl_version  '5.005';
all_from      'lib/Foo.pm';

test_requires 'Test::More' => 9999;

WriteAll;
END_DSL
	ok( build_dist, 'build dist' );
	my $meta_yml = file('META.yml');
	ok(-f $meta_yml, 'has META.yml');

	my $meta = YAML::Tiny::LoadFile($meta_yml);
	ok $meta->{build_requires}{'Test::More'}, 'Test::More is listed in build_requires';

	my $makefile = makefile();
	ok(-f $makefile, 'has Makefile');

	my $content = _read($makefile);
	ok($content =~ /^#\s+(PREREQ_PM|BUILD_REQUIRES)\s*=>\s*{[^}]+Test::More=>q\[9999\]/m, 'Test::More is listed in PREREQ_PM|BUILD_REQUIRES in Makefile');

	ok( kill_dist(), 'kill_dist' );
}

SCOPE: {  # include removes Test::More from the build_requires in META.yml
	ok( create_dist('Foo', { 'Makefile.PL' => <<"END_DSL" }), 'create_dist' );
use strict;
use warnings;
use inc::Module::Install 0.81;
name          'Foo';
perl_version  '5.005';
all_from      'lib/Foo.pm';

test_requires 'Test::More' => 9999;
include 'Test::More';

WriteAll;
END_DSL
	ok( build_dist, 'build dist' );
	my $meta_yml = file('META.yml');
	ok(-f $meta_yml, 'has META.yml');

	my $meta = YAML::Tiny::LoadFile($meta_yml);
	ok !$meta->{build_requires}{'Test::More'}, 'Test::More is not listed in build_requires';

	my $makefile = makefile();
	ok(-f $makefile, 'has Makefile');

	my $content = _read($makefile);
	ok($content !~ /^#\s+(PREREQ_PM|BUILD_REQUIRES)\s*=>\s*{[^}]+Test::More=>q\[9999\]/m, 'Test::More is not listed in PREREQ_PM|BUILD_REQUIRES in Makefile');
	ok( kill_dist(), 'kill_dist' );
}