From 7ed2f6e55d9b145169b9e2c020daceb15996c3a2 Mon Sep 17 00:00:00 2001 From: Patrick Hilhorst Date: Fri, 19 Nov 2021 21:21:20 +0100 Subject: [PATCH] nixos/tests/vscodium{,-wayland}: merge tests --- nixos/tests/all-tests.nix | 2 +- nixos/tests/vscodium-wayland.nix | 54 -------------------- nixos/tests/vscodium.nix | 86 +++++++++++++++++++------------- 3 files changed, 51 insertions(+), 91 deletions(-) delete mode 100644 nixos/tests/vscodium-wayland.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index cd13183ed0a3..b8219416dc42 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -489,7 +489,7 @@ in victoriametrics = handleTest ./victoriametrics.nix {}; vikunja = handleTest ./vikunja.nix {}; virtualbox = handleTestOn ["x86_64-linux"] ./virtualbox.nix {}; - vscodium = handleTest ./vscodium.nix {}; + vscodium = discoverTests (import ./vscodium.nix); wasabibackend = handleTest ./wasabibackend.nix {}; wiki-js = handleTest ./wiki-js.nix {}; wireguard = handleTest ./wireguard {}; diff --git a/nixos/tests/vscodium-wayland.nix b/nixos/tests/vscodium-wayland.nix deleted file mode 100644 index 1321c8b98274..000000000000 --- a/nixos/tests/vscodium-wayland.nix +++ /dev/null @@ -1,54 +0,0 @@ -import ./make-test-python.nix ({ pkgs, ...} : - -{ - name = "vscodium-wayland"; - meta = with pkgs.lib.maintainers; { - maintainers = [ synthetica ]; - }; - - machine = { ... }: - - { - imports = [ - ./common/wayland-cage.nix - ]; - - services.cage.program = '' - ${pkgs.vscodium}/bin/codium \ - --enable-features=UseOzonePlatform \ - --ozone-platform=wayland - ''; - - fonts.fonts = with pkgs; [ - dejavu_fonts - ]; - }; - - enableOCR = true; - - testScript = { nodes, ... }: '' - start_all() - machine.wait_for_unit('graphical.target') - machine.wait_until_succeeds('pgrep -x codium') - - machine.wait_for_text('VSCodium') - machine.screenshot('start_screen') - - test_string = 'testfile' - - machine.send_key('ctrl-n') - machine.wait_for_text('Untitled') - machine.screenshot('empty_editor') - - machine.send_chars(test_string) - machine.wait_for_text(test_string) - machine.screenshot('editor') - - machine.send_key('ctrl-s') - machine.wait_for_text('Save') - machine.screenshot('save_window') - - machine.send_key('ret') - machine.wait_for_file(f'/home/alice/{test_string}') - ''; -}) diff --git a/nixos/tests/vscodium.nix b/nixos/tests/vscodium.nix index 033090aa0e3d..e217c1ec80f9 100644 --- a/nixos/tests/vscodium.nix +++ b/nixos/tests/vscodium.nix @@ -1,47 +1,61 @@ -import ./make-test-python.nix ({ pkgs, ...} : +let + tests = { + vscodium-wayland = { pkgs, ... }: { + imports = [ ./common/wayland-cage.nix ]; -{ - name = "vscodium"; - meta = with pkgs.lib.maintainers; { - maintainers = [ turion ]; + services.cage.program = '' + ${pkgs.vscodium}/bin/codium \ + --enable-features=UseOzonePlatform \ + --ozone-platform=wayland + ''; + + fonts.fonts = with pkgs; [ dejavu_fonts ]; + }; + vscodium-xorg = { pkgs, ... }: { + imports = [ ./common/user-account.nix ./common/x11.nix ]; + + virtualisation.memorySize = 2047; + services.xserver.enable = true; + services.xserver.displayManager.sessionCommands = '' + ${pkgs.vscodium}/bin/codium + ''; + test-support.displayManager.auto.user = "alice"; + }; }; - machine = { ... }: + mkTest = name: machine: + import ./make-test-python.nix ({ pkgs, ... }: { + inherit name machine; + meta = with pkgs.lib.maintainers; { + maintainers = [ synthetica turion ]; + }; + enableOCR = true; + testScript = '' + start_all() - { - imports = [ - ./common/user-account.nix - ./common/x11.nix - ]; + machine.wait_for_unit('graphical.target') + machine.wait_until_succeeds('pgrep -x codium') - virtualisation.memorySize = 2047; - services.xserver.enable = true; - test-support.displayManager.auto.user = "alice"; - environment.systemPackages = with pkgs; [ - vscodium - ]; - }; + machine.wait_for_text('VSCodium') + machine.screenshot('start_screen') - enableOCR = true; + test_string = 'testfile' - testScript = { nodes, ... }: '' - # Start up X - start_all() - machine.wait_for_x() + machine.send_key('ctrl-n') + machine.wait_for_text('Untitled') + machine.screenshot('empty_editor') - # Start VSCodium with a file that doesn't exist yet - machine.fail("ls /home/alice/foo.txt") - machine.succeed("su - alice -c 'codium foo.txt' >&2 &") + machine.send_chars(test_string) + machine.wait_for_text(test_string) + machine.screenshot('editor') - # Wait for the window to appear - machine.wait_for_text("VSCodium") + machine.send_key('ctrl-s') + machine.wait_for_text('Save') + machine.screenshot('save_window') - # Save file - machine.send_key("ctrl-s") + machine.send_key('ret') + machine.wait_for_file(f'/home/alice/{test_string}') + ''; + }); - # Wait until the file has been saved - machine.wait_for_file("/home/alice/foo.txt") - - machine.screenshot("VSCodium") - ''; -}) +in builtins.mapAttrs (k: v: mkTest k v { }) tests