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

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

[nongnu] elpa/emacsql a459708684 244/427: Move tests into their own dire


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql a459708684 244/427: Move tests into their own directory.
Date: Tue, 13 Dec 2022 02:59:48 -0500 (EST)

branch: elpa/emacsql
commit a459708684d30f5c9c38a1ad0ff88ad0669bc393
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Move tests into their own directory.
---
 Makefile                                           | 11 ++-
 .../emacsql-compiler-tests.el                      | 78 +-------------------
 tests/emacsql-external-tests.el                    | 85 ++++++++++++++++++++++
 tests/emacsql-tests.el                             | 10 +++
 4 files changed, 103 insertions(+), 81 deletions(-)

diff --git a/Makefile b/Makefile
index a46a819341..8e82e17587 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 EMACS   ?= emacs
 CASK    ?= cask
 VIRTUAL := $(CASK) exec $(EMACS)
-BATCH   := $(VIRTUAL) -batch -Q -L .
+BATCH   := $(VIRTUAL) -batch -Q -L . -L tests
 
 PACKAGE := emacsql
 VERSION := $(shell $(CASK) version)
@@ -11,6 +11,9 @@ EL = emacsql-compiler.el emacsql-system.el emacsql.el \
 ELC = $(EL:.el=.elc)
 EXTRA_DIST = README.md UNLICENSE
 
