File: get_prereqs.t

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 (63 lines) | stat: -rw-r--r-- 1,773 bytes parent folder | download | duplicates (4)
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
use strict;

use Test::More 0.95;

use Cwd;
use Test::Prereq;
use Test::Prereq::Build;

use lib qw(.);

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

subtest 'get_prereqs' => sub {
	my $cwd = cwd;
	chdir "testdir/build_pl" or warn "Could not change directory! $!";
	my $modules = Test::Prereq::Build->_get_prereqs();
	diag "Didn't find right modules!\nFound <@$modules>\n" unless
	is_deeply( 
		$modules, 
			[ 
			sort qw( Module::Build Module::CoreList Module::Info 
			Test::Builder Test::Builder::Tester Test::Manifest Test::More ) 
			],
		'Right modules for Build.PL'
		);
	chdir $cwd or warn "Could not reset dirctory! $!";
	};

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
subtest 'good_makefile' => sub {
	my $cwd = cwd;
	chdir "testdir/good_makefile" or warn "Could not change directory! $!";
	ok( -e 'Makefile.PL', 'Makefile.PL is in the current working directory' );
	my $modules = Test::Prereq->_get_prereqs();

	isa_ok( $modules, 'ARRAY' );

	diag "Didn't find right modules!\nFound <@$modules>\n" unless
		is_deeply( 
			$modules, 
				[ 
				sort qw( HTTP::Size XML::Twig Test::Output Test::Manifest ) 
				],
			'Right modules for Makefile.PL'
			);

	chdir $cwd or warn "Could not reset dirctory! $!";
	};

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
subtest 'bad_makefile' => sub {
	my $cwd = cwd;
	chdir "testdir/bad_makefile" or warn "Could not change directory! $!";
	diag( "You might see an error about loading a Makefile.PL. That's fine." );
	my $modules = Test::Prereq->_get_prereqs();

	my $okay = defined $modules ? 0 : 1;

	ok( $okay, 'Bad Makefile.PL fails in right way' );
	chdir $cwd or warn "Could not reset dirctory! $!";
	};

done_testing();