wip: tests
Some checks failed
Nix / check-zig-cache-hash (push) Has been cancelled
Test / test (push) Has been cancelled
Test / prettier (push) Has been cancelled
Test / alejandra (push) Has been cancelled
Test / typos (push) Has been cancelled
Test / translations (push) Has been cancelled
Nix / Required Checks: Nix (push) Has been cancelled
Test / Required Checks: Test (push) Has been cancelled
Test / build-bench (push) Has been cancelled
Test / build-flatpak (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / build-linux-libghostty (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / build-macos (push) Has been cancelled
Test / build-macos-matrix (push) Has been cancelled
Test / build-snap (namespace-profile-ghostty-snap) (push) Has been cancelled
Test / build-snap (namespace-profile-ghostty-snap-arm64) (push) Has been cancelled
Test / build-windows (push) Has been cancelled
Test / build-windows-cross (namespace-profile-ghostty-md, x86-windows-gnu) (push) Has been cancelled
Test / build-windows-cross (namespace-profile-ghostty-md, x86_64-windows-gnu) (push) Has been cancelled
Test / GTK x11=${{ matrix.x11 }} wayland=${{ matrix.wayland }} (false, false) (push) Has been cancelled
Test / GTK x11=${{ matrix.x11 }} wayland=${{ matrix.wayland }} (false, true) (push) Has been cancelled
Test / GTK x11=${{ matrix.x11 }} wayland=${{ matrix.wayland }} (true, false) (push) Has been cancelled
Test / GTK x11=${{ matrix.x11 }} wayland=${{ matrix.wayland }} (true, true) (push) Has been cancelled
Test / Build -Dsentry=${{ matrix.sentry }} (false) (push) Has been cancelled
Test / Build -Dsentry=${{ matrix.sentry }} (true) (push) Has been cancelled
Test / test-macos (push) Has been cancelled
Test / Test pkg/${{ matrix.pkg }} (wuffs) (push) Has been cancelled
Test / Test build on Debian 12 (push) Has been cancelled

Not meant for merging.
This commit is contained in:
Mitchell Hashimoto 2025-03-17 09:08:47 -07:00
parent 0f2f0ab69f
commit f9b7ba36d9
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
5 changed files with 185 additions and 9 deletions

View File

@ -47,6 +47,11 @@
system: let
pkgs-stable = nixpkgs-stable.legacyPackages.${system};
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
# These are all of our VM tests.
tests = import ./nix/tests/default.nix {
nixpkgs = pkgs-unstable;
};
in {
devShell.${system} = pkgs-stable.callPackage ./nix/devShell.nix {
zig = zig.packages.${system}."0.14.0";
@ -72,6 +77,8 @@
formatter.${system} = pkgs-stable.alejandra;
checks.${system} = tests;
apps.${system} = let
runVM = (
module: let
@ -91,15 +98,29 @@
program = "${program}";
}
);
in {
wayland-cinnamon = runVM ./nix/vm/wayland-cinnamon.nix;
wayland-gnome = runVM ./nix/vm/wayland-gnome.nix;
wayland-plasma6 = runVM ./nix/vm/wayland-plasma6.nix;
x11-cinnamon = runVM ./nix/vm/x11-cinnamon.nix;
x11-gnome = runVM ./nix/vm/x11-gnome.nix;
x11-plasma6 = runVM ./nix/vm/x11-plasma6.nix;
x11-xfce = runVM ./nix/vm/x11-xfce.nix;
};
in
{
wayland-cinnamon = runVM ./nix/vm/wayland-cinnamon.nix;
wayland-gnome = runVM ./nix/vm/wayland-gnome.nix;
wayland-plasma6 = runVM ./nix/vm/wayland-plasma6.nix;
x11-cinnamon = runVM ./nix/vm/x11-cinnamon.nix;
x11-gnome = runVM ./nix/vm/x11-gnome.nix;
x11-plasma6 = runVM ./nix/vm/x11-plasma6.nix;
x11-xfce = runVM ./nix/vm/x11-xfce.nix;
}
// (pkgs-stable.lib.mapAttrs' (
# This adds all of our VM tests as runnable apps that load
# the interactive driver (repl). We map all the names of the
# tests to "test-<name>" so its distinct from other apps.
name: value: {
name = "test-${name}";
value = {
type = "app";
program = pkgs-unstable.lib.getExe tests.${name}.driverInteractive;
};
}
)
tests);
}
# Our supported systems are the same supported systems as the Zig binaries.
) (builtins.attrNames zig.packages)

