Support more tests than just startup
It looks like I will need tests that some of the more interesting packages actually work, not just build.
This commit is contained in:
parent
4597bb574e
commit
80a951826e
3 changed files with 29 additions and 26 deletions
24
checks.nix
24
checks.nix
|
|
@ -14,15 +14,19 @@
|
|||
|
||||
{
|
||||
emacs29,
|
||||
lib,
|
||||
linkFarm,
|
||||
runCommand,
|
||||
testers,
|
||||
tmux,
|
||||
writeText,
|
||||
writeTextDir,
|
||||
|
||||
makeDoomPackages,
|
||||
toInit,
|
||||
}:
|
||||
let
|
||||
inherit (lib.generators) toPretty;
|
||||
common = {
|
||||
# TODO: drop after NixOS 24.05 release.
|
||||
emacs = emacs29;
|
||||
|
|
@ -31,12 +35,19 @@ let
|
|||
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
||||
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
||||
minimalDoomDir = mkDoomDir { config = [ "default" ]; };
|
||||
doomTest = assertion: args: testers.testEqualContents {
|
||||
inherit assertion;
|
||||
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" {
|
||||
nativeBuildInputs = [ tmux (mkDoom args) ];
|
||||
# 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
|
||||
|
|
@ -61,9 +72,6 @@ in {
|
|||
doomDir = ./doomdirs/example;
|
||||
profileName = "";
|
||||
};
|
||||
interactive = doomTest "minimal doom starts" { doomDir = ./doomdirs/test; };
|
||||
interactive-without-loader = doomTest "minimal doom (without loader) starts" {
|
||||
doomDir = ./doomdirs/test;
|
||||
profileName = "";
|
||||
};
|
||||
interactive = doomTest "minimal" { config = [ "default" ]; } { };
|
||||
interactive-without-loader = doomTest "minimal" { config = [ "default" ]; } { profileName = ""; };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
;; 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.
|
||||
|
||||
;; Doom doesn't like a completely empty doom! block.
|
||||
(doom! :config default)
|
||||
|
|
@ -19,9 +19,20 @@
|
|||
;; This tries to hook into startup as late as possible, write a sign of life
|
||||
;; (currently a string written to $out), and then exits.
|
||||
|
||||
(defun test-minimal ()
|
||||
;; The minimal test is a noop.
|
||||
)
|
||||
|
||||
(defun test-doom ()
|
||||
(let ((out (getenv "out")))
|
||||
(write-region "Doom functions" nil out nil nil nil 'mustbenew))
|
||||
(let* ((out (getenv "out"))
|
||||
(test (intern-soft (format "test-%s" (getenv "testName"))))
|
||||
(result (condition-case err
|
||||
(funcall test)
|
||||
(error
|
||||
(format "%s failed: %s" test err))
|
||||
(:success
|
||||
"Doom functions"))))
|
||||
(write-region result nil out nil nil nil 'mustbenew))
|
||||
(kill-emacs))
|
||||
|
||||
(add-hook 'doom-after-init-hook 'test-doom)
|
||||
Loading…
Add table
Add a link
Reference in a new issue