forked from RexOps/Rex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper_path.t
45 lines (35 loc) · 1.34 KB
/
helper_path.t
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
use strict;
use warnings;
use Test::More tests => 9;
use File::Basename;
use Cwd 'getcwd';
use_ok 'Rex::Helper::Path';
$::rexfile = "Rexfile";
$::rexfile = "Rexfile";
my $path =
Rex::Helper::Path::get_file_path( "files/foo.txt", "main", "Rexfile" );
ok( $path eq "./files/foo.txt", "got file path if called from Rexfile" );
my $cwd = getcwd;
$path =
Rex::Helper::Path::get_file_path( "$cwd/Makefile.PL", "main", "Rexfile" );
ok( $path eq "$cwd/Makefile.PL",
"got file path if called from Rexfile - absolute path" );
$path = Rex::Helper::Path::get_file_path( "files/foo.txt", "main",
"this/is/Rexfile" );
ok( $path eq "this/is/files/foo.txt",
"got file path if called Rexfile from other directory" );
$path = Rex::Helper::Path::get_file_path( "files/foo.txt", "main",
"/this/is/Rexfile" );
ok( $path eq "/this/is/files/foo.txt",
"got file path if called Rexfile from other directory (absolute)" );
$path = Rex::Helper::Path::get_file_path( "files/foo.txt", "File::Foo",
"lib/File/Foo/__module__.pm" );
ok(
$path eq "lib/File/Foo/files/foo.txt",
"got file path for File::Foo module"
);
$path = Rex::Helper::Path::get_tmp_file();
my ( $filename, $directory, $suffix ) = fileparse( $path, '.tmp' );
ok( defined $filename, 'Got temp filename' );
is( $suffix, '.tmp', 'Got filename with .tmp suffix' );
ok( defined $directory, 'Got temp directory' );