1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use File::Spec;
6use File::Basename;
7use Test::More;
8use File::Path qw(make_path remove_tree);
9use Test::CheckManifest;
10use Cwd;
11
12# create a directory and a file
13my $sub = Test::CheckManifest->can('_find_home');
14
15my $dir  = Cwd::realpath( File::Spec->catdir( dirname( __FILE__ ), '..' ) );
16my $file = File::Spec->catfile( $dir, 'MANIFEST' );
17
18my @dirs_one = File::Spec->splitdir( $dir );
19my @dirs_two = File::Spec->splitdir( $sub->( {} ) );
20is_deeply \@dirs_two, \@dirs_one, 'tmp_path => $0';
21
22my ($vol,$dirs,$file_one) = File::Spec->splitpath($file);
23
24my @dirs_three = File::Spec->splitdir( $sub->( {file => $file} ) );
25is_deeply \@dirs_three, \@dirs_one, 'file ' . $file;
26
27my @dirs_five = File::Spec->splitdir( $sub->( { dir  => $dir } )  );
28is_deeply \@dirs_five, \@dirs_one, 'dir ' . $dir;
29
30$sub->( { dir => $vol || '/' } );
31$sub->( { dir => '/this/dir/does/not/exist/test/checkmanifest' } );
32
33my $deep_path_one = File::Spec->catdir( $dir, 'deep' );
34my $deep_path_two = File::Spec->catdir( $deep_path_one, qw/path one and another level to search for/ );
35make_path $deep_path_two;
36$sub->( { dir => $deep_path_two } );
37remove_tree $deep_path_one;
38
39done_testing();
40