Blame t/14_leading_separator.t
|
Packit |
0bf95d |
#!perl
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
# Test the bug-fix for the following bug:
|
|
Packit |
0bf95d |
# Buggy behaviour:
|
|
Packit |
0bf95d |
# Adding file or directory by absolute path results in leading separator
|
|
Packit |
0bf95d |
# being stored in member name.
|
|
Packit |
0bf95d |
# Expected behaviour:
|
|
Packit |
0bf95d |
# Discard leading separator
|
|
Packit |
0bf95d |
# Bug report: http://tech.groups.yahoo.com/group/perl-beginner/message/27085
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
use strict;
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
BEGIN {
|
|
Packit |
0bf95d |
$^W = 1;
|
|
Packit |
0bf95d |
}
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
use Test::More tests => 1;
|
|
Packit |
0bf95d |
use Archive::Zip;
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
use Cwd ();
|
|
Packit |
0bf95d |
use File::Spec ();
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
use lib 't';
|
|
Packit |
0bf95d |
use common;
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
my $file_relative_path = File::Spec->catfile(TESTDIR, 'file.txt');
|
|
Packit |
0bf95d |
open FH, ">$file_relative_path";
|
|
Packit |
0bf95d |
close FH;
|
|
Packit |
0bf95d |
my $file_absolute_path = File::Spec->rel2abs($file_relative_path);
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
my $az = Archive::Zip->new();
|
|
Packit |
0bf95d |
$az->addFile($file_absolute_path);
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
if ($^O eq 'MSWin32') {
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
# remove volume from absolute file path
|
|
Packit |
0bf95d |
my (undef, $directory_path, $current_directory) =
|
|
Packit |
0bf95d |
File::Spec->splitpath(Cwd::getcwd(), $file_relative_path);
|
|
Packit |
0bf95d |
$file_absolute_path =
|
|
Packit |
0bf95d |
File::Spec->catfile($directory_path, $current_directory,
|
|
Packit |
0bf95d |
$file_relative_path);
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
$file_absolute_path =~ s{\\}{/}g; # convert to Unix separators
|
|
Packit |
0bf95d |
}
|
|
Packit |
0bf95d |
|
|
Packit |
0bf95d |
# expect path without leading separator
|
|
Packit |
0bf95d |
(my $expected_member_name = $file_absolute_path) =~ s{^/}{};
|
|
Packit |
0bf95d |
my ($member_name) = $az->memberNames();
|
|
Packit |
0bf95d |
is($member_name, $expected_member_name, 'no leading separator');
|