File: 90-rt104560.t

package info (click to toggle)
libpar-packer-perl 1.064-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,388 kB
  • sloc: perl: 12,774; ansic: 1,474; makefile: 30; sh: 5
file content (40 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download | duplicates (5)
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::Functions;
use File::Temp qw( tempdir );
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );;

use Test::More;
require "./t/utils.pl";

plan tests => 3;

$ENV{PAR_TMPDIR} = tempdir(TMPDIR => 1, CLEANUP => 1);
my $tmpfile1 = catfile($ENV{PAR_TMPDIR}, 'check1.txt');
my $tmpdir1  = catdir($ENV{PAR_TMPDIR}, 'checkdir1');
my $tmpfile2 = catfile($tmpdir1,  'check2.txt');

mkdir $tmpdir1;
foreach my $file ($tmpfile1, $tmpfile2) {
    open my $fh, '>', $file or die "Cannot open $file to write to";
    print $fh "this is $file\n\n";  #  contents don't matter for this test
    close $fh;
}

my $exe = pp_ok(-a => "$tmpfile1;check1.txt",
                -a => "$tmpdir1;checkdir1",
                -e => "print q[regression test for rt104560]");

my $zip = Archive::Zip->new();
$zip->read($exe) == AZ_OK 
    or die qq[can't open zip file "$exe"];
my $manifest = $zip->contents("MANIFEST")
    or die qq[can't read MANIFEST member];
# NOTE: Don't use like() below: early versions of Perl 5.8.x (x < 9)
# have a bug with the /m qualifier on compiled regexes that makes
# the test fail though $manifest is OK.
ok($manifest =~ m{^check1\.txt$}m,           "MANIFEST lists check1.txt");
ok($manifest =~ m{^checkdir1/check2\.txt$}m, "MANIFEST lists checkdir1/check2.txt");