[exim-cvs] testsuite: provide cp() if File::Copy is too old.

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Exim Git Commits Mailing List
Date:  
À: exim-cvs
Sujet: [exim-cvs] testsuite: provide cp() if File::Copy is too old.
Gitweb: https://git.exim.org/exim.git/commitdiff/47bc7a521803eaea0d6666c327f2e21e22eb920b
Commit:     47bc7a521803eaea0d6666c327f2e21e22eb920b
Parent:     701b5a89766772fe78539ea157eebe9f5687e1e4
Author:     Heiko Schlittermann (HS12-RIPE) <hs@???>
AuthorDate: Thu Apr 1 11:33:01 2021 +0200
Committer:  Heiko Schlittermann (HS12-RIPE) <hs@???>
CommitDate: Thu Apr 1 11:34:20 2021 +0200


    testsuite: provide cp() if File::Copy is too old.
---
 test/lib/Exim/Utils.pm | 13 ++++++++++++-
 test/runtest           |  3 +--
 2 files changed, 13 insertions(+), 3 deletions(-)


diff --git a/test/lib/Exim/Utils.pm b/test/lib/Exim/Utils.pm
index b744b0b..1dbd2d0 100644
--- a/test/lib/Exim/Utils.pm
+++ b/test/lib/Exim/Utils.pm
@@ -2,8 +2,9 @@ package Exim::Utils;
use v5.10.1;
use strict;
use warnings;
+use File::Copy;
use parent 'Exporter';
-our @EXPORT_OK = qw(uniq numerically);
+our @EXPORT_OK = qw(uniq numerically cp);


sub uniq {
@@ -13,4 +14,14 @@ sub uniq {

sub numerically { $::a <=> $::b }

+sub cp {
+    if ($File::Copy::VERSION >= 2.15) { # since Perl 5.11 we should have >= 2.15
+        return File::Copy::cp(@_);
+    }
+    copy(@_) or return undef;
+    my ($src, $dst) = @_;
+    my @st = stat $src or return undef;
+    chmod($st[2]&07777, $dst);
+}
+
 1;
diff --git a/test/runtest b/test/runtest
index 64a1493..c9a07e0 100755
--- a/test/runtest
+++ b/test/runtest
@@ -29,11 +29,10 @@ use File::Basename;
 use Pod::Usage;
 use Getopt::Long;
 use FindBin qw'$RealBin';
-use File::Copy qw(cp);


use lib "$RealBin/lib";
use Exim::Runtest;
-use Exim::Utils qw(uniq numerically);
+use Exim::Utils qw(uniq numerically cp);

use if $ENV{DEBUG} && scalar($ENV{DEBUG} =~ /\bruntest\b/) => 'Smart::Comments' => '####';
use if $ENV{DEBUG} && scalar($ENV{DEBUG} =~ /\bruntest\b/) => 'Data::Dumper';