]> git.sur5r.net Git - i3/i3/blob - testcases/t/229-cleanup-tmpdir.t
delete ipc socket when exiting, cleanup tmpdir
[i3/i3] / testcases / t / 229-cleanup-tmpdir.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Makes sure i3 deletes its temporary directory when exiting.
18 # Ticket: #1253
19 # Bug still in: 4.7.2-186-g617afc6
20 use i3test i3_autostart => 0;
21 use File::Basename;
22
23 my $config = <<EOT;
24 # i3 config file (v4)
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
26 EOT
27
28 # ensure XDG_RUNTIME_DIR is not set
29 delete $ENV{XDG_RUNTIME_DIR};
30
31 my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
32 my $socketpath = get_socket_path(0);
33 my $tmpdir = dirname($socketpath);
34
35 ok(-d $tmpdir, "tmpdir $tmpdir exists");
36
37 # Clear the error logfile. The testsuite runs in an environment where RandR is
38 # not supported, so there always is a message about xinerama in the error
39 # logfile.
40 my @errorlogfiles = <$tmpdir/errorlog.*>;
41 for my $fn (@errorlogfiles) {
42     open(my $fh, '>', $fn);
43     close($fh);
44 }
45
46 exit_gracefully($pid);
47
48 ok(! -d $tmpdir, "tmpdir $tmpdir was cleaned up");
49 if (-d $tmpdir) {
50     diag('contents = ' . Dumper(<$tmpdir/*>));
51 }
52
53 done_testing;