-
Notifications
You must be signed in to change notification settings - Fork 5
/
checks.nix
142 lines (135 loc) · 4.62 KB
/
checks.nix
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
callPackages,
emptyDirectory,
emacs,
lib,
linkFarm,
runCommand,
testers,
tmux,
writeText,
writeTextDir,
doomSource,
makeDoomPackages,
toInit,
}:
let
inherit (lib.generators) toPretty;
doomDirs = callPackages ./build-helpers/doomdirs.nix { inherit doomSource; };
common = {
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
experimentalFetchTree = true;
emacs = emacs.override { withNativeCompilation = false; };
};
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
mkDoomDir = args: writeTextDir "init.el" (toInit args);
minimalDoomDir = mkDoomDir { config.default = true; };
doomTest =
name: init: doomArgs:
testers.testEqualContents {
assertion = "name = ${name}; modules = ${toPretty { } init}; args = ${toPretty { } doomArgs};";
expected = writeText "doom-expected" "Doom functions";
# Runs Doom in tmux, waiting (by polling) until its window disappears.
actual =
runCommand "interactive"
{
# Read by tests.el.
testName = name;
nativeBuildInputs = [
tmux
(mkDoom (
doomArgs
// {
doomDir = linkFarm "test-doomdir" {
"config.el" = ./tests.el;
"init.el" = writeText "init.el" (toInit init);
};
}
))
];
}
''
tmux new-session -s doom-testing -d
tmux new-window -n doom-window 'doom-emacs -nw'
for ((i = 0; i < 100; i++)); do
tmux list-windows -a | grep -q doom-window || break
sleep .1
done
tmux kill-session -t doom-testing
'';
};
doomBuildTest = init: mkDoom { doomDir = mkDoomDir init; };
in
{
minimal = mkDoom { doomDir = minimalDoomDir; };
minimalEmacs =
(makeDoomPackages (
common
// {
doomDir = minimalDoomDir;
}
)).emacsWithDoom;
minimalExtraPackages = mkDoom {
doomDir = minimalDoomDir;
extraPackages = epkgs: [
epkgs.vterm
epkgs.treesit-grammars.with-all-grammars
];
};
allModules = mkDoom { doomDir = doomDirs.allModules; };
allModulesAndFlags = mkDoom { doomDir = doomDirs.allModulesAndFlags; };
allModulesMostFlags = mkDoom { doomDir = doomDirs.allModulesMostFlags; };
example = mkDoom { doomDir = ./doomdir; };
example-without-loader = mkDoom {
doomDir = ./doomdir;
profileName = "";
};
interactive = doomTest "nix-profile" { config.default = true; } { };
interactive-unset-profile = doomTest "no-profile" { config.default = true; } { profileName = ""; };
cmake = doomTest "cmake" { lang.cc = true; } { };
org-re-reveal = doomTest "org-re-reveal" { lang.org = [ "+present" ]; } { };
tree-sitter = doomTest "tree-sitter" {
tools.tree-sitter = true;
lang.go = [ "+tree-sitter" ];
} { };
# Various tests of module combinations.
unpinned-org = doomTest "external-org" { app.rss = [ "+org" ]; } { };
# Dependencies that require a module flag enabled and a different module or flag disabled.
# flycheck-eglot needs flymake disabled.
flycheck-eglot = doomBuildTest {
tools.lsp = [ "+eglot" ];
checkers.syntax = true;
};
# multiple-cursors needs :editor evil disabled.
multiple-cursors = doomBuildTest { editor.multiple-cursors = true; };
# flx needs +prescient disabled.
flx = doomBuildTest { completion.ivy = [ "+fuzzy" ]; };
# corfu pulls in unpinned orderless if vertico is disabled.
corfu-orderless = doomBuildTest { completion.corfu = [ "+orderless" ]; };
# flyspell can pull in one of three completion modules.
flyspell-correct-ivy = doomBuildTest {
checkers.spell = [ "+flyspell" ];
completion.ivy = true;
};
flyspell-correct-helm = doomBuildTest {
checkers.spell = [ "+flyspell" ];
completion.helm = true;
};
flyspell-correct-popup = doomBuildTest { checkers.spell = [ "+flyspell" ]; };
extraPackages = doomTest "extraPackages" { config.default = true; } {
extraPackages = epkgs: [ epkgs.vterm ];
};
}