contrib
debian
docs
i3-config-wizard
i3-dump-log
i3-input
i3-msg
i3-nagbar
i3bar
include
libi3
man
parser-specs
src
testcases
lib
t
000-load-deps.t
001-tile.t
002-i3-sync.t
003-ipc.t
004-unmanaged.t
005-floating.t
100-fullscreen.t
101-focus.t
102-dock.t
103-move.t
104-focus-stack.t
105-stacking.t
111-goto.t
112-floating-resize.t
113-urgent.t
114-client-leader.t
115-ipc-workspaces.t
116-nestedcons.t
117-workspace.t
118-openkill.t
119-match.t
120-multiple-cmds.t
121-next-prev.t
122-split.t
124-move.t
126-regress-close.t
127-regress-floating-parent.t
128-open-order.t
129-focus-after-close.t
130-close-empty-split.t
131-stacking-order.t
132-move-workspace.t
133-size-hints.t
134-invalid-command.t
135-floating-focus.t
136-floating-ws-empty.t
137-floating-unmap.t
138-floating-attach.t
139-ws-numbers.t
140-focus-lost.t
141-resize.t
142-regress-move-floating.t
143-regress-floating-restart.t
144-regress-floating-resize.t
145-flattening.t
146-floating-reinsert.t
147-regress-floatingmove.t
148-regress-floatingmovews.t
150-regress-dock-restart.t
151-regress-float-size.t
152-regress-level-up.t
153-floating-originalsize.t
154-regress-multiple-dock.t
155-floating-split-size.t
156-fullscreen-focus.t
158-wm_take_focus.t
159-socketpaths.t
161-regress-borders-restart.t
162-regress-dock-urgent.t
163-wm-state.t
164-kill-win-vs-client.t
165-for_window.t
166-assign.t
167-workspace_layout.t
168-regress-fullscreen-restart.t
169-border-toggle.t
170-force_focus_wrapping.t
171-config-migrate.t
172-start-on-named-ws.t
173-get-marks.t
173-regress-focus-assign.t
174-border-config.t
174-regress-focus-toggle.t
175-startup-notification.t
176-workspace-baf.t
177-bar-config.t
178-regress-workspace-open.t
179-regress-multiple-ws.t
180-fd-leaks.t
181-regress-float-border.t
182-regress-focus-dock.t
183-config-variables.t
184-regress-float-split-resize.t
185-scratchpad.t
186-regress-assign-focus-parent.t
187-commands-parser.t
188-regress-focus-restart.t
189-floating-constraints.t
190-scratchpad-diff-ws.t
191-resize-levels.t
192-layout.t
193-ipc-version.t
194-regress-floating-size.t
195-net-active-window.t
196-randr-output-names.t
197-regression-move-vanish.t
198-regression-scratchpad-crash.t
199-ipc-mode-event.t
200-urgency-timer.t
201-config-parser.t
202-scratchpad-criteria.t
203-regress-assign-and-move.t
204-regress-scratchpad-move.t
205-ipc-windows.t
206-fullscreen-scratchpad.t
207-shmlog.t
208-regress-floating-criteria.t
209-ewmh-net-workarea.t
210-mark-unmark.t
211-regress-urgency-assign.t
212-assign-urgency.t
213-layout-restore-simple.t
213-move-branch-position.t
214-layout-restore-criteria.t
215-layout-restore-crash.t
216-layout-restore-split-swallows.t
217-NET_CURRENT_DESKTOP.t
218-regress-floating-split.t
219-ipc-window-focus.t
220-ipc-window-title.t
221-floating-type-hints.t
222-regress-dock-resize.t
223-net-client-list.t
224-regress-resize-branch.t
225-ipc-window-fullscreen.t
226-internal-workspaces.t
227-ipc-workspace-empty.t
228-border-widths.t
229-cleanup-tmpdir.t
230-floating-fullscreen-restart.t
231-ipc-floating-event.t
231-ipc-window-close.t
231-ipc-window-move.t
232-cmd-move-criteria.t
232-ipc-window-urgent.t
233-regress-manage-focus-unmapped.t
234-ewmh-desktop-names.t
234-layout-restore-output.t
234-regress-default-floating-border.t
235-check-config-no-x.t
235-wm-class-change-handler.t
236-floating-focus-raise.t
237-regress-assign-focus.t
238-ipc-binding-event.t
238-regress-reload-bindsym.t
239-net-close-window-request.t
240-focus-on-window-activation.t
240-tabbed-floating-disable-crash.t
241-consistent-center.t
242-no-focus.t
243-move-to-mark.t
243-net-wm-state-hidden.t
244-new-workspace-floating-enable-center.t
245-move-position-mouse.t
246-window-decoration-focus.t
247-config-line-continuation.t
248-regress-urgency-clear.t
249-layout-restore-floating.t
250-layout-restore-multiple-criteria.t
251-command-criteria-focused.t
251-ewmh-visible-name.t
251-sticky.t
252-floating-size.t
253-multiple-net-wm-state-atoms.t
254-move-to-output-with-criteria.t
255-multiple-marks.t
256-no-auto-back-and-forth.t
257-keypress-group1-fallback.t
258-keypress-release.t
259-net-wm-user-time.t
260-invalid-criteria.t
261-match-con_id-con_mark-combinations.t
262-config-validation.t
262-root-window-mouse-binding.t
500-multi-monitor.t
501-scratchpad.t
502-focus-output.t
503-workspace.t
504-move-workspace-to-output.t
505-scratchpad-resolution.t
506-focus-right.t
507-workspace-move-crash.t
509-workspace_layout.t
510-focus-across-outputs.t
511-scratchpad-configure-request.t
512-move-wraps.t
513-move-workspace.t
514-ipc-workspace-multi-monitor.t
515-create-workspace.t
516-move.t
517-regress-move-direction-ipc.t
518-interpret-workspace-numbers.t
519-mouse-warping.t
520-regress-focus-direction-floating.t
521-ewmh-desktop-viewport.t
522-rename-assigned-workspace.t
523-move-position-center.t
524-move.t
525-i3bar-mouse-bindings.t
526-reconfigure-dock.t
527-focus-fallback.t
528-workspace-next-prev.t
.gitignore
Makefile.PL
complete-run.pl
i3-test.config
new-test
restart-state.golden
valgrind.supp
.clang-format
.gitignore
.travis.yml
CONTRIBUTING.md
DEPENDS
LICENSE
Makefile
PACKAGE-MAINTAINER
RELEASE-NOTES-4.11
common.mk
generate-command-parser.pl
i3-dmenu-desktop
i3-migrate-config-to-v4
i3-save-tree
i3-sensible-editor
i3-sensible-pager
i3-sensible-terminal
i3-with-shmlog.xsession.desktop
i3.applications.desktop
i3.config
i3.config.keycodes
i3.xsession.desktop
logo.svg
pseudo-doc.doxygen
release.sh
This patch extends the previously introduced flag --no-auto-back-and-forth to also apply to move window to workspace <name> move window to workspace number <number> relates to #2028
229 lines
7.7 KiB
Raku
229 lines
7.7 KiB
Raku
#!perl
|
||
# vim:ts=4:sw=4:expandtab
|
||
#
|
||
# Please read the following documents before working on tests:
|
||
# • http://build.i3wm.org/docs/testsuite.html
|
||
# (or docs/testsuite)
|
||
#
|
||
# • http://build.i3wm.org/docs/lib-i3test.html
|
||
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
||
#
|
||
# • http://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 the standalone parser binary to see if it calls the right code when
|
||
# confronted with various commands, if it prints proper error messages for
|
||
# wrong commands and if it terminates in every case.
|
||
#
|
||
use i3test i3_autostart => 0;
|
||
|
||
sub parser_calls {
|
||
my ($command) = @_;
|
||
|
||
# TODO: use a timeout, so that we can error out if it doesn’t terminate
|
||
# TODO: better way of passing arguments
|
||
my $stdout = qx(../test.commands_parser '$command' 2>&1 >&-);
|
||
|
||
# Filter out all debugging output.
|
||
my @lines = split("\n", $stdout);
|
||
@lines = grep { not /^# / } @lines;
|
||
|
||
# The criteria management calls are irrelevant and not what we want to test
|
||
# in the first place.
|
||
@lines = grep { !(/cmd_criteria_init()/ || /cmd_criteria_match_windows/) } @lines;
|
||
return join("\n", @lines);
|
||
}
|
||
|
||
################################################################################
|
||
# 1: First that the parser properly recognizes commands which are ok.
|
||
################################################################################
|
||
|
||
# The first call has only a single command, the following ones are consolidated
|
||
# for performance.
|
||
is(parser_calls('move workspace 3'),
|
||
'cmd_move_con_to_workspace_name(3, (null))',
|
||
'single number (move workspace 3) ok');
|
||
|
||
is(parser_calls(
|
||
'move to workspace 3; ' .
|
||
'move window to workspace 3; ' .
|
||
'move container to workspace 3; ' .
|
||
'move workspace foobar; ' .
|
||
'move workspace torrent; ' .
|
||
'move workspace to output LVDS1; ' .
|
||
'move workspace 3: foobar; ' .
|
||
'move workspace "3: foobar"; ' .
|
||
'move workspace "3: foobar, baz"; '),
|
||
"cmd_move_con_to_workspace_name(3, (null))\n" .
|
||
"cmd_move_con_to_workspace_name(3, (null))\n" .
|
||
"cmd_move_con_to_workspace_name(3, (null))\n" .
|
||
"cmd_move_con_to_workspace_name(foobar, (null))\n" .
|
||
"cmd_move_con_to_workspace_name(torrent, (null))\n" .
|
||
"cmd_move_workspace_to_output(LVDS1)\n" .
|
||
"cmd_move_con_to_workspace_name(3: foobar, (null))\n" .
|
||
"cmd_move_con_to_workspace_name(3: foobar, (null))\n" .
|
||
"cmd_move_con_to_workspace_name(3: foobar, baz, (null))",
|
||
'move ok');
|
||
|
||
is(parser_calls('move workspace 3: foobar, nop foo'),
|
||
"cmd_move_con_to_workspace_name(3: foobar, (null))\n" .
|
||
"cmd_nop(foo)",
|
||
'multiple ops (move workspace 3: foobar, nop foo) ok');
|
||
|
||
is(parser_calls(
|
||
'exec i3-sensible-terminal; ' .
|
||
'exec --no-startup-id i3-sensible-terminal'),
|
||
"cmd_exec((null), i3-sensible-terminal)\n" .
|
||
"cmd_exec(--no-startup-id, i3-sensible-terminal)",
|
||
'exec ok');
|
||
|
||
is(parser_calls(
|
||
'resize shrink left; ' .
|
||
'resize shrink left 25 px; ' .
|
||
'resize shrink left 25 px or 33 ppt; ' .
|
||
'resize shrink left 25'),
|
||
"cmd_resize(shrink, left, 10, 10)\n" .
|
||
"cmd_resize(shrink, left, 25, 10)\n" .
|
||
"cmd_resize(shrink, left, 25, 33)\n" .
|
||
"cmd_resize(shrink, left, 25, 10)",
|
||
'simple resize ok');
|
||
|
||
is(parser_calls('resize shrink left 25 px or 33 ppt,'),
|
||
'cmd_resize(shrink, left, 25, 33)',
|
||
'trailing comma resize ok');
|
||
|
||
is(parser_calls('resize shrink left 25 px or 33 ppt;'),
|
||
'cmd_resize(shrink, left, 25, 33)',
|
||
'trailing semicolon resize ok');
|
||
|
||
is(parser_calls('[con_mark=yay] focus'),
|
||
"cmd_criteria_add(con_mark, yay)\n" .
|
||
"cmd_focus()",
|
||
'criteria focus ok');
|
||
|
||
is(parser_calls("[con_mark=yay con_mark=bar] focus"),
|
||
"cmd_criteria_add(con_mark, yay)\n" .
|
||
"cmd_criteria_add(con_mark, bar)\n" .
|
||
"cmd_focus()",
|
||
'criteria focus ok');
|
||
|
||
is(parser_calls("[con_mark=yay\tcon_mark=bar] focus"),
|
||
"cmd_criteria_add(con_mark, yay)\n" .
|
||
"cmd_criteria_add(con_mark, bar)\n" .
|
||
"cmd_focus()",
|
||
'criteria focus ok');
|
||
|
||
is(parser_calls("[con_mark=yay\tcon_mark=bar]\tfocus"),
|
||
"cmd_criteria_add(con_mark, yay)\n" .
|
||
"cmd_criteria_add(con_mark, bar)\n" .
|
||
"cmd_focus()",
|
||
'criteria focus ok');
|
||
|
||
is(parser_calls('[con_mark="yay"] focus'),
|
||
"cmd_criteria_add(con_mark, yay)\n" .
|
||
"cmd_focus()",
|
||
'quoted criteria focus ok');
|
||
|
||
# Make sure trailing whitespace is stripped off: While this is not an issue for
|
||
# commands being parsed due to the configuration, people might send IPC
|
||
# commands with leading or trailing newlines.
|
||
is(parser_calls("workspace test\n"),
|
||
'cmd_workspace_name(test, (null))',
|
||
'trailing whitespace stripped off ok');
|
||
|
||
is(parser_calls("\nworkspace test"),
|
||
'cmd_workspace_name(test, (null))',
|
||
'trailing whitespace stripped off ok');
|
||
|
||
################################################################################
|
||
# 2: Verify that the parser spits out the right error message on commands which
|
||
# are not ok.
|
||
################################################################################
|
||
|
||
is(parser_calls('unknown_literal'),
|
||
"ERROR: Expected one of these tokens: <end>, '[', " .
|
||
"'move', " .
|
||
"'exec', " .
|
||
"'exit', " .
|
||
"'restart', " .
|
||
"'reload', " .
|
||
"'shmlog', " .
|
||
"'debuglog', " .
|
||
"'border', " .
|
||
"'layout', " .
|
||
"'append_layout', " .
|
||
"'workspace', " .
|
||
"'focus', " .
|
||
"'kill', " .
|
||
"'open', " .
|
||
"'fullscreen', " .
|
||
"'sticky', " .
|
||
"'split', " .
|
||
"'floating', " .
|
||
"'mark', " .
|
||
"'unmark', " .
|
||
"'resize', " .
|
||
"'rename', " .
|
||
"'nop', " .
|
||
"'scratchpad', " .
|
||
"'title_format', " .
|
||
"'mode', " .
|
||
"'bar'\n" .
|
||
"ERROR: Your command: unknown_literal\n" .
|
||
"ERROR: ^^^^^^^^^^^^^^^",
|
||
'error for unknown literal ok');
|
||
|
||
is(parser_calls('move something to somewhere'),
|
||
"ERROR: Expected one of these tokens: 'window', 'container', 'to', '--no-auto-back-and-forth', 'workspace', 'output', 'mark', 'scratchpad', 'left', 'right', 'up', 'down', 'position', 'absolute'\n" .
|
||
"ERROR: Your command: move something to somewhere\n" .
|
||
"ERROR: ^^^^^^^^^^^^^^^^^^^^^^",
|
||
'error for unknown literal ok');
|
||
|
||
################################################################################
|
||
# 3: Verify that escaping works correctly
|
||
################################################################################
|
||
|
||
is(parser_calls('workspace "foo"'),
|
||
'cmd_workspace_name(foo, (null))',
|
||
'Command with simple double quotes ok');
|
||
|
||
is(parser_calls('workspace "foo'),
|
||
'cmd_workspace_name(foo, (null))',
|
||
'Command without ending double quotes ok');
|
||
|
||
is(parser_calls('workspace "foo \"bar"'),
|
||
'cmd_workspace_name(foo "bar, (null))',
|
||
'Command with escaped double quotes ok');
|
||
|
||
is(parser_calls('workspace "foo \\'),
|
||
'cmd_workspace_name(foo \\, (null))',
|
||
'Command with single backslash in the end ok');
|
||
|
||
is(parser_calls('workspace "foo\\\\bar"'),
|
||
'cmd_workspace_name(foo\\bar, (null))',
|
||
'Command with escaped backslashes ok');
|
||
|
||
is(parser_calls('workspace "foo\\\\\\"bar"'),
|
||
'cmd_workspace_name(foo\\"bar, (null))',
|
||
'Command with escaped double quotes after escaped backslashes ok');
|
||
|
||
################################################################################
|
||
# 4: Verify that resize commands with a "px or ppt"-construction are parsed
|
||
# correctly
|
||
################################################################################
|
||
|
||
is(parser_calls("resize shrink width 10 px or"),
|
||
"ERROR: Expected one of these tokens: <number>\n" .
|
||
"ERROR: Your command: resize shrink width 10 px or\n" .
|
||
"ERROR: ",
|
||
"error for resize command with incomplete 'or'-construction ok");
|
||
|
||
is(parser_calls("resize grow left 10 px or 20 ppt"),
|
||
"cmd_resize(grow, left, 10, 20)",
|
||
"resize command with 'or'-construction ok");
|
||
|
||
done_testing;
|