File: 01get_test_files.t

package info (click to toggle)
libtest-manifest-perl 1.23-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 120 kB
  • ctags: 9
  • sloc: perl: 140; makefile: 2
file content (80 lines) | stat: -rw-r--r-- 2,203 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
use strict;

use Test::More tests => 13;

use File::Copy qw(copy);
use File::Spec;

use Test::Manifest qw(get_t_files manifest_name);

copy( 'test_manifest', manifest_name() );

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
my $expected = join " ", map { File::Spec->catfile( "t", $_ ) } qw(
		00load.t 01get_test_files.t 01make_test_manifest.t
		leading_space.t trailing_space.t
		);

my @tests = split /\s+/, $expected;

my $string = get_t_files();

is( $string, $expected, "Single string version of tests is right" );

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
my @array = get_t_files();

foreach my $i ( 0 .. $#array )
	{
	is( $array[$i], $tests[$i], "Test file $i has expected name" );
	}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{
local $SIG{__WARN__} = sub { 1 };

if( $^O eq 'VMS' ) 	# http://perldoc.perl.org/perlvms.html#unlink-LIST
	{
	1 while ( unlink manifest_name() );
	} 
else 
	{
	unlink manifest_name();
	}

-e manifest_name() ? 
	fail( "test_manifest still around after unlink!") :
	pass( "test_manifest unlinked") ;

my $string = get_t_files();

ok( ! $string, "Nothing returned when test_manifest does not exist (scalar)" );

my @array = get_t_files();

ok( ! $string, "Nothing returned when test_manifest does not exist (list)" );
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{
local $Test::Harness::verbose = 1;
copy( 'test_manifest_levels', manifest_name() );

my @expected = ( [] );
$expected[1] = [ qw( 00load.t 01get_test_files.t pod_coverage.t) ];
$expected[2] = [ qw( 00load.t 01get_test_files.t 01make_test_manifest.t 
	pod_coverage.t ) ];
$expected[3] = [ qw( 00load.t 01get_test_files.t 01make_test_manifest.t 
	leading_space.t pod_coverage.t trailing_space.t ) ];
$expected[0] = [ qw( 00load.t 01get_test_files.t 01make_test_manifest.t 
	leading_space.t pod_coverage.t trailing_space.t 99pod.t ) ];
	
foreach my $level ( 0 .. 3 )
	{
	my $string = get_t_files( $level );
	my $expected = join ' ', map { File::Spec->catfile( 't', $_ ) } 
		@{ $expected[$level] };
	is( $string, $expected, "Level $level version of tests is right" );
	}

}