2024-05-25 17:41:10 +10:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
|
|
{
|
2024-06-01 20:37:09 +10:00
|
|
|
callPackages,
|
2024-05-26 14:42:07 +10:00
|
|
|
emptyDirectory,
|
2024-05-25 21:48:33 +10:00
|
|
|
lib,
|
|
|
|
|
linkFarm,
|
2024-05-25 17:41:10 +10:00
|
|
|
runCommand,
|
|
|
|
|
testers,
|
|
|
|
|
tmux,
|
|
|
|
|
writeText,
|
2024-05-25 20:30:33 +10:00
|
|
|
writeTextDir,
|
2024-05-25 21:48:33 +10:00
|
|
|
|
2024-06-01 20:37:09 +10:00
|
|
|
doomSource,
|
2024-05-25 17:41:10 +10:00
|
|
|
makeDoomPackages,
|
2024-05-25 20:30:33 +10:00
|
|
|
toInit,
|
2024-05-25 17:41:10 +10:00
|
|
|
}:
|
|
|
|
|
let
|
2024-05-25 21:48:33 +10:00
|
|
|
inherit (lib.generators) toPretty;
|
2024-06-01 20:37:09 +10:00
|
|
|
inherit (callPackages ./build-helpers/full-init.nix { inherit doomSource; })
|
|
|
|
|
doomDirWithAllModules doomDirWithAllModulesAndFlags;
|
2024-05-25 17:41:10 +10:00
|
|
|
common = {
|
|
|
|
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
2024-05-26 22:42:51 +10:00
|
|
|
experimentalFetchTree = true;
|
2024-05-25 17:41:10 +10:00
|
|
|
};
|
|
|
|
|
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
2024-05-25 20:30:33 +10:00
|
|
|
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
|
|
|
|
minimalDoomDir = mkDoomDir { config = [ "default" ]; };
|
2024-05-25 21:48:33 +10:00
|
|
|
doomTest = name: init: doomArgs: testers.testEqualContents {
|
|
|
|
|
assertion = "name = ${name}; modules = ${toPretty {} init}; args = ${toPretty {} doomArgs};";
|
2024-05-25 17:41:10 +10:00
|
|
|
expected = writeText "doom-expected" "Doom functions";
|
|
|
|
|
# Runs Doom in tmux, waiting (by polling) until its window disappears.
|
|
|
|
|
actual = runCommand "interactive" {
|
2024-05-25 21:48:33 +10:00
|
|
|
# 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);
|
|
|
|
|
};
|
|
|
|
|
})) ];
|
2024-05-25 17:41:10 +10:00
|
|
|
} ''
|
|
|
|
|
tmux new-session -s doom-testing -d
|
|
|
|
|
tmux new-window -n doom-window doom-emacs
|
|
|
|
|
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
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
in {
|
2024-05-26 11:47:31 +10:00
|
|
|
minimal = mkDoom { doomDir = minimalDoomDir; };
|
2024-05-25 17:41:10 +10:00
|
|
|
minimalEmacs = (makeDoomPackages (common // {
|
2024-05-25 20:30:33 +10:00
|
|
|
doomDir = minimalDoomDir;
|
2024-05-25 17:41:10 +10:00
|
|
|
})).emacsWithDoom;
|
2024-06-02 00:34:36 +02:00
|
|
|
minimalExtraPackages = mkDoom {
|
|
|
|
|
doomDir = minimalDoomDir;
|
|
|
|
|
extraPackages = epkgs: [ epkgs.vterm epkgs.treesit-grammars.with-all-grammars ];
|
|
|
|
|
};
|
2024-06-01 20:37:09 +10:00
|
|
|
allModules = mkDoom { doomDir = doomDirWithAllModules; };
|
|
|
|
|
allModulesAndFlags = mkDoom { doomDir = doomDirWithAllModulesAndFlags; };
|
2024-05-27 21:28:20 +10:00
|
|
|
example = mkDoom { doomDir = ./doomdir; };
|
2024-05-25 17:41:10 +10:00
|
|
|
example-without-loader = mkDoom {
|
2024-05-27 21:28:20 +10:00
|
|
|
doomDir = ./doomdir;
|
2024-05-25 17:41:10 +10:00
|
|
|
profileName = "";
|
|
|
|
|
};
|
2024-05-25 21:48:33 +10:00
|
|
|
interactive = doomTest "minimal" { config = [ "default" ]; } { };
|
|
|
|
|
interactive-without-loader = doomTest "minimal" { config = [ "default" ]; } { profileName = ""; };
|
2024-05-26 12:35:09 +10:00
|
|
|
|
2024-05-26 17:19:44 +10:00
|
|
|
org-re-reveal = doomTest "org-re-reveal" { lang = [ [ "org" "+present" ] ]; } { };
|
|
|
|
|
|
2024-05-26 12:35:09 +10:00
|
|
|
# Various tests of module combinations.
|
|
|
|
|
unpinned-org = doomTest "external-org" { app = [ [ "rss" "+org" ] ]; } { };
|
2024-06-03 00:40:12 +02:00
|
|
|
|
|
|
|
|
extraPackages = doomTest "extraPackages" { config = [ "default" ]; } { extraPackages = epkgs: [ epkgs.vterm ]; };
|
2024-05-25 17:41:10 +10:00
|
|
|
}
|