2 # vim:ts=4:sw=4:expandtab
4 # Tests whether we can switch to a non-existant workspace
5 # (necessary for further tests)
7 use Test::More tests => 2;
8 use List::MoreUtils qw(all none);
11 use File::Temp qw(tmpnam);
14 my $i3 = i3("/tmp/nestedcons");
16 sub get_workspace_names {
17 my $tree = $i3->get_workspaces->recv;
18 my @workspaces = map { @{$_->{nodes}} } @{$tree->{nodes}};
19 [ map { $_->{name} } @workspaces ]
22 sub workspace_exists {
24 ($name ~~ @{get_workspace_names()})
27 sub get_unused_workspace {
28 my @names = get_workspace_names();
30 do { $tmp = tmpnam() } while ($tmp ~~ @names);
34 my $tmp = get_unused_workspace();
35 diag("Temporary workspace name: $tmp\n");
37 $i3->command("workspace $tmp")->recv;
38 ok(workspace_exists($tmp), 'workspace created');
40 my $otmp = get_unused_workspace();
41 diag("Other temporary workspace name: $otmp\n");
43 # As the old workspace was empty, it should get
44 # cleaned up as we switch away from it
45 $i3->command("workspace $otmp")->recv;
46 ok(!workspace_exists($tmp), 'old workspace cleaned up');
48 diag( "Testing i3, Perl $], $^X" );