Skip to content

Commit

Permalink
Test byte-compilation only
Browse files Browse the repository at this point in the history
Tests that involve creating and deleting frames cannot run in batch
mode, and that's all this package does. So we can't run any tests, but
we can still test that the package compiles. We do so on the oldest
and newest supported Emacs versions, along with Emacs snapshot.
  • Loading branch information
DarwinAwardWinner committed Sep 22, 2024
1 parent 7dcd5bc commit bc4e45b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 105 deletions.
44 changes: 23 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@ jobs:
strategy:
fail-fast: false
matrix:
# For available versions: https://github.com/purcell/nix-emacs-ci/blob/master/flake.nix
emacs_version:
- 27.1
- 26.3
- 26.2
- 26.1
- 25.3
- 25.2
- 25.1
- 24.5
- 29.4
- 24.4
- snapshot
env:
# We only generate a coverage report for one Emacs version
# (generally the latest release version) in order to avoid
# duplicate reports.
coveralls_emacs_version: 27.1
# env:
# # We only generate a coverage report for one Emacs version
# # (generally the latest release version) in order to avoid
# # duplicate reports.
# coveralls_emacs_version: 29.4
steps:
- name: Set up Emacs
uses: purcell/setup-emacs@master
Expand All @@ -45,13 +39,21 @@ jobs:
- name: Install Elisp dependencies
run: eldev prepare test

- name: Run the test suite
run: |
eldev -p -dtT test
# Tests are currently disabled because there are no runnable tests
# (because testing frame creation is not possible in batch mode).
# Instead, we just make sure the package compiles.

- name: Run the test suite in source mode (for undercover)
if: ${{ matrix.emacs_version == env.coveralls_emacs_version }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: Compile the package
run: |
eldev -s -dtT test
eldev compile
# - name: Run the test suite
# run: |
# eldev -p -dtT test

# - name: Run the test suite in source mode (for undercover)
# if: ${{ matrix.emacs_version == env.coveralls_emacs_version }}
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
# run: |
# eldev -s -dtT test
2 changes: 1 addition & 1 deletion Eldev
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
;; (eldev-use-package-archive 'gnu)
(eldev-use-package-archive 'melpa)

(setq eldev-project-main-file "mac-pseudo-daemon.el")
(setq eldev-project-main-file "pseudo-daemon.el")

(setq eldev-test-framework 'buttercup)

Expand Down
83 changes: 0 additions & 83 deletions tests/test-macpd.el

This file was deleted.

54 changes: 54 additions & 0 deletions tests/test-pseudo-daemon.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
;;; -*- lexical-binding: t -*-

(require 'pseudo-daemon)
(require 'buttercup)
(require 'cl-lib)

(describe "The pseudo-daemon package"

:var ((orig-pseudo-daemon-mode pseudo-daemon-mode)
(orig-pseudo-daemon-window-systems pseudo-daemon-window-systems))

(before-each
;; Start each test with the mode enabled
(pseudo-daemon-mode 1)
;; Spy on and/or disable some functions
(spy-on 'pseudo-daemon-make-hidden-frame :and-call-through)
;; Need to disable this and also keep track of when someone tries
;; to call it
(spy-on 'save-buffers-kill-emacs)
;; These probably shouldn't get called, but just in case we'll
;; disable them so Emacs doesn't accidentally get killed during
;; testing.
(spy-on 'server-save-buffers-kill-terminal)
(spy-on 'kill-emacs))

;; Restore the original state of all relevant vars after all tests
;; are complete
(after-all
(setq pseudo-daemon-window-systems orig-pseudo-daemon-window-systems)
(pseudo-daemon-mode (if orig-pseudo-daemon-mode 1 0)))

;; TODO: Can't make frames in batch mode, so this test can't run
(xit "should only spawn a new frame when closing the last frame"
(let ((this-term (frame-terminal (selected-frame))))
(dotimes (_ 5)
(make-frame `((terminal . ,(frame-terminal (selected-frame))))))
(let ((this-term-frames
(filtered-frame-list
(lambda (frm) (eq (frame-terminal frm) this-term)))))
(dolist (frm this-term-frames)
(delete-frame frm)))
(expect 'make-new-default-frame :to-have-been-called-times 1)
(expect 'save-buffers-kill-emacs :not :to-have-been-called)
;; Terminal should now have exactly one frame -- the
;; newly-created one.
(let ((this-term-frames
(filtered-frame-list
(lambda (frm) (eq (frame-terminal frm) this-term)))))
(expect (length this-term-frames)
:to-equal 1))))
(xit "should prevent terminal closure via `handle-delete-frame'")
(xit "should prevent terminal closure via `save-buffers-kill-terminal'"))

;;; test-pseudo-daemon.el ends here

0 comments on commit bc4e45b

Please sign in to comment.