[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/systemd 3580191 067/131: add autoload regex tests
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/systemd 3580191 067/131: add autoload regex tests |
Date: |
Sun, 29 Aug 2021 11:35:16 -0400 (EDT) |
branch: elpa/systemd
commit 35801910e7e20130d3b4da2da0a893fa7df097dd
Author: Mark Oteiza <mvoteiza@udel.edu>
Commit: Mark Oteiza <mvoteiza@udel.edu>
add autoload regex tests
---
Makefile | 7 ++++-
tests/systemd-tests.el | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 74506ec..f2e7a88 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,11 @@ EMACS = emacs
all: $(SRC:.el=.elc)
+check: tests/systemd-tests.el systemd.elc
+ @$(EMACS) -Q --batch -L . --eval "(progn \
+ (load-file \"tests/systemd-tests.el\") \
+ (ert-run-tests-batch-and-exit))"
+
clean:
$(RM) $(SRC:.el=.elc)
@@ -18,4 +23,4 @@ install:
.el.elc:
$(EMACS) -L . --batch -f batch-byte-compile $<
-.PHONY: all clean install
+.PHONY: all check clean install
diff --git a/tests/systemd-tests.el b/tests/systemd-tests.el
new file mode 100644
index 0000000..65089ab
--- /dev/null
+++ b/tests/systemd-tests.el
@@ -0,0 +1,81 @@
+;;; systemd-tests.el --- Tests for systemd.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2016 Mark Oteiza <mvoteiza@udel.edu>
+
+;; Author: Mark Oteiza <mvoteiza@udel.edu>
+
+;; This file is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License
+;; as published by the Free Software Foundation; either version 3
+;; of the License, or (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this file. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'systemd)
+
+(ert-deftest test-normal-autoloads ()
+ "Tests for `systemd-autoload-regexp'.
+This should match unit names: alpha-numeric ascii base names,
+with exceptions in the set [-_.@\\]. Extensions are a prescribed
+list. Some from systemd.unit(5) are excluded intentionally;
+e.g. scope files which are created programmatically."
+ (let ((re systemd-autoload-regexp))
+ (should (string-match-p re "70-snark-ethernet.link"))
+ (should-not (string-match-p re "abusname"))
+ (should-not (string-match-p re "busname"))
+ ;; Do not match empty unit name
+ (should-not (string-match-p re ".service"))
+ ;; Non-ASCII exceptions
+ (should (string-match-p re "-.mount"))
+ (should (string-match-p re "dev-dm\\x2d4.service"))
+ (should (string-match-p re "proc-sys-fs-binfmt_misc.automount"))
+ (should (string-match-p re "bitlbee@.service"))
+ (should (string-match-p re "org.freedesktop.timedate1.busname"))
+ ;; Do not match non-ASCII
+ (should-not (string-match-p re "割り箸.service"))
+ ;; Do not match non-alphanumeric ASCII
+ (should-not (string-match-p re "~.service"))))
+
+(ert-deftest test-tempfile-autoloads ()
+ "Tests for `systemd-tempfn-autoload-regexp'.
+Should match file names generated by \"tempfn_random\" in
+src/basic/fileio.c which, to quote its comments, does the
+transformation
+
+ /foo/bar/waldo => /foo/bar/.#<extra>waldobaa2a261115984a9
+
+but not plain unit names. For temp files made from systemctl
+edit, <extra> is NULL as of systemd 229."
+ (let ((re systemd-tempfn-autoload-regexp))
+ (should-not (string-match-p re "/foo/bar/.#waldobaa2a261115984a9"))
+ (should (string-match-p re ".#override.conf064d87263873e7f7"))
+ (should (string-match-p re ".#FOObar.timer064d87263873e7f7"))
+ ;; Do not match just the conf extension or unit names
+ (should-not (string-match-p re "override.conf"))
+ (should-not (string-match-p re "mmmmm.mount"))))
+
+(ert-deftest test-dropin-autoloads ()
+ "Tests for `systemd-dropin-autoload-regexp'.
+It should match file names with the \".conf\" extension if and
+only if in an appropriately named parent directory."
+ (let ((re systemd-dropin-autoload-regexp))
+ (should (string-match-p re "/systemd/dog.socket.d/woof.conf"))
+ (should-not (string-match-p re "foobar.conf"))
+ (should-not (string-match-p re "/etc/modprobe.d/bonding.conf"))
+ (should-not (string-match-p re "/etc/systemd/system.conf"))))
+
+(provide 'systemd-tests)
+
+;;; systemd-tests.el ends here
+
- [nongnu] elpa/systemd 23c0caf 115/131: extend anchored matches past the current line if \ broken, (continued)
- [nongnu] elpa/systemd 23c0caf 115/131: extend anchored matches past the current line if \ broken, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 228f0b9 119/131: happy new year, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd e97f78e 120/131: Add %S, %C, %L specifiers, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd eaaf16f 033/131: fix indentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd cf435f4 034/131: convolute sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 2b70f83 035/131: these groups need not be nested, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 807c748 044/131: systemd 225, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 0f2f936 052/131: clarify parent mode hooks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd aa9f4f6 053/131: update commentary, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd bf39be2 062/131: assimilate systemd-company.el into systemd.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 3580191 067/131: add autoload regex tests,
ELPA Syncer <=
- [nongnu] elpa/systemd 16be183 084/131: don't indiscriminately use relative file name, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd f0b29ad 087/131: systemd v232 directives, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 7874a10 090/131: future flycheck has a checker for units, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd fa1277d 092/131: add reminder, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 59ce8ad 095/131: simpler while test, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 9693935 099/131: nix extra newline, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 7bb8f09 104/131: correct syntax?, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd a4f4096 107/131: moar keywords, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd b0c1d64 109/131: add multi-line comment highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 5c9389d 110/131: move this matcher down with the other ones, ELPA Syncer, 2021/08/29