* [PATCH] Integrate module test with normal test suite
@ 2017-04-22 14:23 Philipp Stephani
2017-04-22 14:47 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Philipp Stephani @ 2017-04-22 14:23 UTC (permalink / raw)
To: emacs-devel; +Cc: Philipp Stephani
* test/Makefile.in (ELFILES): Exclude module test if modules aren't
configured.
(EMACS_TEST_DIRECTORY): Expand test directory so that it's set
correctly even if Emacs changes the current directory.
($(srcdir)/src/emacs-module-tests.log)
($(test_module)): Proper dependency tracking for test module.
* test/data/emacs-module/Makefile (ROOT): Adapt to new location.
Remove 'check' target and EMACS variable, which are no longer
necessary.
* test/src/emacs-module-tests.el (mod-test): Use EMACS_TEST_DIRECTORY
environment variable to reliably find test data.
* configure.ac (HAVE_MODULES, MODULES_SUFFIX): Add necessary
substitutions.
---
configure.ac | 2 ++
test/Makefile.in | 23 ++++++++++++++++++++--
.../mod-test => test/data/emacs-module}/Makefile | 6 +-----
.../mod-test => test/data/emacs-module}/mod-test.c | 0
.../test.el => test/src/emacs-module-tests.el | 6 +++---
5 files changed, 27 insertions(+), 10 deletions(-)
rename {modules/mod-test => test/data/emacs-module}/Makefile (90%)
rename {modules/mod-test => test/data/emacs-module}/mod-test.c (100%)
rename modules/mod-test/test.el => test/src/emacs-module-tests.el (97%)
diff --git a/configure.ac b/configure.ac
index bd8f7650cc..f3c53d7a19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3476,6 +3476,8 @@ AC_DEFUN
fi
AC_SUBST(MODULES_OBJ)
AC_SUBST(LIBMODULES)
+AC_SUBST(HAVE_MODULES)
+AC_SUBST(MODULES_SUFFIX)
### Use -lpng if available, unless '--with-png=no'.
HAVE_PNG=no
diff --git a/test/Makefile.in b/test/Makefile.in
index a1b772de21..708b60640f 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -63,7 +63,8 @@ TEST_LOCALE =
# The actual Emacs command run in the targets below.
# Prevent any setting of EMACSLOADPATH in user environment causing problems.
-emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) EMACS_TEST_DIRECTORY=$(srcdir) \
+emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) \
+ EMACS_TEST_DIRECTORY=$(abspath $(srcdir)) \
$(GDB) "$(EMACS)" $(EMACSOPT)
.PHONY: all check
@@ -124,8 +125,16 @@ SELECTOR_ACTUAL=
$(emacs) -l ert -l $$loadfile \
--eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG}
+ifeq (@HAVE_MODULES@, yes)
+maybe_exclude_module_tests :=
+else
+maybe_exclude_module_tests := -name emacs-module-tests.el -prune -o
+endif
+
ELFILES := $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
- -name "*resources" -prune -o -name "*.el" -print)
+ -name "*resources" -prune -o \
+ ${maybe_exclude_module_tests} \
+ -name "*.el" -print)
## .log files may be in a different directory for out of source builds
LOGFILES := $(patsubst %.el,%.log, \
$(patsubst $(srcdir)/%,%,$(ELFILES)))
@@ -159,6 +168,16 @@ define test_template
$(foreach test,${TESTS},$(eval $(call test_template,${test})))
+ifeq (@HAVE_MODULES@, yes)
+test_module_dir := $(srcdir)/data/emacs-module
+test_module_name := mod-test@MODULES_SUFFIX@
+test_module := $(test_module_dir)/$(test_module_name)
+$(srcdir)/src/emacs-module-tests.log: $(test_module)
+$(test_module): $(srcdir)/../src/emacs-module.[ch]
+ $(MAKE) -C $(test_module_dir) $(test_module_name) \
+ SO=$(patsubst .%,%,@MODULES_SUFFIX@)
+endif
+
## Check that there is no 'automated' subdirectory, which would
## indicate an incomplete merge from an older version of Emacs where
## the tests were arranged differently.
diff --git a/modules/mod-test/Makefile b/test/data/emacs-module/Makefile
similarity index 90%
rename from modules/mod-test/Makefile
rename to test/data/emacs-module/Makefile
index 27ae2ae3c2..d415622e58 100644
--- a/modules/mod-test/Makefile
+++ b/test/data/emacs-module/Makefile
@@ -17,8 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
-ROOT = ../..
-EMACS = $(ROOT)/src/emacs
+ROOT = ../../..
CC = gcc
LD = gcc
@@ -40,6 +39,3 @@ all:
%.o: %.c
$(CC) $(CFLAGS) -I$(ROOT)/src -c $<
-
-check:
- $(EMACS) -batch -l ert -l test.el -f ert-run-tests-batch-and-exit
diff --git a/modules/mod-test/mod-test.c b/test/data/emacs-module/mod-test.c
similarity index 100%
rename from modules/mod-test/mod-test.c
rename to test/data/emacs-module/mod-test.c
diff --git a/modules/mod-test/test.el b/test/src/emacs-module-tests.el
similarity index 97%
rename from modules/mod-test/test.el
rename to test/src/emacs-module-tests.el
index caa807d300..93e85ae22d 100644
--- a/modules/mod-test/test.el
+++ b/test/src/emacs-module-tests.el
@@ -19,9 +19,9 @@
(require 'ert)
-(add-to-list 'load-path
- (file-name-directory (or #$ (expand-file-name (buffer-file-name)))))
-(require 'mod-test)
+(require 'mod-test
+ (expand-file-name "data/emacs-module/mod-test"
+ (getenv "EMACS_TEST_DIRECTORY")))
;;
;; Basic tests.
--
2.12.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Integrate module test with normal test suite
2017-04-22 14:23 [PATCH] Integrate module test with normal test suite Philipp Stephani
@ 2017-04-22 14:47 ` Eli Zaretskii
2017-04-22 14:58 ` Philipp Stephani
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2017-04-22 14:47 UTC (permalink / raw)
To: Philipp Stephani; +Cc: phst, emacs-devel
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sat, 22 Apr 2017 16:23:27 +0200
> Cc: Philipp Stephani <phst@google.com>
>
> +$(test_module): $(srcdir)/../src/emacs-module.[ch]
> + $(MAKE) -C $(test_module_dir) $(test_module_name) \
> + SO=$(patsubst .%,%,@MODULES_SUFFIX@)
Can we get rid of the patsubst thing, please? It makes little sense
to assume in the Makefile that SO doesn't include the leading period,
only to have to delete it from the value computed by configure.
Also, I believe you need to quote the string after SO=, as it includes
whitespace.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Integrate module test with normal test suite
2017-04-22 14:47 ` Eli Zaretskii
@ 2017-04-22 14:58 ` Philipp Stephani
2017-04-29 12:39 ` Philipp Stephani
0 siblings, 1 reply; 4+ messages in thread
From: Philipp Stephani @ 2017-04-22 14:58 UTC (permalink / raw)
To: emacs-devel; +Cc: Philipp Stephani
* test/Makefile.in (ELFILES): Exclude module test if modules aren't
configured.
(EMACS_TEST_DIRECTORY): Expand test directory so that it's set
correctly even if Emacs changes the current directory.
($(srcdir)/src/emacs-module-tests.log)
($(test_module)): Proper dependency tracking for test module.
* test/data/emacs-module/Makefile (ROOT): Adapt to new location.
Remove 'check' target and EMACS variable, which are no longer
necessary.
(SO): Change to include period.
* test/src/emacs-module-tests.el (mod-test): Use EMACS_TEST_DIRECTORY
environment variable to reliably find test data.
* configure.ac (HAVE_MODULES, MODULES_SUFFIX): Add necessary
substitutions.
---
configure.ac | 2 ++
test/Makefile.in | 22 ++++++++++++++++++++--
.../mod-test => test/data/emacs-module}/Makefile | 16 ++++++----------
.../mod-test => test/data/emacs-module}/mod-test.c | 0
.../test.el => test/src/emacs-module-tests.el | 6 +++---
5 files changed, 31 insertions(+), 15 deletions(-)
rename {modules/mod-test => test/data/emacs-module}/Makefile (81%)
rename {modules/mod-test => test/data/emacs-module}/mod-test.c (100%)
rename modules/mod-test/test.el => test/src/emacs-module-tests.el (97%)
diff --git a/configure.ac b/configure.ac
index bd8f7650cc..f3c53d7a19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3476,6 +3476,8 @@ AC_DEFUN
fi
AC_SUBST(MODULES_OBJ)
AC_SUBST(LIBMODULES)
+AC_SUBST(HAVE_MODULES)
+AC_SUBST(MODULES_SUFFIX)
### Use -lpng if available, unless '--with-png=no'.
HAVE_PNG=no
diff --git a/test/Makefile.in b/test/Makefile.in
index a1b772de21..03ae32e3a6 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -63,7 +63,8 @@ TEST_LOCALE =
# The actual Emacs command run in the targets below.
# Prevent any setting of EMACSLOADPATH in user environment causing problems.
-emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) EMACS_TEST_DIRECTORY=$(srcdir) \
+emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) \
+ EMACS_TEST_DIRECTORY=$(abspath $(srcdir)) \
$(GDB) "$(EMACS)" $(EMACSOPT)
.PHONY: all check
@@ -124,8 +125,16 @@ SELECTOR_ACTUAL=
$(emacs) -l ert -l $$loadfile \
--eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG}
+ifeq (@HAVE_MODULES@, yes)
+maybe_exclude_module_tests :=
+else
+maybe_exclude_module_tests := -name emacs-module-tests.el -prune -o
+endif
+
ELFILES := $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
- -name "*resources" -prune -o -name "*.el" -print)
+ -name "*resources" -prune -o \
+ ${maybe_exclude_module_tests} \
+ -name "*.el" -print)
## .log files may be in a different directory for out of source builds
LOGFILES := $(patsubst %.el,%.log, \
$(patsubst $(srcdir)/%,%,$(ELFILES)))
@@ -159,6 +168,15 @@ define test_template
$(foreach test,${TESTS},$(eval $(call test_template,${test})))
+ifeq (@HAVE_MODULES@, yes)
+test_module_dir := $(srcdir)/data/emacs-module
+test_module_name := mod-test@MODULES_SUFFIX@
+test_module := $(test_module_dir)/$(test_module_name)
+$(srcdir)/src/emacs-module-tests.log: $(test_module)
+$(test_module): $(srcdir)/../src/emacs-module.[ch]
+ $(MAKE) -C $(test_module_dir) $(test_module_name) SO=@MODULES_SUFFIX@
+endif
+
## Check that there is no 'automated' subdirectory, which would
## indicate an incomplete merge from an older version of Emacs where
## the tests were arranged differently.
diff --git a/modules/mod-test/Makefile b/test/data/emacs-module/Makefile
similarity index 81%
rename from modules/mod-test/Makefile
rename to test/data/emacs-module/Makefile
index 27ae2ae3c2..db5e1b6808 100644
--- a/modules/mod-test/Makefile
+++ b/test/data/emacs-module/Makefile
@@ -17,29 +17,25 @@
# You should have received a copy of the GNU General Public License
# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
-ROOT = ../..
-EMACS = $(ROOT)/src/emacs
+ROOT = ../../..
CC = gcc
LD = gcc
LDFLAGS =
-# On MS-Windows, say "make SO=dll" to build the module
-SO = so
+# On MS-Windows, say "make SO=.dll" to build the module
+SO = .so
# -fPIC is a no-op on Windows, but causes a compiler warning
-ifeq ($(SO),dll)
+ifeq ($(SO),.dll)
CFLAGS = -std=gnu99 -ggdb3 -Wall
else
CFLAGS = -std=gnu99 -ggdb3 -Wall -fPIC
endif
-all: mod-test.$(SO)
+all: mod-test$(SO)
-%.$(SO): %.o
+%$(SO): %.o
$(LD) -shared $(LDFLAGS) -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) -I$(ROOT)/src -c $<
-
-check:
- $(EMACS) -batch -l ert -l test.el -f ert-run-tests-batch-and-exit
diff --git a/modules/mod-test/mod-test.c b/test/data/emacs-module/mod-test.c
similarity index 100%
rename from modules/mod-test/mod-test.c
rename to test/data/emacs-module/mod-test.c
diff --git a/modules/mod-test/test.el b/test/src/emacs-module-tests.el
similarity index 97%
rename from modules/mod-test/test.el
rename to test/src/emacs-module-tests.el
index caa807d300..93e85ae22d 100644
--- a/modules/mod-test/test.el
+++ b/test/src/emacs-module-tests.el
@@ -19,9 +19,9 @@
(require 'ert)
-(add-to-list 'load-path
- (file-name-directory (or #$ (expand-file-name (buffer-file-name)))))
-(require 'mod-test)
+(require 'mod-test
+ (expand-file-name "data/emacs-module/mod-test"
+ (getenv "EMACS_TEST_DIRECTORY")))
;;
;; Basic tests.
--
2.12.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Integrate module test with normal test suite
2017-04-22 14:58 ` Philipp Stephani
@ 2017-04-29 12:39 ` Philipp Stephani
0 siblings, 0 replies; 4+ messages in thread
From: Philipp Stephani @ 2017-04-29 12:39 UTC (permalink / raw)
To: emacs-devel; +Cc: Philipp Stephani
[-- Attachment #1: Type: text/plain, Size: 5835 bytes --]
Pushed as bfc0f610ba.
Philipp Stephani <p.stephani2@gmail.com> schrieb am Sa., 22. Apr. 2017 um
16:58 Uhr:
> * test/Makefile.in (ELFILES): Exclude module test if modules aren't
> configured.
> (EMACS_TEST_DIRECTORY): Expand test directory so that it's set
> correctly even if Emacs changes the current directory.
> ($(srcdir)/src/emacs-module-tests.log)
> ($(test_module)): Proper dependency tracking for test module.
>
> * test/data/emacs-module/Makefile (ROOT): Adapt to new location.
> Remove 'check' target and EMACS variable, which are no longer
> necessary.
> (SO): Change to include period.
>
> * test/src/emacs-module-tests.el (mod-test): Use EMACS_TEST_DIRECTORY
> environment variable to reliably find test data.
>
> * configure.ac (HAVE_MODULES, MODULES_SUFFIX): Add necessary
> substitutions.
> ---
> configure.ac | 2 ++
> test/Makefile.in | 22
> ++++++++++++++++++++--
> .../mod-test => test/data/emacs-module}/Makefile | 16 ++++++----------
> .../mod-test => test/data/emacs-module}/mod-test.c | 0
> .../test.el => test/src/emacs-module-tests.el | 6 +++---
> 5 files changed, 31 insertions(+), 15 deletions(-)
> rename {modules/mod-test => test/data/emacs-module}/Makefile (81%)
> rename {modules/mod-test => test/data/emacs-module}/mod-test.c (100%)
> rename modules/mod-test/test.el => test/src/emacs-module-tests.el (97%)
>
> diff --git a/configure.ac b/configure.ac
> index bd8f7650cc..f3c53d7a19 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -3476,6 +3476,8 @@ AC_DEFUN
> fi
> AC_SUBST(MODULES_OBJ)
> AC_SUBST(LIBMODULES)
> +AC_SUBST(HAVE_MODULES)
> +AC_SUBST(MODULES_SUFFIX)
>
> ### Use -lpng if available, unless '--with-png=no'.
> HAVE_PNG=no
> diff --git a/test/Makefile.in b/test/Makefile.in
> index a1b772de21..03ae32e3a6 100644
> --- a/test/Makefile.in
> +++ b/test/Makefile.in
> @@ -63,7 +63,8 @@ TEST_LOCALE =
>
> # The actual Emacs command run in the targets below.
> # Prevent any setting of EMACSLOADPATH in user environment causing
> problems.
> -emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE)
> EMACS_TEST_DIRECTORY=$(srcdir) \
> +emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) \
> + EMACS_TEST_DIRECTORY=$(abspath $(srcdir)) \
> $(GDB) "$(EMACS)" $(EMACSOPT)
>
> .PHONY: all check
> @@ -124,8 +125,16 @@ SELECTOR_ACTUAL=
> $(emacs) -l ert -l $$loadfile \
> --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})"
> ${WRITE_LOG}
>
> +ifeq (@HAVE_MODULES@, yes)
> +maybe_exclude_module_tests :=
> +else
> +maybe_exclude_module_tests := -name emacs-module-tests.el -prune -o
> +endif
> +
> ELFILES := $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
> - -name "*resources" -prune -o -name "*.el" -print)
> + -name "*resources" -prune -o \
> + ${maybe_exclude_module_tests} \
> + -name "*.el" -print)
> ## .log files may be in a different directory for out of source builds
> LOGFILES := $(patsubst %.el,%.log, \
> $(patsubst $(srcdir)/%,%,$(ELFILES)))
> @@ -159,6 +168,15 @@ define test_template
>
> $(foreach test,${TESTS},$(eval $(call test_template,${test})))
>
> +ifeq (@HAVE_MODULES@, yes)
> +test_module_dir := $(srcdir)/data/emacs-module
> +test_module_name := mod-test@MODULES_SUFFIX@
> +test_module := $(test_module_dir)/$(test_module_name)
> +$(srcdir)/src/emacs-module-tests.log: $(test_module)
> +$(test_module): $(srcdir)/../src/emacs-module.[ch]
> + $(MAKE) -C $(test_module_dir) $(test_module_name)
> SO=@MODULES_SUFFIX@
> +endif
> +
> ## Check that there is no 'automated' subdirectory, which would
> ## indicate an incomplete merge from an older version of Emacs where
> ## the tests were arranged differently.
> diff --git a/modules/mod-test/Makefile b/test/data/emacs-module/Makefile
> similarity index 81%
> rename from modules/mod-test/Makefile
> rename to test/data/emacs-module/Makefile
> index 27ae2ae3c2..db5e1b6808 100644
> --- a/modules/mod-test/Makefile
> +++ b/test/data/emacs-module/Makefile
> @@ -17,29 +17,25 @@
> # You should have received a copy of the GNU General Public License
> # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
>
> -ROOT = ../..
> -EMACS = $(ROOT)/src/emacs
> +ROOT = ../../..
>
> CC = gcc
> LD = gcc
> LDFLAGS =
>
> -# On MS-Windows, say "make SO=dll" to build the module
> -SO = so
> +# On MS-Windows, say "make SO=.dll" to build the module
> +SO = .so
> # -fPIC is a no-op on Windows, but causes a compiler warning
> -ifeq ($(SO),dll)
> +ifeq ($(SO),.dll)
> CFLAGS = -std=gnu99 -ggdb3 -Wall
> else
> CFLAGS = -std=gnu99 -ggdb3 -Wall -fPIC
> endif
>
> -all: mod-test.$(SO)
> +all: mod-test$(SO)
>
> -%.$(SO): %.o
> +%$(SO): %.o
> $(LD) -shared $(LDFLAGS) -o $@ $<
>
> %.o: %.c
> $(CC) $(CFLAGS) -I$(ROOT)/src -c $<
> -
> -check:
> - $(EMACS) -batch -l ert -l test.el -f ert-run-tests-batch-and-exit
> diff --git a/modules/mod-test/mod-test.c
> b/test/data/emacs-module/mod-test.c
> similarity index 100%
> rename from modules/mod-test/mod-test.c
> rename to test/data/emacs-module/mod-test.c
> diff --git a/modules/mod-test/test.el b/test/src/emacs-module-tests.el
> similarity index 97%
> rename from modules/mod-test/test.el
> rename to test/src/emacs-module-tests.el
> index caa807d300..93e85ae22d 100644
> --- a/modules/mod-test/test.el
> +++ b/test/src/emacs-module-tests.el
> @@ -19,9 +19,9 @@
>
> (require 'ert)
>
> -(add-to-list 'load-path
> - (file-name-directory (or #$ (expand-file-name
> (buffer-file-name)))))
> -(require 'mod-test)
> +(require 'mod-test
> + (expand-file-name "data/emacs-module/mod-test"
> + (getenv "EMACS_TEST_DIRECTORY")))
>
> ;;
> ;; Basic tests.
> --
> 2.12.2
>
>
[-- Attachment #2: Type: text/html, Size: 7417 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-29 12:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-22 14:23 [PATCH] Integrate module test with normal test suite Philipp Stephani
2017-04-22 14:47 ` Eli Zaretskii
2017-04-22 14:58 ` Philipp Stephani
2017-04-29 12:39 ` Philipp Stephani
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).