Skip to content

Commit

Permalink
Dialyzer, tests and elisp fixes for otp17, otp25, otp26 (#279)
Browse files Browse the repository at this point in the history
* Dialyzer and tests for otp17 + otp25

* app.src + otp26

* don't change src-file for deps

* byte-compile fixes

* emacs byte-compile docker tests

* linum-mode fix for new emacs (#278)

* linum-mode fix for new emacs

* upgrade tests

* use ubuntu-20.04 for github actions

* correct OTP 25.3 version
  • Loading branch information
sebastiw authored Sep 26, 2023
1 parent db440d4 commit d10b79a
Show file tree
Hide file tree
Showing 28 changed files with 192 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ on:

jobs:
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
name: OTP ${{matrix.otp}}
strategy:
matrix:
otp: [20.3.8.26, 21.3.8.17, 22.3.4.9, 23.3.1, 24.0.5]
otp: [22.3.4.9, 23.3.4.5, 24.3.3, 25.3]
emacs: [27.1] # 24.5, 26.3,

steps:
Expand Down
35 changes: 21 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# MAKEFLAGS = -s
LIBS = lib/edts lib/edts_debug lib/edts_dialyzer lib/edts_xref
DEPS = mochiweb meck
MKDIR ?= mkdir
MKDIR_FLAGS ?= "-p"
GIT ?= git
Expand All @@ -26,19 +27,21 @@ release: rel/releases
rel/releases:
$(MKDIR) $(MKDIR_FLAGS) rel/releases

deps/mochiweb:
$(GIT) clone "https://github.com/mochi/mochiweb" $@
cd $@ && $(GIT) checkout --detach 835b107a4da4550080d032623ff6ae9a18d02c37
deps/mochiweb/src:
$(GIT) clone "https://github.com/mochi/mochiweb" deps/mochiweb
cd deps/mochiweb && $(GIT) checkout --detach 835b107a4da4550080d032623ff6ae9a18d02c37
deps/meck/src:
$(GIT) clone "https://github.com/eproxus/meck" deps/meck
cd deps/meck && $(GIT) checkout --detach cc47aab4b64a46a5409c1a93353d44a367b41454

deps/mochiweb: deps/mochiweb/src deps/mochiweb/ebin
deps/meck: deps/meck/src deps/meck/ebin

$(DEPS:%=deps/%/ebin):
$(MKDIR) $(MKDIR_FLAGS) $@
$(ERLC) +debug_info -o $@ -I$(@:/ebin=/include) -I$(@:/ebin=/src) $(@:/ebin=/src)/*.erl
# reltool doesn't support unrecognized options
sed -i '/applications/{N; s/,$$// };/licenses/d;/links/d' $@/src/mochiweb.app.src
$(MAKE) -C $@ MAKEFLAGS="$(MAKEFLAGS)"
deps/meck:
$(GIT) clone "https://github.com/eproxus/meck" $@
cd $@ && $(GIT) checkout --detach cc47aab4b64a46a5409c1a93353d44a367b41454
$(MKDIR) $(MKDIR_FLAGS) $@/ebin
$(ERLC) +debug_info -o $@/ebin -I$@/include -I$@/src $@/src/*.erl
sed -i '/env/{ s/,$$// };/licenses/d;/links/{ N; N; N; d }' $@/src/meck.app.src
cp $@/src/meck.app.src $@/ebin/meck.app
sed 'H; $$!d; x; s/[[:space:]]\+%[^\n]\+//g; s/,[[:space:]]\+{licenses[^\n]\+//; s/{links, \[[^]]\+]}//;' $(@:/ebin=/src)/$(@:deps/%/ebin=%).app.src > $@/$(@:deps/%/ebin=%).app

.PHONY: $(LIBS)
$(LIBS):
Expand All @@ -64,7 +67,8 @@ dialyzer: erlang.plt edts.plt
erlang.plt:
$(DIALYZER) --quiet --build_plt --output_plt $@ --apps \
erts kernel stdlib mnesia crypto sasl eunit \
syntax_tools compiler tools debugger dialyzer
syntax_tools compiler tools debugger dialyzer \
wx runtime_tools
edts.plt: erlang.plt
$(DIALYZER) --add_to_plt --plt erlang.plt -r lib/ deps/ --output_plt $@

Expand Down Expand Up @@ -109,4 +113,7 @@ byte-compilation-test:

.PHONY: $(OTP_TESTS)
$(OTP_TESTS):
$(DOCKER) build -f test_data/manual/Dockerfile.$@ .
$(DOCKER) build \
--ulimit nofile=4096 \
-f test_data/manual/Dockerfile.$@ .

8 changes: 6 additions & 2 deletions elisp/edts/edts-alist.el
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@


(defun edts-alist-select (predicate alist)
"Return all elements of ALIST for which PREDICATE returns a non-nil value. PREDICATE is a function that takes two argument KEY and VALUE."
"Return all elements of ALIST for which PREDICATE returns a
non-nil value. PREDICATE is a function that takes two argument
KEY and VALUE."
(-filter (lambda (el) (funcall predicate (car el) (cdr el))) alist))


(defun edts-alist-filter (predicate alist)
"Remove all elements of ALIST for which PREDICATE returns a non-nil value. PREDICATE is a function that takes two argument KEY and VALUE."
"Remove all elements of ALIST for which PREDICATE returns a
non-nil value. PREDICATE is a function that takes two argument
KEY and VALUE."
(-filter (lambda (el) (not (funcall predicate (car el) (cdr el)))) alist))


Expand Down
8 changes: 2 additions & 6 deletions elisp/edts/edts-code.el
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ the module to be compiled as the only argument.")
'(edts-code-eunit)
"Hooks to run after compilation finishes. Hooks are called with the
compilation result as a symbol as the only argument")
(defvaralias ;; Compatibility
'edts-code-after-compilation-hook
'edts-code-after-compile-hook
"This variable is deprecated, use `edts-code-after-compile-hook'")

(defvar edts-code-buffer-issues nil
"A plist describing the current issues (errors and warnings) in the
Expand Down Expand Up @@ -97,8 +93,8 @@ with severity as key and a lists of issues as values"
(plist-put edts-code-buffer-issues type issues)))

(defun edts-code-buffer-status ()
"Return 'error if there are any edts errors in current buffer,
'warning if there are warnings and 'ok otherwise."
"Return `'error' if there are any edts errors in current buffer,
`'warning' if there are warnings and `'ok' otherwise."
(cl-block nil
(let ((status 'ok)
(issues edts-code-buffer-issues))
Expand Down
6 changes: 3 additions & 3 deletions elisp/edts/edts-complete-built-in-function-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@

(defun edts-complete-built-in-function-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-built-in-function-candidates))
('none (edts-complete-normal-built-in-function-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-built-in-function-candidates))
(none (edts-complete-normal-built-in-function-candidates))))

(defun edts-complete-normal-built-in-function-candidates ()
"Produces the completion list for normal (unqoted) local functions."
Expand Down
8 changes: 4 additions & 4 deletions elisp/edts/edts-complete-exported-function-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
(let ((point (or ac-point (point))))
(when (edts-complete-exported-function-p point)
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
(double-quoted nil) ; Don't complete inside strings
(otherwise
(edts-log-debug "Initializing exported function completions")
(let* ((module (ferl-symbol-at (- point 1)))
Expand All @@ -66,9 +66,9 @@

(defun edts-complete-exported-function-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-exported-function-candidates))
('none (edts-complete-normal-exported-function-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-exported-function-candidates))
(none (edts-complete-normal-exported-function-candidates))))

(defun edts-complete-normal-exported-function-candidates ()
"Produces the completion list for normal (unqoted) exported functions."
Expand Down
6 changes: 3 additions & 3 deletions elisp/edts/edts-complete-imported-function-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

(defun edts-complete-imported-function-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-imported-function-candidates))
('none (edts-complete-normal-imported-function-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-imported-function-candidates))
(none (edts-complete-normal-imported-function-candidates))))

(defun edts-complete-normal-imported-function-candidates ()
"Produces the completion list for normal (unqoted) imported functions."
Expand Down
6 changes: 3 additions & 3 deletions elisp/edts/edts-complete-keyword-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@

(defun edts-complete-keyword-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-keyword-candidates))
('none (edts-complete-normal-keyword-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-keyword-candidates))
(none (edts-complete-normal-keyword-candidates))))

(defun edts-complete-normal-keyword-candidates ()
"Produces the completion list for normal (unqoted) local functions."
Expand Down
8 changes: 4 additions & 4 deletions elisp/edts/edts-complete-local-function-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@
"Initialize local function completions."
(when (edts-complete-local-function-p)
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
(double-quoted nil) ; Don't complete inside strings
(otherwise
(edts-log-debug "Initializing local function completions")
(setq edts-complete-local-function-candidates
(mapcar #'car (ferl-local-functions)))))))

(defun edts-complete-local-function-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-local-function-candidates))
('none (edts-complete-normal-local-function-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-local-function-candidates))
(none (edts-complete-normal-local-function-candidates))))

(defun edts-complete-normal-local-function-candidates ()
"Produces the completion list for normal (unqoted) local functions."
Expand Down
6 changes: 3 additions & 3 deletions elisp/edts/edts-complete-macro-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@

(defun edts-complete-macro-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-macro-candidates))
('none (edts-complete-normal-macro-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-macro-candidates))
(none (edts-complete-normal-macro-candidates))))

(defun edts-complete-normal-macro-candidates ()
"Produces the completion list for normal (unqoted) macros."
Expand Down
6 changes: 3 additions & 3 deletions elisp/edts/edts-complete-module-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@

(defun edts-complete-module-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-module-candidates))
('none (edts-complete-normal-module-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-module-candidates))
(none (edts-complete-normal-module-candidates))))

(defun edts-complete-normal-module-candidates ()
"Produces the completion list for normal (unqoted) modules."
Expand Down
8 changes: 4 additions & 4 deletions elisp/edts/edts-complete-record-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"Initialize record completions."
(when (edts-complete-record-p ac-point)
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
(double-quoted nil) ; Don't complete inside strings
(otherwise
(edts-log-debug "Initializing record completions")
(cl-flet ((rec-name (rec) (cdr (assoc 'record rec))))
Expand All @@ -65,9 +65,9 @@

(defun edts-complete-record-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted (edts-complete-single-quoted-record-candidates))
('none (edts-complete-normal-record-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted (edts-complete-single-quoted-record-candidates))
(none (edts-complete-normal-record-candidates))))

(defun edts-complete-normal-record-candidates ()
"Produces the completion list for normal (unqoted) records. Unimplemented"
Expand Down
6 changes: 3 additions & 3 deletions elisp/edts/edts-complete-variable-source.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@

(defun edts-complete-variable-candidates ()
(cl-case (ferl-point-inside-quotes)
('double-quoted nil) ; Don't complete inside strings
('single-quoted nil) ; No single-quoted variables
('none (edts-complete-normal-variable-candidates))))
(double-quoted nil) ; Don't complete inside strings
(single-quoted nil) ; No single-quoted variables
(none (edts-complete-normal-variable-candidates))))

(defun edts-complete-normal-variable-candidates ()
"Generates the auto-complete candidate list for variables. Matches variables
Expand Down
2 changes: 1 addition & 1 deletion elisp/edts/edts-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ left-fringe or right-fringe."
:group 'edts)

(defvar edts-face-modeline-remap-cookie nil
"A list of The 'cookies' returned from face-remap-add-relative, so
"A list of The `cookies' returned from face-remap-add-relative, so
that we can reset our face remappings.")
(make-variable-buffer-local 'edts-face-modeline-remap-cookie)

Expand Down
2 changes: 1 addition & 1 deletion elisp/edts/edts-rpc.el
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ inside a `with-temp-buffer'."
(defun edts-rpc--parse-http-response-status ()
(save-excursion
(goto-char (point-min))
(s-split " " (buffer-substring (point) (point-at-eol)))))
(s-split " " (buffer-substring (point) (line-end-position)))))

(defun edts-rpc-command-url (command)
"Construct the edts command url."
Expand Down
6 changes: 4 additions & 2 deletions elisp/edts/edts-shell.el
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ PWD and running COMMAND."
(ignore-errors
(make-local-variable 'show-paren-mode)
(show-paren-mode 1))
(linum-mode -1)
(if (version<= "26.0.50" emacs-version)
(display-line-numbers-mode -1)
(linum-mode -1))
(setq show-trailing-whitespace nil)
(set-process-query-on-exit-flag (get-buffer-process (current-buffer)) nil)
(add-hook 'kill-buffer-hook #'edts-shell--kill-buffer-hook t t)
Expand Down Expand Up @@ -257,7 +259,7 @@ respectively so we can use them later when fontifying user input."
(while (< start end)
(let ((temp-end nil))
(cl-case (get-text-property start 'field)
('output
(output
(setq temp-end (edts-shell-output-end start end))
(font-lock-default-fontify-region start temp-end loudly))
(otherwise
Expand Down
2 changes: 1 addition & 1 deletion elisp/edts/edts-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@
(defmacro edts-test-case (suite name args desc &rest body)
"Define a testcase in SUITE. All other arguments are the same is in
`ert-deftest'."
(declare (indent 3))
(unless body
(error "edts-test-case: Not enough arguments"))
(declare (indent 3))
`(macroexpand
(ert-deftest ,name ,args ,desc :tags '(,suite edts-test-suite) ,@body)))

Expand Down
8 changes: 7 additions & 1 deletion lib/edts/src/edts_eunit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
reason/0
]).

-dialyzer({nowarn_function, get_module_tests/1}).

%%%_* API ======================================================================

%%------------------------------------------------------------------------------
Expand Down Expand Up @@ -86,12 +88,16 @@ try_run_tests(Module) ->
do_run_tests(Module) ->
debug("running eunit tests in: ~p", [Module]),
Listener = edts_eunit_listener:start([{parent, self()}]),
Tests = filter_module_tests(Module, eunit_data:get_module_tests(Module)),
Tests = filter_module_tests(Module, get_module_tests(Module)),
case eunit_server:start_test(eunit_server, Listener, Tests, []) of
{ok, Ref} -> do_run_tests(Ref, Listener, 20000);
{error, Err} -> {error, Err}
end.

-spec get_module_tests(module()) -> list().
get_module_tests(Module) ->
eunit_data:get_module_tests(Module).

filter_module_tests(Module, Tests) ->
Fun = fun({_Type, TestModule, _Fun} = Test, Acc) when TestModule =:= Module ->
[Test|Acc];
Expand Down
2 changes: 1 addition & 1 deletion lib/edts/src/edts_module_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ init(_Args) ->

%%------------------------------------------------------------------------------
%% @doc Handle call messages
-spec handle_call(term(), {pid(), atom()}, state()) ->
-spec handle_call(term(), {pid(), any()}, state()) ->
{reply, Reply::term(), state()} |
{reply, Reply::term(), state(), timeout()} |
{noreply, state()} |
Expand Down
2 changes: 1 addition & 1 deletion lib/edts/src/edts_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ init([]) ->
%% Handling call messages
%% @end
%%
-spec handle_call(term(), {pid(), atom()}, state()) ->
-spec handle_call(term(), {pid(), any()}, state()) ->
{reply, Reply::term(), state()} |
{reply, Reply::term(), state(), timeout()} |
{noreply, state()} |
Expand Down
9 changes: 8 additions & 1 deletion lib/edts/src/edts_syntax.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,18 @@ parse_expressions(String) ->
Tokens ->
case erl_parse:parse_exprs(Tokens) of
{ok, AnnoTerms} ->
{ok, lists:map(fun erl_parse:anno_to_term/1, AnnoTerms)};
{ok, lists:map(fun anno_to_term/1, AnnoTerms)};
Err -> Err
end
end.

anno_to_term(T) ->
case code:which(erl_anno) of
non_existing ->
T;
_ ->
erl_parse:anno_to_term(T)
end.

%%------------------------------------------------------------------------------
%% @doc
Expand Down
5 changes: 0 additions & 5 deletions lib/edts_dialyzer/edts-dialyzer.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
:group 'edts
:type 'boolean)

(define-obsolete-variable-alias
'edts-code-inhibit-dialyzer-on-compile
'edts-dialyzer-inhibit-on-compile
"2017-04-15")

(defun edts-dialyzer-init ()
"Initialize edts-dialyzer."
(add-to-list 'edts-code-issue-types 'edts-dialyzer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ COPY . .
RUN emacs -Q --batch \
-L ${PWD} \
-l test_data/package-install-deps.el \
-f batch-byte-compile *.el elisp/edts/*.el lib/**/*.el
--eval '(byte-recompile-directory "." 0 t)' \
2> "compile.log"

# RUN emacs -Q --batch \
# -L ${PWD} \
# -l test_data/package-install-deps.el \
# --eval '(byte-compile-file "edts-mode.el")' \
# --eval '(with-current-buffer "*EDTS compile*" (write-file "edts_compile.log"))' && \
# cat edts_compile.log
Loading

0 comments on commit d10b79a

Please sign in to comment.