-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
nixosTests.sway: don't use ORC #238997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixosTests.sway: don't use ORC #238997
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,10 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { | |
| regular2 = foreground; | ||
| }; | ||
| }; | ||
|
|
||
| etc."gpg-agent.conf".text = '' | ||
| pinentry-timeout 86400 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be great if we could document this change (either here via a comment or via the commit message) - otherwise it might not be clear / obvious enough in the future. I also checked the man page but the timeout seems to come from pinentry-gnome3:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah I tried that but it didn't work with 0 (which was with the first value I tried), but I didn't retry with a large positive value... I'll investigate
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I tried this again and it just doesn't come up. Seems like the config file is really needed. |
||
| ''; | ||
| }; | ||
|
|
||
| fonts.fonts = [ pkgs.inconsolata ]; | ||
|
|
@@ -71,16 +75,53 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { | |
| virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ]; | ||
| }; | ||
|
|
||
| enableOCR = true; | ||
|
|
||
| testScript = { nodes, ... }: '' | ||
| import shlex | ||
| import json | ||
|
|
||
| q = shlex.quote | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, not sure about this but I can live with it. |
||
| NODE_GROUPS = ["nodes", "floating_nodes"] | ||
|
|
||
|
|
||
| def swaymsg(command: str = "", succeed=True, type="command"): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: A docstring would be nice (but the function is well readable so it's not required). |
||
| assert command != "" or type != "command", "Must specify command or type" | ||
| shell = q(f"swaymsg -t {q(type)} -- {q(command)}") | ||
| with machine.nested( | ||
| f"sending swaymsg {shell!r}" + " (allowed to fail)" * (not succeed) | ||
| ): | ||
| ret = (machine.succeed if succeed else machine.execute)( | ||
| f"su - alice -c {shell}" | ||
| ) | ||
|
|
||
| # execute also returns a status code, but disregard. | ||
| if not succeed: | ||
| _, ret = ret | ||
|
|
||
| if not succeed and not ret: | ||
| return None | ||
|
|
||
| parsed = json.loads(ret) | ||
| return parsed | ||
|
|
||
| def swaymsg(command: str, succeed=True): | ||
| with machine.nested(f"sending swaymsg {command!r}" + " (allowed to fail)" * (not succeed)): | ||
| (machine.succeed if succeed else machine.execute)( | ||
| f"su - alice -c {shlex.quote('swaymsg -- ' + command)}" | ||
| ) | ||
|
|
||
| def walk(tree): | ||
primeos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| yield tree | ||
| for group in NODE_GROUPS: | ||
| for node in tree.get(group, []): | ||
| yield from walk(node) | ||
|
|
||
|
|
||
| def wait_for_window(pattern): | ||
| def func(last_chance): | ||
| nodes = (node["name"] for node in walk(swaymsg(type="get_tree"))) | ||
|
|
||
| if last_chance: | ||
| nodes = list(nodes) | ||
| machine.log(f"Last call! Current list of windows: {nodes}") | ||
|
|
||
| return any(pattern in name for name in nodes) | ||
|
|
||
| retry(func) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how safe it is to rely on |
||
|
|
||
| start_all() | ||
| machine.wait_for_unit("multi-user.target") | ||
|
|
@@ -94,7 +135,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { | |
|
|
||
| # Test XWayland (foot does not support X): | ||
| swaymsg("exec WINIT_UNIX_BACKEND=x11 WAYLAND_DISPLAY=invalid alacritty") | ||
| machine.wait_for_text("alice@machine") | ||
| wait_for_window("alice@machine") | ||
| machine.send_chars("test-x11\n") | ||
| machine.wait_for_file("/tmp/test-x11-exit-ok") | ||
| print(machine.succeed("cat /tmp/test-x11.out")) | ||
|
|
@@ -106,7 +147,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { | |
| machine.send_key("alt-3") | ||
| machine.sleep(3) | ||
| machine.send_key("alt-ret") | ||
| machine.wait_for_text("alice@machine") | ||
| wait_for_window("alice@machine") | ||
| machine.send_chars("test-wayland\n") | ||
| machine.wait_for_file("/tmp/test-wayland-exit-ok") | ||
| print(machine.succeed("cat /tmp/test-wayland.out")) | ||
|
|
@@ -117,16 +158,24 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { | |
|
|
||
| # Test gpg-agent starting pinentry-gnome3 via D-Bus (tests if | ||
| # $WAYLAND_DISPLAY is correctly imported into the D-Bus user env): | ||
| swaymsg("exec gpg --no-tty --yes --quick-generate-key test") | ||
| swaymsg("exec mkdir -p ~/.gnupg") | ||
| swaymsg("exec cp /etc/gpg-agent.conf ~/.gnupg") | ||
|
Comment on lines
+161
to
+162
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a bit unfortunate but the package seems to use |
||
|
|
||
| swaymsg("exec DISPLAY=INVALID gpg --no-tty --yes --quick-generate-key test", succeed=False) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need the |
||
| machine.wait_until_succeeds("pgrep --exact gpg") | ||
| machine.wait_for_text("Passphrase") | ||
| wait_for_window("gpg") | ||
| machine.succeed("pgrep --exact gpg") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, it's fine but is this really useful again after waiting for the window (since we already ensured that the process is there before waiting for the window)? |
||
| machine.screenshot("gpg_pinentry") | ||
| machine.send_key("alt-shift-q") | ||
| machine.wait_until_fails("pgrep --exact gpg") | ||
|
|
||
| # Test swaynag: | ||
| def get_height(): | ||
| return [node['rect']['height'] for node in walk(swaymsg(type="get_tree")) if node['focused']][0] | ||
|
|
||
| before = get_height() | ||
| machine.send_key("alt-shift-e") | ||
| machine.wait_for_text("You pressed the exit shortcut.") | ||
| retry(lambda _: get_height() < before) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine but a bit of a weird test. Would seem better if we could use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't show up in the window list, this was the best thing I could think of. |
||
| machine.screenshot("sway_exit") | ||
|
|
||
| swaymsg("exec swaylock") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the entire foot config I think (unless we want to return to ORC? Not sure how common font rendering issues are vs. how finicky ORC is (doesn't work reliably in interactive mode, etc.))