To fix test with ports privsep, create temp file in /tmp.

This commit is contained in:
bluhm 2022-03-21 22:55:21 +00:00
parent c130d45e0d
commit 33ff18a3cd
2 changed files with 45 additions and 4 deletions

View File

@ -1,14 +1,17 @@
COMMENT = cryptographic CipherSaber encryption
DISTNAME = Crypt-CipherSaber-1.01
CATEGORIES = security
REVISION = 0
CATEGORIES = security
# Perl
PERMIT_PACKAGE = Yes
MODULES = cpan
PKG_ARCH = *
TEST_DEPENDS = devel/p5-Test-Warn
MODULES = cpan
TEST_DEPENDS = devel/p5-Test-Warn
PKG_ARCH = *
.include <bsd.port.mk>

View File

@ -0,0 +1,38 @@
Ports privsep does not allow to write into t directory.
Index: t/bigfile.t
--- t/bigfile.t.orig
+++ t/bigfile.t
@@ -1,25 +1,25 @@
#!perl -w
-BEGIN
-{
- chdir 't' if -d 't';
-}
-
use strict;
+use File::Temp qw(tempfile);
use Test::More tests => 2;
use_ok( 'Crypt::CipherSaber' );
+my ($fh, $filename) = tempfile(UNLINK => 1,
+ TEMPLATE => "/tmp/smiles.png.XXXXXXXXXX");
+chdir 't' or die "Couldn't chdir: $!";
+
my $cs = Crypt::CipherSaber->new( 'sdrawkcabsihtdaeR' );
open( INPUT, 'smiles.cs1' ) or die "Couldn't open: $!";
binmode(INPUT);
-open(OUTPUT, '> smiles.png') or die "Couldn't open: $!";
+open(OUTPUT, '>&', $fh) or die "Couldn't open: $!";
binmode(OUTPUT);
$cs->fh_crypt(\*INPUT, \*OUTPUT);
close INPUT;
close OUTPUT;
-open(TEST, 'smiles.png') or die "Couldn't open: $!";
+open(TEST, $filename) or die "Couldn't open: $!";
my $line = <TEST>;
like( $line, qr/PNG/, 'Encrypting a large file should not mangle it' );