]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/159-socketpaths.t
Kill windows between tests
[i3/i3] / testcases / t / 159-socketpaths.t
index c63bbbc4e12d6e8efa0cf31292c5b96a04809c7d..6c214d20b17ecb5ac0c5204860199462e9daa859 100644 (file)
@@ -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 = </tmp/i3-*>;
 my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
-my @files_after = </tmp/i3-*>;
-@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);
@@ -58,7 +65,7 @@ ok(-S $socketpath, "file $socketpath exists and is a socket");
 exit_gracefully($pid);
 
 #####################################################################
-# configuration file case: socket gets placed whereever we specify
+# configuration file case: socket gets placed wherever we specify
 #####################################################################
 
 my $tmpdir = tempdir(CLEANUP => 1);