File: 03_find_home.t

package info (click to toggle)
libtest-checkmanifest-perl 1.43-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: perl: 773; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,217 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use strict;
use warnings;
use File::Spec;
use File::Basename;
use Test::More;
use File::Path qw(make_path remove_tree);
use Test::CheckManifest;
use Cwd;

# create a directory and a file
my $sub = Test::CheckManifest->can('_find_home');
ok $sub;

my $dir  = Cwd::realpath( File::Spec->catdir( dirname( __FILE__ ), '..' ) );
my $file = File::Spec->catfile( $dir, 'MANIFEST' );

my @dirs_one = File::Spec->splitdir( $dir );
my @dirs_two = File::Spec->splitdir( $sub->( {} ) );
is_deeply \@dirs_two, \@dirs_one, 'tmp_path => $0';

my ($vol,$dirs,$file_one) = File::Spec->splitpath($file);

my @dirs_three = File::Spec->splitdir( $sub->( {file => $file} ) );
is_deeply \@dirs_three, \@dirs_one, 'file ' . $file;

my @dirs_five = File::Spec->splitdir( $sub->( { dir  => $dir } )  );
is_deeply \@dirs_five, \@dirs_one, 'dir ' . $dir;

$sub->( { dir => $vol || '/' } );
$sub->( { dir => '/this/dir/does/not/exist/test/checkmanifest' } );

my $deep_path_one = File::Spec->catdir( $dir, 'deep' );
my $deep_path_two = File::Spec->catdir( $deep_path_one, qw/path one and another level to search for/ );
make_path $deep_path_two;
$sub->( { dir => $deep_path_two } );
remove_tree $deep_path_one;

done_testing();