X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=testcases%2Ft%2F159-socketpaths.t;h=d21581d1fe9506b9f3c28bf517290e655752dcb8;hb=9c3ece56d20db392610ae3106d570ee47c5831e8;hp=cc54d5a980f7581bf8c2dbbaed39b1e4ecc50e0d;hpb=622b94f176c3a6959c13ca2162be673c7b8028c4;p=i3%2Fi3 diff --git a/testcases/t/159-socketpaths.t b/testcases/t/159-socketpaths.t index cc54d5a9..d21581d1 100644 --- a/testcases/t/159-socketpaths.t +++ b/testcases/t/159-socketpaths.t @@ -1,10 +1,24 @@ #!perl # vim:ts=4:sw=4:expandtab # +# Please read the following documents before working on tests: +# • http://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • http://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • http://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# # Tests if the various ipc_socket_path options are correctly handled # use i3test i3_autostart => 0; use File::Temp qw(tempfile tempdir); +use File::Basename; use POSIX qw(getuid); use v5.10; @@ -20,21 +34,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); -my @files_after = ; -@files_after = grep { !($_ ~~ @files_before) } @files_after; - -is(@files_after, 1, 'one new temp directory'); - +my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1); +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); @@ -49,7 +56,7 @@ ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet"); $ENV{XDG_RUNTIME_DIR} = $rtdir; -$pid = launch_with_config($config, dont_add_socket_path => 1); +$pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1); ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory"); $socketpath = "$rtdir/i3/ipc-socket." . $pid; @@ -71,7 +78,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 ipc-socket $socketpath EOT -$pid = launch_with_config($config, dont_add_socket_path => 1); +$pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1); ok(-S $socketpath, "file $socketpath exists and is a socket");