Skip to content

Commit 7770a46

Browse files
committed
Merge pull request #1063 from gracjan/pr-coverage
Add code coverage
2 parents b71b3c8 + dcf131a commit 7770a46

File tree

6 files changed

+3069
-105
lines changed

6 files changed

+3069
-105
lines changed

Makefile

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ INSTALL_INFO = install-info
2424
# This is particularly useful when EMACS is set in ~/.bash_profile
2525
#
2626
EMACS := $(shell which "$${EMACS}" || which "emacs")
27+
EMACS_VERSION := $(shell "$(EMACS)" -Q --batch --eval '(princ emacs-version)')
2728

2829
EFLAGS = --eval "(add-to-list 'load-path (expand-file-name \"tests/compat\") 'append)" \
2930
--eval "(when (< emacs-major-version 24) \
3031
(setq byte-compile-warnings '(not cl-functions)))" \
3132
--eval '(setq byte-compile-error-on-warn t)' \
32-
--eval '(when (not (version< emacs-version "24.4")) (setq load-prefer-newer t))'
33+
--eval '(when (not (version< emacs-version "24.4")) (setq load-prefer-newer t))' \
34+
--eval '(defun byte-compile-dest-file (filename) \
35+
(concat (file-name-directory filename) "build-" emacs-version "/" \
36+
(file-name-nondirectory filename) "c"))'
3337

3438
BATCH = $(EMACS) $(EFLAGS) --batch -Q -L .
3539

@@ -75,17 +79,13 @@ ELFILES = \
7579
haskell-utils.el \
7680
inf-haskell.el
7781

78-
ELCFILES = $(ELFILES:.el=.elc)
82+
ELCHECKS := $(shell echo tests/*-tests.el)
83+
7984
AUTOLOADS = haskell-mode-autoloads.el
8085

8186
PKG_DIST_FILES = $(ELFILES) logo.svg NEWS haskell-mode.info dir
82-
ELCHECKS=$(addprefix check-, $(ELFILES:.el=))
83-
84-
%.elc: %.el
85-
@$(BATCH) \
86-
-f batch-byte-compile $*.el
8787

88-
.PHONY: all compile info clean check $(ELCHECKS) elpa package check-emacs-version
88+
.PHONY: all compile info clean check check-emacs-version
8989

9090
all: check-emacs-version compile $(AUTOLOADS) info
9191

@@ -100,20 +100,30 @@ check-emacs-version :
100100
(message \" 3. make EMACS=/path/to/emacs\") \
101101
(kill-emacs 2))"
102102

103-
compile: $(ELCFILES)
104-
105-
$(ELCHECKS): check-%: %.el %.elc
106-
@$(BATCH) --eval '(when (check-declare-file "$*.el") (error "check-declare failed"))'
107-
@if [ -f "$(<:%.el=tests/%-tests.el)" ]; then \
108-
$(BATCH) -l "$(<:%.el=tests/%-tests.el)" -f ert-run-tests-batch-and-exit; \
103+
compile: build-$(EMACS_VERSION)
104+
105+
build-$(EMACS_VERSION) : $(ELFILES)
106+
if [ ! -d $@ ]; then mkdir $@; fi
107+
$(BATCH) -f batch-byte-compile-if-not-done $^
108+
109+
check-%: tests/%-tests.el
110+
$(BATCH) -l "$<" -f ert-run-tests-batch-and-exit;
111+
112+
check: $(ELCHECKS) build-$(EMACS_VERSION)
113+
$(BATCH) --eval "(when (>= emacs-major-version 24) \
114+
(require 'undercover) \
115+
(undercover \"*.el\" (:exclude \"haskell-mode-pkg.el\")))" \
116+
$(patsubst %,-l %,$(ELCHECKS)) \
117+
-f ert-run-tests-batch-and-exit
118+
@TAB=$$(echo "\t"); \
119+
if grep -Hn "[ $${TAB}]\+\$$" *.el; then \
120+
echo "Some files contain whitespace at the end of lines, correct it"; \
121+
exit 3; \
109122
fi
110-
@echo "--"
111-
112-
check: $(ELCHECKS)
113123
@echo "checks passed!"
114124

115125
clean:
116-
$(RM) $(ELCFILES) $(AUTOLOADS) $(AUTOLOADS:.el=.elc) haskell-mode.info dir
126+
$(RM) -r build-$(EMACS_VERSION) $(AUTOLOADS) $(AUTOLOADS:.el=.elc) haskell-mode.info dir
117127

118128
info: haskell-mode.info dir
119129

@@ -158,7 +168,7 @@ doc/html : doc/html/index.html \
158168
deploy-manual : doc/html
159169
cd doc && ./deploy-manual.sh
160170

161-
$(AUTOLOADS): $(ELFILES) haskell-mode.elc
171+
$(AUTOLOADS): $(ELFILES)
162172
$(BATCH) \
163173
--eval '(setq make-backup-files nil)' \
164174
--eval '(setq generated-autoload-file "$(CURDIR)/$@")' \

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
This is an Emacs mode for editing, debugging and developing Haskell programs.
55

6+
[![Coverage Status](https://coveralls.io/repos/haskell/haskell-mode/badge.svg?branch=master&service=github)](https://coveralls.io/github/haskell/haskell-mode?branch=master)
67
[![Build Status](https://travis-ci.org/haskell/haskell-mode.svg?branch=master)](https://travis-ci.org/haskell/haskell-mode)
78
[![Melpa Status](http://melpa.org/packages/haskell-mode-badge.svg)](http://melpa.org/#/haskell-mode)
89
[![Melpa Stable Status](http://stable.melpa.org/packages/haskell-mode-badge.svg)](http://stable.melpa.org/#/haskell-mode)

0 commit comments

Comments
 (0)