]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/171-config-migrate.t
tests: replace http:// with https:// where appropriate
[i3/i3] / testcases / t / 171-config-migrate.t
index f64d323995db8881ea081f429746266ec61b59f5..136333278504972a3924b101960d3bcd42094eee 100644 (file)
@@ -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 = <<EOT;
+    new_window bb
+    new_window bn
+    new_window bp
+EOT
+$output = migrate_config($input);
+like($output->[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 = <<EOT;
     bindsym Mod1+s restart
     bindsym Mod1+s reload
     bindsym Mod1+s exit
-    bindsym Mod1+s stack-limit cols 2
-    bindsym Mod1+s stack-limit rows 3
     bind Mod1+c exec /usr/bin/urxvt
     mode "asdf" {
         bind 36 mode default
@@ -147,10 +152,8 @@ ok(line_exists($output, qr|^bindsym Mod1\+s mark foo$|), 'mark unchanged');
 ok(line_exists($output, qr|^bindsym Mod1\+s restart$|), 'restart unchanged');
 ok(line_exists($output, qr|^bindsym Mod1\+s reload$|), 'reload unchanged');
 ok(line_exists($output, qr|^bindsym Mod1\+s exit$|), 'exit unchanged');
-ok(line_exists($output, qr|^bindsym Mod1\+s stack-limit cols 2$|), 'stack-limit unchanged');
-ok(line_exists($output, qr|^bindsym Mod1\+s stack-limit rows 3$|), 'stack-limit unchanged');
 ok(line_exists($output, qr|^bindcode Mod1\+c exec /usr/bin/urxvt$|), 'bind changed to bindcode');
-ok(line_exists($output, qr|^mode "asdf" {$|), 'mode asdf unchanged');
+ok(line_exists($output, qr|^mode "asdf" \{$|), 'mode asdf unchanged');
 ok(line_exists($output, qr|^bindcode 36 mode \"default\"$|), 'mode default unchanged');
 ok(line_exists($output, qr|^}$|), 'closing mode bracket still there');
 
@@ -194,7 +197,7 @@ EOT
 
 $output = migrate_config($input);
 ok(line_exists($output, qr|^bindsym Mod1\+s layout stacking$|), 's replaced');
-ok(line_exists($output, qr|^bindsym Mod1\+s layout default$|), 'd replaced');
+ok(line_exists($output, qr|^bindsym Mod1\+s layout toggle split$|), 'd replaced');
 ok(line_exists($output, qr|^bindsym Mod1\+s layout tabbed$|), 'T replaced');
 ok(line_exists($output, qr|^bindsym Mod1\+s fullscreen$|), 'f replaced');
 ok(line_exists($output, qr|^bindsym Mod1\+s fullscreen global$|), 'fg replaced');
@@ -232,56 +235,59 @@ ok(line_exists($output, qr|^bindsym Mod1\+s \[con_mark="foo"\] focus$|), 'goto r
 # check whether focus's parameters get changed correctly
 #####################################################################
 
-$output = migrate_config('bindsym Mod1+f focus 3');
-ok(line_exists($output, qr|^#.*focus.*obsolete.*focus 3$|), 'focus [number] gone');
-
-$output = migrate_config('bindsym Mod1+f focus floating');
-ok(line_exists($output, qr|^bindsym Mod1\+f focus floating$|), 'focus floating unchanged');
-
-$output = migrate_config('bindsym Mod1+f focus tiling');
-ok(line_exists($output, qr|^bindsym Mod1\+f focus tiling$|), 'focus tiling unchanged');
+$input = <<EOT;
+bindsym Mod1+f focus 3
+bindsym Mod1+f focus floating
+bindsym Mod1+f focus tiling
+bindsym Mod1+f focus ft
+EOT
 
-$output = migrate_config('bindsym Mod1+f focus ft');
-ok(line_exists($output, qr|^bindsym Mod1\+f focus mode_toggle$|), 'focus ft changed');
+$output = migrate_config($input);
+like($output->[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 = <<EOT;
+bindsym Mod1+f resize left +10
+bindsym Mod1+f resize top -20
+bindsym Mod1+f resize right -20
+bindsym Mod1+f resize bottom +23
+bindsym Mod1+f resize          left    \t +10
+EOT
 
-$output = migrate_config('bindsym Mod1+f resize bottom +23');
-ok(line_exists($output, qr|^bindsym Mod1\+f resize grow down 23 px$|), 'resize bottom changed');
+$output = migrate_config($input);
+like($output->[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 = <<EOT;
+bindsym Mod1+f jump 3
+bindsym Mod1+f jump 3 4 5
+bindsym Mod1+f jump "XTerm"
+bindsym Mod1+f jump "XTerm/irssi"
+EOT
 
-$output = migrate_config('bindsym Mod1+f jump "XTerm/irssi"');
-ok(line_exists($output, qr|^bindsym Mod1\+f \[class="XTerm" title="irssi"\] focus$|), 'jump changed');
+$output = migrate_config($input);
+like($output->[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
@@ -315,7 +321,7 @@ $output = migrate_config('bindsym Mod1+3 3');
 ok(line_exists($output, qr|^bindsym Mod1\+3 workspace 3|), 'workspace changed');
 
 $output = migrate_config('bindsym Mod1+3 m3');
-ok(line_exists($output, qr|^bindsym Mod1\+3 move workspace 3|), 'move workspace changed');
+ok(line_exists($output, qr|^bindsym Mod1\+3 move container to workspace 3|), 'move workspace changed');
 
 $input = <<EOT;
     workspace 3 work
@@ -323,20 +329,20 @@ $input = <<EOT;
 EOT
 $output = migrate_config($input);
 ok(!line_exists($output, qr|^workspace|), 'workspace name not present');
-ok(line_exists($output, qr|^bindsym Mod1\+3 move workspace work|), 'move to named workspace in bindings');
+ok(line_exists($output, qr|^bindsym Mod1\+3 move container to workspace work|), 'move to named workspace in bindings');
 
 #####################################################################
 # check whether an i3bar call is added if the workspace bar bar was enabled
 #####################################################################
 
 $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