Skip to content

Commit 4aeec0b

Browse files
committed
Use Test::Util's &make-temp-file in UNIX socket tests
This deduplicates some temporary file logic. Basenames generated by this routine are rather long (around 70 characters), but being in $*TMPDIR, we can use a relative path to give us more wiggle room.
1 parent da7067f commit 4aeec0b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

S32-io/IO-Socket-INET-UNIX.t

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use v6;
2+
use lib $?FILE.IO.parent.sibling: 'packages/Test-Helpers/lib';
23
use Test;
4+
use Test::Util;
35

46
plan 8;
57

@@ -11,10 +13,9 @@ if $*DISTRO.is-win {
1113
my IO::Socket::INET:_ $server;
1214
my IO::Socket::INET:_ $client;
1315
my IO::Socket::INET:_ $accepted;
14-
my Str:D $host = "./test-$*PID-{(1..1_000).pick}.sock";
16+
my Str:D $host = ~make-temp-file.relative;
1517
my Str:D $sent = 'Hello, world!';
1618
my Str:_ $received;
17-
LEAVE $host.IO.unlink if $host.IO.e;
1819

1920
lives-ok {
2021
$server = IO::Socket::INET.listen: $host, 0, family => PF_UNIX;
@@ -40,6 +41,8 @@ if $*DISTRO.is-win {
4041
lives-ok {
4142
$server.close;
4243
}, 'can close TCP UNIX socket servers';
44+
45+
# Test::Util takes care of cleanup.
4346
}
4447

4548
# vim: expandtab shiftwidth=4

0 commit comments

Comments
 (0)