Blame SOURCES/Convert-ASN1-0.27-Use-temporary-output-files-for-tests.patch

5339e0
From db01806c94b109117683aecf4b1934f8ce2a3137 Mon Sep 17 00:00:00 2001
5339e0
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
5339e0
Date: Wed, 28 Aug 2019 10:31:26 +0200
5339e0
Subject: [PATCH] Use temporary output files for tests
5339e0
MIME-Version: 1.0
5339e0
Content-Type: text/plain; charset=UTF-8
5339e0
Content-Transfer-Encoding: 8bit
5339e0
5339e0
I need to run the tests from a read-only directory. The t/07io.t fails
5339e0
because it creates a file in ./t directory. This patch uses File::Temp
5339e0
for creating the writable file.
5339e0
5339e0
Signed-off-by: Petr Písař <ppisar@redhat.com>
5339e0
---
5339e0
 dist.ini |  1 +
5339e0
 t/07io.t | 11 ++++++-----
5339e0
 2 files changed, 7 insertions(+), 5 deletions(-)
5339e0
5339e0
diff --git a/dist.ini b/dist.ini
5339e0
index 167e3e2..6f2fb12 100644
5339e0
--- a/dist.ini
5339e0
+++ b/dist.ini
5339e0
@@ -23,6 +23,7 @@ directory = examples
5339e0
 [PodVersion]
5339e0
 
5339e0
 [Prereqs / TestRequires]
5339e0
+File::Temp   = 0
5339e0
 Test::More   = 0.90
5339e0
 Math::BigInt = 1.997
5339e0
 
5339e0
diff --git a/t/07io.t b/t/07io.t
5339e0
index 706cf51..cca31d7 100644
5339e0
--- a/t/07io.t
5339e0
+++ b/t/07io.t
5339e0
@@ -2,6 +2,7 @@
5339e0
 
5339e0
 use Convert::ASN1 qw(:io);
5339e0
 use IO::Socket;
5339e0
+use File::Temp ();
5339e0
 
5339e0
 print "1..11\n";
5339e0
 
5339e0
@@ -14,11 +15,11 @@ my  $result = pack("C*", 0x30, 0x3D, 0x04, 0x04, 0x46, 0x72, 0x65, 0x64,
5339e0
 			 0x73, 0x74, 0x04, 0x02, 0x6F, 0x66, 0x04, 0x07,
5339e0
 			 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x73);
5339e0
 
5339e0
-($file = $0) =~ s/t$/dat/;
5339e0
-open(OUT,"> $file");
5339e0
-asn_write(*OUT, $result);
5339e0
-asn_write(*OUT, $result);
5339e0
-close(OUT);
5339e0
+$fd = File::Temp->new('UNLINK' => 0);
5339e0
+$file = $fd->filename;
5339e0
+asn_write($fd, $result);
5339e0
+asn_write($fd, $result);
5339e0
+$fd->close;
5339e0
 
5339e0
 open(IN,"< $file");
5339e0
 sysread(IN,$buffer,1024);
5339e0
-- 
5339e0
2.21.0
5339e0