Commit 94c91f49 authored by Chris Lamb's avatar Chris Lamb 💬

Merge tag '0.026' into debian

Release 0.026

* tag '0.026':
  Release 0.026
  handlers/jar.pm: Reintroduce subroutine prototype on _jar_filename_cmp to fix ordering regression in .jar files.
  t/fixtures/jar/*: Add a testcase for jar file ordering and normalisation.
  t/fixtures.t: Check that output matches expected before comparing attributes to make it less confusing on failure.
  t/fixtures.t: Don't test whether inode number has changed either.
  t/fixtures.t: Add a lookup table for descriptions of stat(1) indices.
  bin/strip-nondeterminism: die if file does not exist (Closes: #800159)
  t/fixtures.t: Re-order @fixtures setup for global->specific ordering.
  t/fixtures.t: Re-add top-level "plan" call dropped in previous commit.
  t/fixtures.t: Align size check with atime, etc.
  t/fixtures.t: Make it clearer that we are checking for attributes
  t/fixtures.t: Add comment why we use a per-fixture temporary directory.
parents 77695662 10814d76
......@@ -59,6 +59,8 @@ $File::StripNondeterminism::clamp_time = $clamp_timestamp;
die $usage if @ARGV == 0;
for my $filename (@ARGV) {
die "$filename: Does not exist\n" unless -e $filename;
my $normalizer;
if (defined $filetype) {
$normalizer = File::StripNondeterminism::get_normalizer_by_name($filetype);
......
......@@ -33,7 +33,7 @@ use File::StripNondeterminism::handlers::zip;
our($VERSION, $canonical_time, $clamp_time);
$VERSION = '0.025'; # 0.025
$VERSION = '0.026'; # 0.026
sub _get_file_type {
my $file=shift;
......
......@@ -28,7 +28,7 @@ use File::StripNondeterminism::handlers::zip;
use File::StripNondeterminism::handlers::javadoc;
use File::StripNondeterminism::handlers::javaproperties;
sub _jar_filename_cmp {
sub _jar_filename_cmp($$) {
my ($a, $b) = @_;
# META-INF/ and META-INF/MANIFEST.MF are expected to be the first entries in the Zip archive.
return 0 if $a eq $b;
......
......@@ -29,12 +29,33 @@ use File::Temp qw(tempdir);
use File::StripNondeterminism;
use Test::More;
my @fixtures = glob('t/fixtures/*/*.in');
# perlfunc(1)
my %STAT = (
0 => "dev (device number of filesystem)",
# 1 => "ino (inode number)",
2 => "mode (file mode (type and permissions))",
3 => "nlink (number of hard links to the file)",
4 => "uid (numeric user ID of file's owner)",
5 => "gid (numeric group ID of file's owner)",
6 => "rdev (the device identifier; special files only)",
# 7 => "size (total size of file, in bytes)",
# 8 => "atime (last access time in seconds since the epoch)",
# 9 => "mtime (last modified time in seconds since the epoch)",
# 10 => "ctime (inode change time in seconds since the epoch)",
11 => "blksize (preferred I/O size in bytes for interacting with the file)",
12 => "blocks (actual number of system-specific blocks allocated on disk)",
);
$File::StripNondeterminism::canonical_time = 1423159771;
my @fixtures = glob('t/fixtures/*/*.in');
plan tests => scalar @fixtures;
foreach my $filename (@fixtures) {
# Use a temporary directory per fixture so we can check whether any
# extraneous files are leftover.
my $temp = tempdir( CLEANUP => 1 );
my $in = "$temp/" . basename($filename, '.in');
(my $out = $filename) =~ s/\.in$/.out/;
......@@ -48,18 +69,14 @@ foreach my $filename (@fixtures) {
my @stat_before = lstat $in;
$normalizer->($in) if defined $normalizer;
my @stat_after = lstat $in;
foreach (my $i = 0; $i < @stat_after; $i++) {
next if (
$i == 7 # size
|| $i == 8 # atime
|| $i == 9 # mtime
|| $i == 10 # ctime
);
is($stat_before[$i], $stat_after[$i], "$filename: stat[$i]");
}
ok(compare($in, $out) == 0, "Got expected output");
# Check that file attributes remain unchanged.
foreach my $i (sort keys %STAT) {
is($stat_before[$i], $stat_after[$i], "$filename: $STAT{$i}");
}
my @files = glob("$temp/*");
ok(scalar(@files) == 1, "Unexpected files leftover: " . join(" ", @files));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment