Skip to content

Instantly share code, notes, and snippets.

@thefloweringash
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefloweringash/9500216 to your computer and use it in GitHub Desktop.
Save thefloweringash/9500216 to your computer and use it in GitHub Desktop.
package.el dependency test

Test case for package.el's dependency resolution. The two test cases are, with dependencies flowing left to right:

      C
     / \            X---Z
    A   D--E         \ /
     \ /              Y
      B
  • For a, the only valid install orders are (e d b c a) or (e d c b a)
  • For x, the only valid install order is (z y x)

My results

24.3

lorne@argon$ brew switch emacs 24.3 && ./test.el
Cleaning /usr/local/Cellar/emacs/24.3
Cleaning /usr/local/Cellar/emacs/HEAD
22 links created for /usr/local/Cellar/emacs/24.3
Saving file /Users/lorne/.emacs.d/elpa/archives/test/archive-contents...
Loading vc-git...
Wrote /Users/lorne/.emacs.d/elpa/archives/test/archive-contents
emacs-version:
	GNU Emacs 24.3.1 (x86_64-apple-darwin13.1.0, NS apple-appkit-1265.19)
 of 2014-03-12 on argon.cons.org.nz
emacs-bzr-version:
	nil
package-archives:
	((test . ~/src/emacs-package-test/))
[FAIL] install a = (c e d b a)
[FAIL] install x = (y z x)
tests=2 ok=0 fail=2 TEST FAILURES

HEAD

For some reason emacs-bzr-version is lost, Homebrew printed this while installing:

Updated to revision 116733 of branch http://bzr.savannah.gnu.org/r/emacs/trunk
lorne@argon$ brew switch emacs HEAD && ./test.el
Cleaning /usr/local/Cellar/emacs/24.3
Cleaning /usr/local/Cellar/emacs/HEAD
22 links created for /usr/local/Cellar/emacs/HEAD
Saving file /Users/lorne/.emacs.d/elpa/archives/test/archive-contents...
Wrote /Users/lorne/.emacs.d/elpa/archives/test/archive-contents
emacs-version:
	GNU Emacs 24.3.50.1 (x86_64-apple-darwin13.1.0, NS apple-appkit-1265.19)
 of 2014-03-12 on argon.cons.org.nz
emacs-bzr-version:
	nil
package-archives:
	((test . ~/src/emacs-package-test/))
[FAIL] install a = (d c e b a)
[  OK] install x = (z y x)
tests=2 ok=1 fail=1 TEST FAILURES
(1
(a . [(1) ((b) (c)) "a" nil])
(b . [(1) ((d)) "b" nil])
(c . [(1) ((d)) "c" nil])
(d . [(1) ((e)) "d" nil])
(e . [(1) nil "e" nil])
(x . [(1) ((z) (y)) "x" nil])
(y . [(1) ((z)) "y" nil])
(z . [(1) nil "z" nil])
)
#!/usr/bin/env emacs --script
;; -*- lexical-binding: t -*-
(require 'package)
(package-initialize)
(setq package-archives `(("test" . ,default-directory)))
(package-refresh-contents)
(cond ((version< emacs-version "24.3.50")
(defun show-tx (pkg-name)
(package-compute-transaction nil (list (list pkg-name)))))
(t
(defun show-tx (pkg-name)
(mapcar 'package-desc-name
(package-compute-transaction nil (list (list pkg-name)))))))
(defvar tests 0)
(defvar failures 0)
(defun result (name result)
(setq tests (1+ tests))
(unless result
(setq failures (1+ failures)))
(message "[%4s] %s"
(if result "OK" "FAIL") name))
(message "emacs-version:\n\t%s\nemacs-bzr-version:\n\t%s"
(emacs-version) emacs-bzr-version)
(message "package-archives:\n\t%s" package-archives)
(let ((install-a (show-tx 'a))
(install-x (show-tx 'x)))
(result (format "install a = %s" install-a)
(member install-a '((e d b c a) (e d c b a))))
(result (format "install x = %s" install-x)
(equal install-x '(z y x))))
(message "tests=%i ok=%i fail=%i %s"
tests
(- tests failures)
failures
(if (zerop failures)
"ALL TESTS PASSED"
"TEST FAILURES"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment