]> git.sur5r.net Git - i3/i3/blob - testcases/t/229-cleanup-tmpdir.t
Merge branch 'next'
[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 $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
54 $socketpath = get_socket_path(0);
55 $tmpdir = dirname($socketpath);
56
57 ok(-d $tmpdir, "tmpdir $tmpdir exists");
58
59 # Clear the error logfile. The testsuite runs in an environment where RandR is
60 # not supported, so there always is a message about xinerama in the error
61 # logfile.
62 @errorlogfiles = <$tmpdir/errorlog.*>;
63 for my $fn (@errorlogfiles) {
64     open(my $fh, '>', $fn);
65     close($fh);
66 }
67
68 diag('socket path before restarting is ' . $socketpath);
69
70 cmd 'restart';
71
72 # The socket path will be different, and we use that for checking whether i3 has restarted yet.
73 while (get_socket_path(0) eq $socketpath) {
74     sleep 0.1;
75 }
76
77 my $new_tmpdir = dirname(get_socket_path());
78
79 does_i3_live;
80
81 # Clear the error logfile. The testsuite runs in an environment where RandR is
82 # not supported, so there always is a message about xinerama in the error
83 # logfile.
84 @errorlogfiles = <$new_tmpdir/errorlog.*>;
85 for my $fn (@errorlogfiles) {
86     open(my $fh, '>', $fn);
87     close($fh);
88 }
89
90 exit_gracefully($pid);
91
92 ok(! -d $tmpdir, "old tmpdir $tmpdir was cleaned up");
93 if (-d $tmpdir) {
94     diag('contents = ' . Dumper(<$tmpdir/*>));
95 }
96
97 ok(! -d $new_tmpdir, "new tmpdir $new_tmpdir was cleaned up");
98 if (-d $new_tmpdir) {
99     diag('contents = ' . Dumper(<$new_tmpdir/*>));
100 }
101
102
103 done_testing;