From 19946ee14d2e4262165f05c717c59143e581db19 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 29 Jun 2012 21:21:07 +0200 Subject: [PATCH] tests: make t/159-socketpath more robust MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …by getting the socket path from i3 and then checking that it conforms to what we expect. Previously we monitored /tmp, which can go wrong in various ways, especially since i3’s directory within /tmp is not predictable (by design). --- testcases/t/159-socketpaths.t | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/testcases/t/159-socketpaths.t b/testcases/t/159-socketpaths.t index c63bbbc4..7c3946b4 100644 --- a/testcases/t/159-socketpaths.t +++ b/testcases/t/159-socketpaths.t @@ -5,6 +5,7 @@ # use i3test i3_autostart => 0; use File::Temp qw(tempfile tempdir); +use File::Basename; use POSIX qw(getuid); use v5.10; @@ -20,21 +21,14 @@ EOT # ensure XDG_RUNTIME_DIR is not set delete $ENV{XDG_RUNTIME_DIR}; -# See which files exist in /tmp before to not mistakenly check an already -# existing tmpdir of another i3 instance. -my @files_before = ; my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1); -my @files_after = ; -@files_after = grep { !($_ ~~ @files_before) } @files_after; - -is(@files_after, 1, 'one new temp directory'); - +my $socketpath = get_socket_path(0); my $folder = "/tmp/i3-" . getpwuid(getuid()); -like($files_after[0], qr/^$folder/, 'temp directory matches expected pattern'); -$folder = $files_after[0]; +like(dirname($socketpath), qr/^$folder/, 'temp directory matches expected pattern'); +$folder = dirname($socketpath); ok(-d $folder, "folder $folder exists"); -my $socketpath = "$folder/ipc-socket." . $pid; +$socketpath = "$folder/ipc-socket." . $pid; ok(-S $socketpath, "file $socketpath exists and is a socket"); exit_gracefully($pid); -- 2.39.5