26
nix/tests/basic.nix Normal file
View File

@ -0,0 +1,26 @@
{
name = "basic";
nodes.machine = {
config,
pkgs,
...
}: {
users.users.alice = {
isNormalUser = true;
extraGroups = ["wheel"];
packages = with pkgs; [
firefox
(pkgs.callPackage ../package.nix {})
];
};
system.stateVersion = "24.11";
};
testScript = ''
machine.wait_for_unit("default.target")
machine.succeed("su -- alice -c 'which firefox'")
machine.fail("su -- root -c 'which firefox'")
'';
}

14
nix/tests/default.nix Normal file
View File

@ -0,0 +1,14 @@
{nixpkgs}: let
# mkTest does nothing special right now, its just a wrapper around
# runNixOSTest, but it could be extended in the future so I pulled it out.
mkTest = path:
nixpkgs.testers.runNixOSTest {
imports = [
path
];
};
in {
basic = mkTest ./basic.nix;
gnome = mkTest ./gnome.nix;
i3 = mkTest ./i3.nix;
}

56
nix/tests/gnome.nix Normal file
View File

@ -0,0 +1,56 @@
{
name = "gnome";
nodes.machine = {
config,
pkgs,
...
}: {
users.users.alice = {
isNormalUser = true;
password = "alice";
extraGroups = ["wheel"];
packages = with pkgs; [
(pkgs.callPackage ../package.nix {})
];
};
services.xserver.enable = true;
services.xserver.displayManager = {
gdm.enable = true;
gdm.debug = true;
};
services.displayManager.autoLogin = {
enable = true;
user = "alice";
};
services.xserver.desktopManager.gnome.enable = true;
services.xserver.desktopManager.gnome.debug = true;
systemd.user.services = {
"org.gnome.Shell@wayland" = {
serviceConfig = {
ExecStart = [
# Clear the list before overriding it.
""
# Eval API is now internal so Shell needs to run in unsafe mode.
# TODO: improve test driver so that it supports openqa-like manipulation
# that would allow us to drop this mess.
"${pkgs.gnome-shell}/bin/gnome-shell --unsafe-mode"
];
};
};
};
system.stateVersion = "24.11";
};
testScript = ''
machine.wait_for_unit("default.target")
machine.succeed("su -- alice -c 'which firefox'")
machine.fail("su -- root -c 'which firefox'")
'';
}

59
nix/tests/i3.nix Normal file
View File

@ -0,0 +1,59 @@
{
name = "gnome";
nodes.machine = {
config,
pkgs,
...
}: {
users.users.alice = {
isNormalUser = true;
password = "alice";
extraGroups = ["wheel"];
packages = with pkgs; [
(pkgs.callPackage ../package.nix {})
];
};
# We need an XDG portal for various applications to work properly,
# such as Flatpak applications.
xdg.portal = {
enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
config.common.default = "*";
};
services.xserver = {
enable = true;
xkb.layout = "us";
dpi = 220;
desktopManager = {
xterm.enable = false;
wallpaper.mode = "fill";
};
displayManager = {
defaultSession = "none+i3";
lightdm.enable = true;
};
windowManager = {
i3.enable = true;
};
};
services.displayManager.autoLogin = {
enable = true;
user = "alice";
};
system.stateVersion = "24.11";
};
testScript = ''
machine.wait_for_unit("default.target")
machine.succeed("su -- alice -c 'which firefox'")
machine.fail("su -- root -c 'which firefox'")
'';
}