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

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

[nongnu] elpa/package-lint 095de5408e 1/8: Convert run-tests.sh to Makef


From: ELPA Syncer
Subject: [nongnu] elpa/package-lint 095de5408e 1/8: Convert run-tests.sh to Makefile
Date: Thu, 19 Sep 2024 13:01:30 -0400 (EDT)

branch: elpa/package-lint
commit 095de5408ec937b38cabeaab622a75f76f67defc
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>

    Convert run-tests.sh to Makefile
---
 .github/workflows/test.yml |  2 +-
 Makefile                   | 63 ++++++++++++++++++++++++++++++++++
 run-tests.sh               | 85 ----------------------------------------------
 3 files changed, 64 insertions(+), 86 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c654b4023a..65b9f8b177 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -43,4 +43,4 @@ jobs:
 
     - uses: actions/checkout@v4
     - name: Run tests
-      run: './run-tests.sh'
+      run: make
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..8976dcd913
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,63 @@
+EMACS ?= emacs
+
+# A space-separated list of required package names
+DEPS = cl-lib let-alist compat
+
+INIT_PACKAGES="(progn \
+  (require 'package) \
+  (push '(\"melpa\" . \"https://melpa.org/packages/\";) package-archives) \
+  (package-initialize) \
+  (dolist (pkg '(${DEPS})) \
+    (unless (package-installed-p pkg) \
+      (unless (assoc pkg package-archive-contents) \
+       (package-refresh-contents)) \
+      (package-install pkg))) \
+  ;; Ensure we have a downloadable package list for package-lint to work from \
+  (unless package-archive-contents (package-refresh-contents)) \
+  )"
+
+EMACS_BATCH="${EMACS} -Q -batch --eval ${INIT_PACKAGES}"
+
+all: clean-elc compile package-lint test
+
+package-lint:
+       ${EMACS} -Q --eval ${INIT_PACKAGES} -batch -l package-lint.el -f 
package-lint-batch-and-exit package-lint.el
+
+compile: clean-elc
+       ${EMACS} -Q --eval ${INIT_PACKAGES} -L . -batch -f batch-byte-compile 
*.el
+
+clean-elc:
+       rm -f f.elc
+
+test:
+       @echo "---- Run unit tests"
+       @${EMACS_BATCH} \
+                -l package-lint.el \
+                -l package-lint-test.el \
+                -f ert-run-tests-batch-and-exit && echo "OK"
+       @echo "---- Assert clean package passes batch linting"
+       @${EMACS_BATCH} \
+                -l package-lint.el \
+                -f package-lint-batch-and-exit \
+                batch-tests/is-clean.el && echo "OK"
+       @echo "---- Assert package with demoted warnings passes batch linting"
+       @${EMACS_BATCH} \
+                --eval "(setq package-lint-batch-fail-on-warnings nil)" \
+                -l package-lint.el \
+                -f package-lint-batch-and-exit \
+                batch-tests/just-warnings.el && echo "OK"
+       @echo "---- Assert package with warnings fails batch linting"
+       @${EMACS_BATCH} \
+                -l package-lint.el \
+                -f package-lint-batch-and-exit \
+                batch-tests/just-warnings.el && \
+           exit 1 || echo "OK"
+       @echo "---- Assert package with errors fails batch linting"
+       @${EMACS_BATCH} \
+                -l package-lint.el \
+                -f package-lint-batch-and-exit \
+                batch-tests/has-errors.el && \
+           exit 1 || echo "OK"
+
+
+.PHONY:        all compile clean-elc package-lint test
diff --git a/run-tests.sh b/run-tests.sh
deleted file mode 100755
index 462714ec25..0000000000
--- a/run-tests.sh
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/sh -e
-
-EMACS="${EMACS:=emacs}"
-
-NEEDED_PACKAGES="cl-lib let-alist compat"
-
-INIT_PACKAGE_EL="(progn \
-  (require 'package) \
-  (push '(\"melpa\" . \"https://melpa.org/packages/\";) package-archives) \
-  (setq package-check-signature nil) \
-  (package-initialize) \
-  (package-refresh-contents) \
-  (dolist (pkg '(${NEEDED_PACKAGES})) \
-    (unless (package-installed-p pkg) \
-      (package-install pkg))))"
-
-# Refresh package archives, because the test suite needs to see at least
-# package-lint and cl-lib.
-"$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL"
-
-# Byte compile, failing on byte compiler errors, or on warnings unless ignored
-if [ -n "${EMACS_LINT_IGNORE+x}" ]; then
-    ERROR_ON_WARN=nil
-else
-    ERROR_ON_WARN=t
-fi
-
-"$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL" \
-         -l package-lint.el \
-         --eval "(setq byte-compile-error-on-warn ${ERROR_ON_WARN})" \
-         -f batch-byte-compile \
-         package-lint.el package-lint-test.el
-# Lint ourselves
-# Lint failures are ignored if EMACS_LINT_IGNORE is defined, so that lint
-# failures on Emacs 24.2 and below don't cause the tests to fail, as these
-# versions have buggy imenu that reports (defvar foo) as a definition of foo.
-"$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL" \
-         -L . \
-         --eval "(require 'package-lint)" \
-         -f package-lint-batch-and-exit \
-         package-lint.el package-lint-test.el || [ -n "${EMACS_LINT_IGNORE+x}" 
]
-# Finally, run the testsuite
-"$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL" \
-         -l package-lint.elc \
-         -l package-lint-test.el \
-         -f ert-run-tests-batch-and-exit
-
-# Check for correct exit codes
-
-echo "Assert clean package passes batch linting"
-"$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL" \
-         -l package-lint.el \
-         -f package-lint-batch-and-exit \
-         batch-tests/is-clean.el
-"$EMACS" -Q -batch \
-echo "Assert package with demoted warnings passes batch linting"
-"$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL" \
-         --eval "(setq package-lint-batch-fail-on-warnings nil)" \
-         -l package-lint.el \
-         -f package-lint-batch-and-exit \
-         batch-tests/just-warnings.el
-echo "Assert package with warnings fails batch linting"
-if "$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL" \
-         -l package-lint.el \
-         -f package-lint-batch-and-exit \
-         batch-tests/just-warnings.el; then
-    echo "Didn't report failure when batch-linting file with errors"
-    exit 1
-fi
-echo "Assert package with errors fails batch linting"
-if "$EMACS" -Q -batch \
-         --eval "$INIT_PACKAGE_EL" \
-         -l package-lint.el \
-         -f package-lint-batch-and-exit \
-         batch-tests/has-errors.el; then
-    echo "Didn't report failure when batch-linting file with errors"
-    exit 1
-fi



reply via email to

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