emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/graphql 8d45c98e9f 24/56: Run tests on Travis


From: ELPA Syncer
Subject: [elpa] externals/graphql 8d45c98e9f 24/56: Run tests on Travis
Date: Sat, 29 Oct 2022 13:57:54 -0400 (EDT)

branch: externals/graphql
commit 8d45c98e9f396626a6fa5d00811b70905bd1f933
Author: Sean Allred <code@seanallred.com>
Commit: Sean Allred <code@seanallred.com>

    Run tests on Travis
---
 .gitignore   |   1 +
 .travis.yml  |  21 ++++++++++
 Makefile     |  24 +++++++++++
 test/make.el | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 181 insertions(+)

diff --git a/.gitignore b/.gitignore
index 28f0a7dc05..9d0a57f4f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 .cask/
+.elpa/
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..5171b30fc1
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,21 @@
+language: emacs-lisp
+sudo: false
+cache:
+- directories:
+  - "$HOME/emacs"
+matrix:
+  fast_finish: true
+  allow_failures:
+  - env: EMACS_VERSION=snapshot
+env:
+  matrix:
+  - EMACS_VERSION=25.1
+  - EMACS_VERSION=25.2
+  - EMACS_VERSION=25.3
+  - EMACS_VERSION=snapshot
+before_install:
+- make CI-setup
+install:
+- make install
+script:
+- make test
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..e8bb6507a1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+EENVS := PACKAGE_FILE="graphql.el" PACKAGE_DEV_DEPS="" PACKAGE_SOURCES="gnu"
+EMAKE := $(EENVS) emacs -batch -l test/make.el --eval "(make (pop argv))"
+
+.PHONY: clean install compile test CI-setup
+
+clean:
+       rm -f *.elc
+       rm -rf .elpa/
+
+install: .elpa/
+.elpa/:
+       $(EMAKE) update
+
+compile: clean
+       $(EMAKE) compile
+
+test:
+       $(EMAKE) test
+
+CI-setup:
+       export PATH="$(HOME)/bin:$(PATH)"
+       wget 
'https://raw.githubusercontent.com/flycheck/emacs-travis/master/emacs-travis.mk'
+       make -f emacs-travis.mk install_emacs
+       emacs --version
diff --git a/test/make.el b/test/make.el
new file mode 100644
index 0000000000..b7f7737efa
--- /dev/null
+++ b/test/make.el
@@ -0,0 +1,135 @@
+;;; Emacs-Make -- simple, transparent functionality for automated elisp testing
+;;; Based on 
http://edkolev.github.io/posts/2017-09-10-travis-for-emacs-packages.html
+
+;;; Basic support for Caskfile syntax; override with environment variables:
+
+;; PACKAGE_FILE     := the root file of your package
+;; PACKAGE_DEV_DEPS := list of development-environment dependencies separated 
by spaces
+;; PACKAGE_SOURCES  := list of package dependencies separated by spaces
+
+;;; You can debug emacs-make by setting the environment variable DEBUG.
+
+(setq debug-on-error (getenv "DEBUG"))
+
+(require 'package)
+(require 'subr-x)
+
+(defun make-get-directive-in-caskfile (directive &optional get-all)
+  "Get DIRECTIVE from the caskfile if it exists.
+If GET-ALL is non-nil, all instances of DIRECTIVE are collected
+into a list."
+  (let ((caskfile "Cask") expr found)
+    (when-let ((caskdir (locate-dominating-file default-directory caskfile))
+               (caskfile (expand-file-name caskfile caskdir)))
+      (with-temp-buffer
+        (insert-file-contents-literally caskfile)
+        (ignore-errors ; may not be able to find DIRECTIVE; don't let `read' 
error out
+          (while (not (or (eobp) found))
+            (let ((e (read (current-buffer))))
+              (when (eq directive (car-safe e))
+                (if get-all
+                    (push e expr)
+                  (setq expr e
+                        found t)))))))
+      (cond
+       (get-all expr)
+       (found (cdr-safe expr))))))
+
+(defconst make-package-file
+  (or (getenv "PACKAGE_FILE")
+      (car-safe (make-get-directive-in-caskfile 'package-file))
+      (error "No PACKAGE_FILE and no Caskfile found."))
+  "Main package file.")
+(defconst make-project-root
+  (locate-dominating-file default-directory make-package-file)
+  "Root directory of the project.")
+(defconst make-package-archives
+  (or (when-let ((deps (getenv "PACKAGE_SOURCES")))
+        (thread-last (split-string deps nil t)
+          (mapcar #'downcase)
+          (mapcar #'intern)))
+      (mapcar (lambda (source) (pcase source (`(source ,src) src)))
+              (make-get-directive-in-caskfile 'source t))
+      '(gnu))
+  "List of sources (symbols) to use.")
+(defconst make-dev-deps
+  (or (when-let ((deps (getenv "PACKAGE_DEV_DEPS")))
+        (thread-last (split-string deps nil t)
+          (mapcar #'downcase)
+          (mapcar #'intern)))
+      (mapcar (lambda (dep) (pcase dep (`(depends-on ,package) (intern 
package))))
+              (make-get-directive-in-caskfile 'development)))
+  "List of package-symbols that are development dependencies.")
+
+(defconst make-package-archive-master-alist
+  '(("melpa" . "http://melpa.org/packages/";)
+    ("gnu" . "http://elpa.gnu.org/packages/";)))
+
+(defvar make-package-desc
+  (with-temp-buffer
+    (insert-file-contents-literally (expand-file-name make-package-file 
make-project-root))
+    (package-buffer-info))
+  "A package-desc object for the current package.")
+
+(defun make (target)
+  "Run `make-TARGET' if bound."
+  (let ((fun (intern (format "make-%s" target))))
+    (unless (fboundp fun)
+      (error "%S target not found" target))
+    (message "Project file detected as: %S" make-package-file)
+    (message "Development dependencies detected as: %S" make-dev-deps)
+    (message "Running target %S with %S\n" target fun)
+    (funcall fun)))
+
+(defun make-test ()
+  "Run all tests in \"PACKAGE-NAME-test.el\"."
+  (let* ((project-tests-file (format "%S-test.el" (package-desc-name 
make-package-desc)))
+         (project-tests-path (format "%s/test/" make-project-root)))
+
+    ;; add the package being tested to `load-path' so it can be required
+    (add-to-list 'load-path make-project-root)
+    (add-to-list 'load-path project-tests-path)
+
+    ;; load the file with tests
+    (load (expand-file-name project-tests-file project-tests-path) nil t)
+
+    ;; run the tests
+    (ert-run-tests-batch-and-exit)))
+
+(defun make-update ()
+  "Update required packages.
+Required packages include those that `make-package-file' lists as
+dependencies and those in `make-dev-deps'."
+  (let ((pkglist (append
+                  make-dev-deps
+                  (thread-last make-package-desc
+                    (package-desc-reqs)
+                    (mapcar #'car)
+                    (delq 'emacs))))
+        (package-user-dir (expand-file-name (format ".elpa/%s/elpa" 
emacs-version)))
+        (package-archives
+         (let (l)
+           (dolist (pair make-package-archive-master-alist)
+             (when (memq (intern (car pair)) make-package-archives)
+               (push pair l)))
+           l)))
+
+    (message "installing in %s..." package-user-dir)
+    (package-initialize)
+    (package-refresh-contents)
+
+    ;; install dependencies
+    (dolist (package pkglist)
+      (unless (package-installed-p package)
+        (ignore-errors
+          (package-install package))))
+
+    ;; upgrade dependencies
+    (save-window-excursion
+      (package-list-packages t)
+      (condition-case _
+          (progn
+            (package-menu-mark-upgrades)
+            (package-menu-execute t))
+        (error
+         (message "All packages up to date"))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]