X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=testcases%2Ft%2F171-config-migrate.t;h=136333278504972a3924b101960d3bcd42094eee;hb=7ad32fd2d1611056bd6b24b1f57791939c0f6772;hp=6efe607197ab23910968363816c29d0aa783d5d6;hpb=8d72a77c7a56fa788d29a54455c806f18e2a3fd5;p=i3%2Fi3 diff --git a/testcases/t/171-config-migrate.t b/testcases/t/171-config-migrate.t index 6efe6071..13633327 100644 --- a/testcases/t/171-config-migrate.t +++ b/testcases/t/171-config-migrate.t @@ -1,6 +1,19 @@ #!perl # vim:ts=4:sw=4:expandtab # +# Please read the following documents before working on tests: +# • https://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • https://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • https://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# # Tests if i3-migrate-config-to-v4 correctly migrates all config file # directives and commands # @@ -9,13 +22,6 @@ use Cwd qw(abs_path); use File::Temp qw(tempfile tempdir); use v5.10; -# reads in a whole file -sub slurp { - open my $fh, '<', shift; - local $/; - <$fh>; -} - sub migrate_config { my ($config) = @_; @@ -23,7 +29,7 @@ sub migrate_config { print $fh $config; close($fh); - my $cmd = "sh -c 'exec " . abs_path("../i3-migrate-config-to-v4") . " --v3 <$tmpfile'"; + my $cmd = "sh -c 'exec i3-migrate-config-to-v4 --v3 <$tmpfile'"; return [ split /\n/, qx($cmd) ]; } @@ -114,14 +120,15 @@ ok(line_exists($output, qr|^new_window none$|), 'new_window changed'); # check whether new_window's parameters get changed correctly ##################################################################### -$output = migrate_config('new_window bb'); -ok(line_exists($output, qr|^new_window none$|), 'new_window bb changed'); - -$output = migrate_config('new_window bn'); -ok(line_exists($output, qr|^new_window normal$|), 'new_window bn changed'); - -$output = migrate_config('new_window bp'); -ok(line_exists($output, qr|^new_window 1pixel$|), 'new_window bp changed'); +$input = <[0], qr|^new_window none$|, 'new_window bb changed'); +like($output->[1], qr|^new_window normal$|, 'new_window bn changed'); +like($output->[2], qr|^new_window 1pixel$|, 'new_window bp changed'); ##################################################################### # check that some commands remain untouched @@ -133,8 +140,6 @@ $input = <[0], qr|^#.*focus.*obsolete.*focus 3$|, 'focus [number] gone'); +like($output->[1], qr|^bindsym Mod1\+f focus floating$|, 'focus floating unchanged'); +like($output->[2], qr|^bindsym Mod1\+f focus tiling$|, 'focus tiling unchanged'); +like($output->[3], qr|^bindsym Mod1\+f focus mode_toggle$|, 'focus ft changed'); ##################################################################### # check whether resize's parameters get changed correctly ##################################################################### -$output = migrate_config('bindsym Mod1+f resize left +10'); -ok(line_exists($output, qr|^bindsym Mod1\+f resize grow left 10 px$|), 'resize left changed'); - -$output = migrate_config('bindsym Mod1+f resize top -20'); -ok(line_exists($output, qr|^bindsym Mod1\+f resize shrink up 20 px$|), 'resize top changed'); - -$output = migrate_config('bindsym Mod1+f resize right -20'); -ok(line_exists($output, qr|^bindsym Mod1\+f resize shrink right 20 px$|), 'resize right changed'); +$input = <[0], qr|^bindsym Mod1\+f resize grow left 10 px$|, 'resize left changed'); +like($output->[1], qr|^bindsym Mod1\+f resize shrink up 20 px$|, 'resize top changed'); +like($output->[2], qr|^bindsym Mod1\+f resize shrink right 20 px$|, 'resize right changed'); +like($output->[3], qr|^bindsym Mod1\+f resize grow down 23 px$|, 'resize bottom changed'); ##################################################################### # also resizing, but with indention this time ##################################################################### -$output = migrate_config("bindsym Mod1+f resize left \t +10"); -ok(line_exists($output, qr|^bindsym Mod1\+f resize grow left 10 px$|), 'resize left changed'); +like($output->[4], qr|^bindsym Mod1\+f resize grow left 10 px$|, 'resize left changed'); ##################################################################### # check whether jump's parameters get changed correctly ##################################################################### -$output = migrate_config('bindsym Mod1+f jump 3'); -ok(line_exists($output, qr|^#.*obsolete.*jump 3$|), 'jump to workspace removed'); - -$output = migrate_config('bindsym Mod1+f jump 3 4 5'); -ok(line_exists($output, qr|^#.*obsolete.*jump 3 4 5$|), 'jump to workspace + col/row removed'); - -$output = migrate_config('bindsym Mod1+f jump "XTerm"'); -ok(line_exists($output, qr|^bindsym Mod1\+f \[class="XTerm"\] focus$|), 'jump changed'); +$input = <[0], qr|^#.*obsolete.*jump 3$|, 'jump to workspace removed'); +like($output->[1], qr|^#.*obsolete.*jump 3 4 5$|, 'jump to workspace + col/row removed'); +like($output->[2], qr|^bindsym Mod1\+f \[class="XTerm"\] focus$|, 'jump changed'); +like($output->[3], qr|^bindsym Mod1\+f \[class="XTerm" title="irssi"\] focus$|, 'jump changed'); ##################################################################### # check whether workspace commands are handled correctly @@ -330,13 +336,13 @@ ok(line_exists($output, qr|^bindsym Mod1\+3 move container to workspace work|), ##################################################################### $output = migrate_config(''); -ok(line_exists($output, qr|bar {|), 'i3bar added'); +ok(line_exists($output, qr|bar \{|), 'i3bar added'); $output = migrate_config('workspace_bar enable'); -ok(line_exists($output, qr|bar {|), 'i3bar added'); +ok(line_exists($output, qr|bar \{|), 'i3bar added'); $output = migrate_config('workspace_bar no'); -ok(!line_exists($output, qr|bar {|), 'no i3bar added'); +ok(!line_exists($output, qr|bar \{|), 'no i3bar added'); ##################################################################### # check whether the mode command gets quotes