Skip to content

Commit

Permalink
Add basic end-to-end test
Browse files Browse the repository at this point in the history
  • Loading branch information
marienz committed May 17, 2024
1 parent d7c2725 commit bc808de
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
27 changes: 27 additions & 0 deletions doomdirs/test/config.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
;; -*- lexical-binding: t; -*-

;; 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.

;; Config file for integration tests.
;;
;; 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-doom ()
(let ((out (getenv "out")))
(write-region "Doom functions" nil out nil nil nil 'mustbenew))
(kill-emacs))

(add-hook 'doom-after-init-hook 'test-doom)
16 changes: 16 additions & 0 deletions doomdirs/test/init.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;; 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)
21 changes: 21 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
};
mkDoom = args: (doomFromPackages pkgs (common // args)).doomEmacs;
doomTest = assertion: args: pkgs.testers.testEqualContents {
inherit assertion;
expected = pkgs.writeText "doom-expected" "Doom functions";
# Runs Doom in tmux, waiting (by polling) until its window disappears.
actual = pkgs.runCommand "interactive" {
nativeBuildInputs = [ pkgs.tmux (mkDoom args) ];
} ''
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 {
minimal = mkDoom { doomDir = ./doomdirs/minimal; };
minimalEmacs = (doomFromPackages pkgs (common // {
Expand All @@ -73,6 +89,11 @@
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 = "";
};
});
packages = perSystemPackages (pkgs: {
doom-example = (doomFromPackages pkgs {
Expand Down

0 comments on commit bc808de

Please sign in to comment.