Skip to content

Commit ff9d44e

Browse files
committed
Make changes in preparation for LFE 2.0.
1 parent 1402201 commit ff9d44e

7 files changed

+71
-23
lines changed

include/ltest-macros.lfe

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
(defun to-unders (atm)
3535
(re:replace (atom_to_list atm) "-" "_" '(#(return list) global)))
3636

37+
;; XXX this is no longer used anywhere, right? remove it!
3738
(defun list-body
3839
((body) (when (is_list body))
3940
body)
@@ -89,7 +90,7 @@
8990
;;;===================================================================
9091

9192
(eval-when-compile
92-
;;Return true if we have (tuple "name"...) or #("Name"...)
93+
;; Return true if we have (tuple "name"...) or #("Name"...)
9394
(defun is-named-tuple
9495
((t) (when (is_tuple t))
9596
(io_lib:printable_list (element 1 t)))
@@ -98,7 +99,7 @@
9899
(io_lib:printable_list (cadr t))))
99100
((other) 'false))
100101

101-
;;Return (tuple "Name" lambda() ...) from (tuple "Name" ...)
102+
;; Return (tuple "Name" lambda() ...) from (tuple "Name" ...)
102103
(defun mk-named-tuple
103104
((t) (when (is_tuple t))
104105
`(tuple ,(element 1 t)
@@ -209,7 +210,7 @@
209210

210211
(defmacro is-exit
211212
"Equivalent to [[is-exception/3]] with `'exit` as `expected-class`."
212-
(`(,expression) `(is-exit _ ,expression))
213+
(`(,expression) `(is-exit _ ,expression))
213214
(`(,expected-term ,expression) `(assertExit ,expected-term ,expression)))
214215

215216
(defmacro is-not-exit
@@ -221,7 +222,7 @@
221222

222223
(defmacro is-throw
223224
"Equivalent to [[is-exception/3]] with `'throw` as `expected-class`."
224-
(`(,expression) `(is-throw _ ,expression))
225+
(`(,expression) `(is-throw _ ,expression))
225226
(`(,expected-term ,expression) `(assertThrow ,expected-term ,expression)))
226227

227228
(defmacro is-not-throw
@@ -285,17 +286,17 @@
285286

286287
(defmacro is-exit*
287288
"Return a test object that wraps [[is-exit/2]]"
288-
(`(,expression) `(is-exit* _ ,expression))
289+
(`(,expression) `(is-exit* _ ,expression))
289290
(`(,expected-term ,expression) `(_assertExit ,expected-term ,expression)))
290291

291292
(defmacro is-not-exit* (expected-term expression)
292293
"Return a test object that wraps [[is-not-exit/2]]."
293-
(`(,expression) `(is-not-exit* _ ,expression))
294+
(`(,expression) `(is-not-exit* _ ,expression))
294295
(`(,expected-term ,body) `(_test (is-not-exit ,expected-term ,expression))))
295296

296297
(defmacro is-throw* (expected-term expression)
297298
"Return a test object that wraps [[is-throw/2]]."
298-
(`(,expression) `(is-throw* _ ,expression))
299+
(`(,expression) `(is-throw* _ ,expression))
299300
(`(,expected-term ,body) `(_assertThrow ,expected-term ,expression)))
300301

301302
(defmacro is-not-throw* (expected-term expression)

include/ltest-records.lfe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(defrecord state
2-
(status (orddict:new))
2+
status
33
test-type
44
(ok 0)
55
(fail 0)

rebar.config

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,30 @@
1010

1111
{pre_hooks, [
1212
%% DEBUG:
13-
% {"(linux|darwin|solaris|freebsd|netbsd|openbsd)", compile,
14-
% "echo REBAR_DEPS_DIR = $REBAR_DEPS_DIR"},
13+
%% {"(linux|darwin|solaris|freebsd|netbsd|openbsd)", compile,
14+
%% "echo REBAR_DEPS_DIR = $REBAR_DEPS_DIR"},
1515
{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", app_compile,
1616
"$REBAR_DEPS_DIR/lfe/bin/lfe $REBAR_DEPS_DIR/lfe/bin/lfec"
1717
" -o $REBAR_DEPS_DIR/ltest/ebin"
18-
" src/*.lfe"},
19-
%% TODO: equivalent win32 hook
20-
{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", eunit,
21-
"$REBAR_DEPS_DIR/lfe/bin/lfe $REBAR_DEPS_DIR/lfe/bin/lfec"
22-
" -o $REBAR_DEPS_DIR/ltest/ebin"
23-
" test/*.lfe"}
18+
" src/*.lfe"}
2419
%% TODO: Test this on a win32 box
2520
%% {"win32", ct,
2621
%% "bin/lfe bin/lfec -o $REBAR_DEPS_DIR/ltest/test test/*_SUITE.lfe"}
2722
]}.
2823

2924
{profiles, [
25+
{test, [
26+
{pre_hooks, [
27+
{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", app_compile,
28+
"$REBAR_DEPS_DIR/lfe/bin/lfe $REBAR_DEPS_DIR/lfe/bin/lfec "
29+
"-o $REBAR_DEPS_DIR/ltest/ebin "
30+
"src/*.lfe"},
31+
{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", app_compile,
32+
"$REBAR_DEPS_DIR/lfe/bin/lfe $REBAR_DEPS_DIR/lfe/bin/lfec "
33+
"-o $REBAR_DEPS_DIR/ltest/ebin "
34+
"test/*.lfe"}
35+
]}
36+
]},
3037
{repl, [
3138
{pre_hooks, [
3239
{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", app_compile,

src/ltest-formatter.lfe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(defmodule ltest-formatter
22
(export all))
33

4-
(include-lib "ltest/include/ltest-records.lfe")
4+
(include-lib "include/ltest-records.lfe")
55

66
(defun test-suite-header ()
77
(io:format (get-suite-header)))

src/ltest-listener.lfe

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(behaviour eunit_listener)
33
(export all))
44

5-
(include-lib "ltest/include/ltest-records.lfe")
5+
(include-lib "include/ltest-records.lfe")
66

77
(defun start ()
88
(start '()))
@@ -11,7 +11,9 @@
1111
(eunit_listener:start (MODULE) options))
1212

1313
(defun init (options)
14-
(make-state test-type (proplists:get_value 'test-type options)))
14+
(make-state
15+
status (orddict:new)
16+
test-type (proplists:get_value 'test-type options)))
1517

1618
(defun handle_begin
1719
(('group (= `(,_ #(desc undefined) ,_ ,_) data) state)

src/ltest-util.lfe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(defmodule ltest-util
22
(export all))
33

4-
(include-lib "ltest/include/ltest-records.lfe")
4+
(include-lib "include/ltest-records.lfe")
55

66
(defun get-module (bin-data)
77
(beam->module (get-beam bin-data)))

src/ltest.lfe

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,32 @@
33

44
(include-lib "include/ltest-macros.lfe")
55

6-
(defun skip-test-patt () '".*_skip")
7-
(defun skip-test-group-patt () '"(.*)(_skip)")
8-
6+
(defun skip-test-patt () ".*_skip")
7+
(defun skip-test-group-patt () "(.*)(_skip)")
8+
9+
;; XXX this code actually assumes two possible layouts for different versions of
10+
;; rebar; those paths don't belong in a general purpose library, but rather
11+
;; in a rebar3 plugin.
12+
;;
13+
;; instead, there should be two path functions:
14+
;; - one that takes two arguments, a prefix and a regex, where the two are
15+
;; filename:joined and then pumped into filelib:wildcard, and
16+
;; - one that takes one argument, a regex, and then calls the two-arg
17+
;; function with a default (e.g., ".")
18+
;;
19+
;; come to think of it, though, that also feels like a bad approach. it
20+
;; should just recurse through a given directory, and look for beam files.
21+
;; in a rebar3 plugin, the appropriate path can be computed.
22+
;;
23+
;; so, some examination should be done of the latest rebar3 code, to see
24+
;; what public utility functions there are for locating beam files for a
25+
;; given app (or, in the case of releases, set of apps). That would mean
26+
;; we wouldn't need to do any wild-carding whatsoever ...
27+
;;
28+
;; see XXX comment on `get-possible-test-beams` for more thoughts ...
29+
;;
30+
;; related ticket: https://github.com/lfex/ltest/issues/61
31+
;;
932
(defun paths (path)
1033
(lists:append
1134
(list
@@ -15,6 +38,21 @@
1538
;; XXX this should be _build/<profile(s)>/lib/...
1639
(list path "_build/*/lib/*/ebin/*.beam"))))))
1740

41+
;; XXX do we need this? after examining the current rebar3 utils, we might not.
42+
;;
43+
;; this library baiscally uses behaviours as "marker interfaces" and that's
44+
;; why we're jumping through all these hoops. so we should ask some basic
45+
;; questions:
46+
;;
47+
;; - is there a better way to do this in Erlang/LFE? for example, eunit
48+
;; expects functions to have a particular suffix; we could do the same
49+
;; to distinguish unit, system, and integration tests
50+
;; - is there a more elegant way to check for a behaviour in a beam file?
51+
;; - does rebar3 offer some utility functions that do this better, that we
52+
;; can use?
53+
;;
54+
;; related ticket: https://github.com/lfex/ltest/issues/61
55+
;;
1856
(defun get-possible-test-beams (path)
1957
"Get the compiled .beam files, but without the .beam extension. The list of
2058
files generated by this function are meant to be consumed by (code:load_abs)."

0 commit comments

Comments
 (0)