+TEST_EL  = $(wildcard tests/*.el)
+TEST_ELC = $(TEST_EL:.el=.elc)
+
 .PHONY : all binary compile package test clean distclean
 
 all : test
@@ -32,11 +35,11 @@ $(PACKAGE)-pkg.el : Cask
 $(PACKAGE)-$(VERSION).tar : $(EL) $(PACKAGE)-pkg.el $(EXTRA_DIST)
        tar -cf $@ --transform "s,^,$(PACKAGE)-$(VERSION)/," $^
 
-test: compile $(PACKAGE)-tests.elc
-       $(BATCH) -l $(PACKAGE)-tests.elc -f ert-run-tests-batch
+test: compile $(TEST_ELC)
+       $(BATCH) -l tests/$(PACKAGE)-tests.elc -f ert-run-tests-batch
 
 clean :
-       $(RM) *.tar *.elc $(PACKAGE)-pkg.el
+       $(RM) *.tar *.elc tests/*.elc $(PACKAGE)-pkg.el
 
 distclean :
        $(MAKE) -C sqlite clean
diff --git a/emacsql-tests.el b/tests/emacsql-compiler-tests.el
similarity index 68%
rename from emacsql-tests.el
rename to tests/emacsql-compiler-tests.el
index 220f7eaea2..c780101f99 100644
--- a/emacsql-tests.el
+++ b/tests/emacsql-compiler-tests.el
@@ -4,26 +4,6 @@
 
 (require 'ert)
 (require 'emacsql)
-(require 'emacsql-sqlite)
-(require 'emacsql-psql)
-
-(defvar emacsql-tests-timeout 4
-  "Be aggressive about not waiting on subprocesses in unit tests.")
-
-(defvar emacsql-tests-connection-factories
-  (let ((factories ())
-        (pgdatabase (getenv "PGDATABASE")))
-    (push (cons "sqlite" (apply-partially #'emacsql-sqlite nil)) factories)
-    (when pgdatabase
-      (push (cons "psql" (apply-partially #'emacsql-psql pgdatabase))
-            factories))
-    (nreverse factories))
-  "List of connection factories to use in unit tests.")
-
-;; Print testing information
-(princ (format "\nTesting %d database(s): %S\n"
-               (length emacsql-tests-connection-factories)
-               (mapcar #'car emacsql-tests-connection-factories)))
 
 (ert-deftest emacsql-escape-identifier ()
   (should-error (emacsql-escape-identifier "foo"))
@@ -217,62 +197,6 @@
    ([:alter-table foo :add-column size :integer :not-null] '()
     "ALTER TABLE foo ADD COLUMN size INTEGER NOT NULL;")))
 
-(ert-deftest emacsql-system ()
-  "A short test that fully interacts with SQLite."
-  (let ((emacsql-global-timeout emacsql-tests-timeout))
-    (dolist (factory emacsql-tests-connection-factories)
-      (emacsql-with-connection (db (funcall (cdr factory)))
-        (emacsql db [:create-temporary-table foo ([x])])
-        (should-error (emacsql db [:create-temporary-table foo ([x])]))
-        (emacsql db [:insert :into foo :values ([1] [2] [3])])
-        (should (equal (emacsql db [:select * :from foo])
-                       '((1) (2) (3))))))))
-
-(ert-deftest emacsql-foreign-system ()
-  "Tests that foreign keys work properly through Emacsql."
-  (let ((emacsql-global-timeout emacsql-tests-timeout))
-    (dolist (factory emacsql-tests-connection-factories)
-      (emacsql-with-connection (db (funcall (cdr factory)))
-        (emacsql-thread db
-          [:create-temporary-table person ([(id integer :primary-key) name])]
-          [:create-temporary-table likes
-           ([(personid integer) color]
-            (:foreign-key [personid] :references person [id]
-                          :on-delete :cascade))]
-          [:insert :into person :values ([0 "Chris"] [1 "Brian"])])
-        (should (equal (emacsql db [:select * :from person :order-by id])
-                       '((0 "Chris") (1 "Brian"))))
-        (emacsql db [:insert :into likes
-                             :values ([0 red] [0 yellow] [1 yellow])])
-        (should (equal (emacsql db [:select * :from likes
-                                            :order-by [personid color]])
-                       '((0 red) (0 yellow) (1 yellow))))
-        (emacsql db [:delete :from person :where (= id 0)])
-        (should (equal (emacsql db [:select * :from likes])
-                       '((1 yellow))))))))
-
-(ert-deftest emacsql-error ()
-  "Check that we're getting expected conditions."
-  (should-error (emacsql-compile nil [:insert :into foo :values 1])
-                :type 'emacsql-syntax)
-  (let ((emacsql-global-timeout emacsql-tests-timeout))
-    (dolist (factory emacsql-tests-connection-factories)
-      (emacsql-with-connection (db (funcall (cdr factory)))
-        (emacsql db [:create-temporary-table foo ([x])])
-        (should-error (emacsql db [:create-temporary-table foo ([x])])
-                      :type 'emacsql-error)))))
-
-(ert-deftest emacsql-special-chars ()
-  "A short test that interacts with SQLite with special characters."
-  (let ((emacsql-global-timeout 4))
-    (dolist (factory emacsql-tests-connection-factories)
-      (emacsql-with-connection (db (funcall (cdr factory)))
-        (emacsql db [:create-temporary-table test-table ([x])])
-        (emacsql db [:insert-into test-table :values ([""] [\])])
-        (should (process-live-p (emacsql-process db)))
-        (should (equal (emacsql db [:select * :from test-table])
-                       '(("") (\))))))))
-
-(provide 'emacsql-tests)
+(provide 'emacsql-compiler-tests)
 
 ;;; emacsql-tests.el ends here
diff --git a/tests/emacsql-external-tests.el b/tests/emacsql-external-tests.el
new file mode 100644
index 0000000000..10c83c38d4
--- /dev/null
+++ b/tests/emacsql-external-tests.el
@@ -0,0 +1,85 @@
+;;; emacsql-external-tests.el --- subprocess tests -*- lexical-binding: t; -*-
+
+(require 'cl-lib)
+(require 'ert)
+(require 'emacsql)
+(require 'emacsql-sqlite)
+(require 'emacsql-psql)
+
+(defvar emacsql-tests-timeout 4
+  "Be aggressive about not waiting on subprocesses in unit tests.")
+
+(defvar emacsql-tests-connection-factories
+  (let ((factories ())
+        (pgdatabase (getenv "PGDATABASE")))
+    (push (cons "sqlite" (apply-partially #'emacsql-sqlite nil)) factories)
+    (when pgdatabase
+      (push (cons "psql" (apply-partially #'emacsql-psql pgdatabase))
+            factories))
+    (nreverse factories))
+  "List of connection factories to use in unit tests.")
+
+;; Print testing information
+(princ (format "\nTesting %d database(s): %S\n"
+               (length emacsql-tests-connection-factories)
+               (mapcar #'car emacsql-tests-connection-factories)))
+
+(ert-deftest emacsql-basic ()
+  "A short test that fully interacts with SQLite."
+  (let ((emacsql-global-timeout emacsql-tests-timeout))
+    (dolist (factory emacsql-tests-connection-factories)
+      (emacsql-with-connection (db (funcall (cdr factory)))
+        (emacsql db [:create-temporary-table foo ([x])])
+        (should-error (emacsql db [:create-temporary-table foo ([x])]))
+        (emacsql db [:insert :into foo :values ([1] [2] [3])])
+        (should (equal (emacsql db [:select * :from foo])
+                       '((1) (2) (3))))))))
+
+(ert-deftest emacsql-foreign-system ()
+  "Tests that foreign keys work properly through Emacsql."
+  (let ((emacsql-global-timeout emacsql-tests-timeout))
+    (dolist (factory emacsql-tests-connection-factories)
+      (emacsql-with-connection (db (funcall (cdr factory)))
+        (emacsql-thread db
+          [:create-temporary-table person ([(id integer :primary-key) name])]
+          [:create-temporary-table likes
+           ([(personid integer) color]
+            (:foreign-key [personid] :references person [id]
+                          :on-delete :cascade))]
+          [:insert :into person :values ([0 "Chris"] [1 "Brian"])])
+        (should (equal (emacsql db [:select * :from person :order-by id])
+                       '((0 "Chris") (1 "Brian"))))
+        (emacsql db [:insert :into likes
+                             :values ([0 red] [0 yellow] [1 yellow])])
+        (should (equal (emacsql db [:select * :from likes
+                                            :order-by [personid color]])
+                       '((0 red) (0 yellow) (1 yellow))))
+        (emacsql db [:delete :from person :where (= id 0)])
+        (should (equal (emacsql db [:select * :from likes])
+                       '((1 yellow))))))))
+
+(ert-deftest emacsql-error ()
+  "Check that we're getting expected conditions."
+  (should-error (emacsql-compile nil [:insert :into foo :values 1])
+                :type 'emacsql-syntax)
+  (let ((emacsql-global-timeout emacsql-tests-timeout))
+    (dolist (factory emacsql-tests-connection-factories)
+      (emacsql-with-connection (db (funcall (cdr factory)))
+        (emacsql db [:create-temporary-table foo ([x])])
+        (should-error (emacsql db [:create-temporary-table foo ([x])])
+                      :type 'emacsql-error)))))
+
+(ert-deftest emacsql-special-chars ()
+  "A short test that interacts with SQLite with special characters."
+  (let ((emacsql-global-timeout 4))
+    (dolist (factory emacsql-tests-connection-factories)
+      (emacsql-with-connection (db (funcall (cdr factory)))
+        (emacsql db [:create-temporary-table test-table ([x])])
+        (emacsql db [:insert-into test-table :values ([""] [\])])
+        (should (process-live-p (emacsql-process db)))
+        (should (equal (emacsql db [:select * :from test-table])
+                       '(("") (\))))))))
+
+(provide 'emacsql-external-tests)
+
+;;; emacsql-external-tests.el ends here
diff --git a/tests/emacsql-tests.el b/tests/emacsql-tests.el
new file mode 100644
index 0000000000..53cb7be8b1
--- /dev/null
+++ b/tests/emacsql-tests.el
@@ -0,0 +1,10 @@
+;;; emacsql-tests.el --- test suite for Emacsql -*- lexical-binding: t; -*-
+
+(require 'emacsql-compiler-tests)
+(require 'emacsql-external-tests)
+
+;; Nothing to see here yet.
+
+(provide 'emacsql-tests)
+
+;;; emacsql-tests.el ends here



reply via email to

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