From efa1cada293d356d3c14913d3a0225c3012bb611 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 30 Jan 2012 15:51:48 +0000 Subject: [PATCH] tests: Make i3 create its temporary files in /tmp/i3-testsuite This behavior can be avoided by passing dont_create_temp_dir => 1 to launch_with_config (or activate_i3). This commit fixes t/159-socketpaths.t being flaky on non-systemd computers. --- testcases/lib/SocketActivation.pm | 4 ++++ testcases/lib/i3test.pm | 3 +++ testcases/t/159-socketpaths.t | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/testcases/lib/SocketActivation.pm b/testcases/lib/SocketActivation.pm index d09d33fb..8f52bddc 100644 --- a/testcases/lib/SocketActivation.pm +++ b/testcases/lib/SocketActivation.pm @@ -52,6 +52,10 @@ sub activate_i3 { $ENV{LISTEN_PID} = $$; $ENV{LISTEN_FDS} = 1; delete $ENV{DESKTOP_STARTUP_ID}; + unless ($args{dont_create_temp_dir}) { + $ENV{XDG_RUNTIME_DIR} = '/tmp/i3-testsuite/'; + mkdir $ENV{XDG_RUNTIME_DIR}; + } $ENV{DISPLAY} = $args{display}; $ENV{PATH} = join(':', '../i3-nagbar', diff --git a/testcases/lib/i3test.pm b/testcases/lib/i3test.pm index 09c66dc5..8204f842 100644 --- a/testcases/lib/i3test.pm +++ b/testcases/lib/i3test.pm @@ -513,6 +513,8 @@ sub launch_with_config { $tmp_socket_path = "/tmp/nested-$ENV{DISPLAY}"; + $args{dont_create_temp_dir} //= 0; + my ($fh, $tmpfile) = tempfile("i3-cfg-for-$ENV{TESTNAME}-XXXXX", UNLINK => 1); if ($config ne '-default') { @@ -540,6 +542,7 @@ sub launch_with_config { strace => $ENV{STRACE}, restart => $ENV{RESTART}, cv => $cv, + dont_create_temp_dir => $args{dont_create_temp_dir}, ); # force update of the cached socket path in lib/i3test diff --git a/testcases/t/159-socketpaths.t b/testcases/t/159-socketpaths.t index cc54d5a9..c63bbbc4 100644 --- a/testcases/t/159-socketpaths.t +++ b/testcases/t/159-socketpaths.t @@ -23,7 +23,7 @@ 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 $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; @@ -49,7 +49,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 +71,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"); -- 2.39.5