summaryrefslogtreecommitdiffstats
path: root/nixos/tests/wine.nix
blob: dfb6d2fd1f7c298f8775b11de3f26a193faa02d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
  pkgs,
  lib,
  runTest,
}:

let
  inherit (lib)
    concatMapStrings
    listToAttrs
    optionals
    optionalString
    ;

  hello32 = "${pkgs.pkgsCross.mingw32.hello}/bin/hello.exe";
  hello64 = "${pkgs.pkgsCross.mingwW64.hello}/bin/hello.exe";

  makeWineTest = packageSet: exes: variant: rec {
    name = "${packageSet}-${variant}";
    value = runTest {
      inherit name;
      meta = with lib.maintainers; {
        maintainers = [ chkno ];
      };

      nodes.machine =
        { pkgs, ... }:
        {
          environment.systemPackages = [ pkgs."${packageSet}"."${variant}" ];
          virtualisation.diskSize = 800;
        };

      testScript = ''
        machine.wait_for_unit("multi-user.target")
        ${concatMapStrings (
          exe:
          ''
            greeting = machine.succeed(
                "bash -c 'wine ${exe} 2> >(tee wine-stderr >&2)'"
            )
            assert 'Hello, world!' in greeting
          ''
          # only the full version contains Gecko, but the error is not printed reliably in other variants
          + optionalString (variant == "full") ''
            machine.fail(
                "fgrep 'Could not find Wine Gecko. HTML rendering will be disabled.' wine-stderr"
            )
          ''
        ) exes}
      '';
    };
  };

  variants = [
    "base"
    "full"
    "minimal"
    "staging"
    "unstable"
    "wayland"
  ];

in
listToAttrs (
  map (makeWineTest "winePackages" [ hello32 ]) variants
  ++ optionals pkgs.stdenv.hostPlatform.is64bit (
    map
      (makeWineTest "wineWow64Packages" [
        hello32
        hello64
      ])
      # This wayland combination times out after spending many hours.
      # https://hydra.nixos.org/job/nixos/trunk-combined/nixos.tests.wine.wineWowPackages-wayland.x86_64-linux
      (lib.remove "wayland" variants)
  )
)