From 1eb011aae12d60c07117a7a6a9b95a35f42eec5b Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 24 Sep 2011 16:28:21 +0100 Subject: [PATCH] tests: make sure to leave no tempfiles behind --- testcases/complete-run.pl | 2 +- testcases/t/59-socketpaths.t | 4 ++-- testcases/t/71-config-migrate.t | 2 +- testcases/t/lib/i3test.pm | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/testcases/complete-run.pl b/testcases/complete-run.pl index 3566d78b..52038b33 100755 --- a/testcases/complete-run.pl +++ b/testcases/complete-run.pl @@ -134,7 +134,7 @@ sub take_job { my $dont_start = (slurp($test) =~ /# !NO_I3_INSTANCE!/); my $logpath = "$outdir/i3-log-for-" . basename($test); - my ($fh, $tmpfile) = tempfile(); + my ($fh, $tmpfile) = tempfile('i3-run-cfg.XXXXXX', UNLINK => 1); say $fh $config; say $fh "ipc-socket /tmp/nested-$display"; close($fh); diff --git a/testcases/t/59-socketpaths.t b/testcases/t/59-socketpaths.t index 33350927..36c99087 100644 --- a/testcases/t/59-socketpaths.t +++ b/testcases/t/59-socketpaths.t @@ -18,7 +18,7 @@ my $i3_path = abs_path("../i3"); # default case: socket will be created in /tmp/i3-/ipc-socket. ##################################################################### -my ($fh, $tmpfile) = tempfile(); +my ($fh, $tmpfile) = tempfile('/tmp/i3-test-config.XXXXXX', UNLINK => 1); say $fh "# i3 config file (v4)"; say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; close($fh); @@ -67,7 +67,7 @@ my $tmpdir = tempdir(CLEANUP => 1); $socketpath = $tmpdir . "/config.sock"; ok(! -e $socketpath, "$socketpath does not exist yet"); -($fh, $tmpfile) = tempfile(); +($fh, $tmpfile) = tempfile('/tmp/i3-test-config.XXXXXX', UNLINK => 1); say $fh "# i3 config file (v4)"; say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; say $fh "ipc-socket $socketpath"; diff --git a/testcases/t/71-config-migrate.t b/testcases/t/71-config-migrate.t index 6b41f2c1..561538e5 100644 --- a/testcases/t/71-config-migrate.t +++ b/testcases/t/71-config-migrate.t @@ -23,7 +23,7 @@ sub slurp { sub migrate_config { my ($config) = @_; - my ($fh, $tmpfile) = tempfile(); + my ($fh, $tmpfile) = tempfile('/tmp/i3-migrate-cfg.XXXXXX', UNLINK => 1); print $fh $config; close($fh); diff --git a/testcases/t/lib/i3test.pm b/testcases/t/lib/i3test.pm index 2685d695..c890693c 100644 --- a/testcases/t/lib/i3test.pm +++ b/testcases/t/lib/i3test.pm @@ -382,6 +382,10 @@ sub exit_gracefully { if (!$exited) { kill(9, $pid) or die "could not kill i3"; } + + if ($socketpath =~ m,^/tmp/i3-test-socket-,) { + unlink($socketpath); + } } # Gets the socket path from the I3_SOCKET_PATH atom stored on the X11 root window