From: Michael Stapelberg Date: Mon, 10 Sep 2012 11:29:50 +0000 (+0200) Subject: tests: move does_i3_live to i3test::Test X-Git-Tag: 4.3~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0626c637aad5eba82ff44eb25ba45f8a96ed82ad;p=i3%2Fi3 tests: move does_i3_live to i3test::Test --- diff --git a/testcases/lib/i3test.pm b/testcases/lib/i3test.pm index 86886de1..fe3b50c6 100644 --- a/testcases/lib/i3test.pm +++ b/testcases/lib/i3test.pm @@ -34,7 +34,6 @@ our @EXPORT = qw( get_dock_clients cmd sync_with_i3 - does_i3_live exit_gracefully workspace_exists focused_ws @@ -459,13 +458,6 @@ sub sync_with_i3 { }; } -sub does_i3_live { - my $tree = i3(get_socket_path())->get_tree->recv; - my @nodes = @{$tree->{nodes}}; - my $ok = (@nodes > 0); - $tester->ok($ok, 'i3 still lives'); - return $ok; -} # Tries to exit i3 gracefully (with the 'exit' cmd) or kills the PID if that fails sub exit_gracefully { diff --git a/testcases/lib/i3test/Test.pm b/testcases/lib/i3test/Test.pm index 4389971b..0253bc2d 100644 --- a/testcases/lib/i3test/Test.pm +++ b/testcases/lib/i3test/Test.pm @@ -6,6 +6,7 @@ use base 'Test::Builder::Module'; our @EXPORT = qw( is_num_children cmp_float + does_i3_live ); my $CLASS = __PACKAGE__; @@ -83,6 +84,22 @@ sub cmp_float { $tb->cmp_ok(abs($a - $b), '<', 1e-6, $name); } +=head2 does_i3_live + +Returns true if the layout tree can still be received from i3. + + # i3 used to crash on invalid commands in revision X + cmd 'invalid command'; + does_i3_live; + +=cut +sub does_i3_live { + my $tree = i3test::i3(i3test::get_socket_path())->get_tree->recv; + my @nodes = @{$tree->{nodes}}; + my $tb = $CLASS->builder; + $tb->ok((@nodes > 0), 'i3 still lives'); +} + =head1 AUTHOR Michael Stapelberg