[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
- [nongnu] elpa/emacsql f030b9952d 224/427: Fix up psql-connection., (continued)
- [nongnu] elpa/emacsql f030b9952d 224/427: Fix up psql-connection., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql dc2afbbc1f 221/427: Adjust the Emacsql wire protocol., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6318472b20 223/427: Link the Makefiles together., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a7728339ba 216/427: Switch to custom middleware., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ab53199d07 232/427: Fix escaping issue in middleware., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6ad267f93b 229/427: Change :value to :scalar., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1146f2e26a 233/427: Flesh out the changes in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ed77eac846 237/427: Add string prepared statements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 847196cafa 226/427: Set tty to raw in psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3e5ce21b0d 242/427: Tweak the new implementation notes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a459708684 244/427: Move tests into their own directory.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 4db068920d 247/427: Provide MySQL front-end., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql dce6736e04 249/427: Oops, add new MySQL module to the Makefile., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fcba876d0e 251/427: Solve the tty (pty) issue in MySQL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fb0e2d5423 256/427: Fix typecase typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a6e859f1b5 260/427: Normalize darwin OS., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4332bd67ec 271/427: Flesh out the main header a bit more., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4e9297233d 273/427: Don't rely on C99 mode., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 7963261ef3 270/427: Bump to version 1.0.0., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6f6533ab70 272/427: Add Cygwin note., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 45f43323ad 275/427: Check the compiler error code., ELPA Syncer, 2022/12/13