summaryrefslogtreecommitdiff
path: root/src/rebar_eunit.erl
diff options
context:
space:
mode:
authorRoberto Ostinelli <roberto@ostinelli.net>2012-08-19 14:23:06 -0700
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-08-20 12:58:31 +0200
commitfa6618f2b410c2b71877c1878dff3a0c8503000c (patch)
treece7102414e0a90be3ea9ddb5e52f84bde9be7649 /src/rebar_eunit.erl
parent9dd8e7f2ee581842d0376fef4292613b4e8275be (diff)
downloadrebar-fa6618f2b410c2b71877c1878dff3a0c8503000c.tar.gz
Add experimental tests= filter without eunit suites
Diffstat (limited to 'src/rebar_eunit.erl')
-rw-r--r--src/rebar_eunit.erl24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index be9417e..765f59f 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -51,6 +51,12 @@
%% suites="foo,bar" tests="baz"- runs first test with name starting
%% with 'baz' in foo.erl, test/foo_tests.erl and tests in bar.erl,
%% test/bar_tests.erl
+%% </li>
+%% <li>
+%% tests="baz"- For every existing suite, run the first test whose
+%% name starts with bar and, if no such test exists, run the test
+%% whose name starts with bar in the suite's _tests module
+%% </li>
%% </ul>
%% Additionally, for projects that have separate folders for the core
%% implementation, and for the unit tests, then the following
@@ -112,7 +118,8 @@ run_eunit(Config, CodePath, SrcErls) ->
%% Get modules to be run in eunit
AllModules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- AllBeamFiles],
{SuitesProvided, FilteredModules} = filter_suites(Config, AllModules),
- %% TODO: make tests= work with no suites= provided
+
+ %% build the tests
Tests = get_tests(Config, SuitesProvided, ModuleBeamFiles, FilteredModules),
SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
@@ -174,7 +181,7 @@ filter_suites1(Modules, Suites) ->
[M || M <- Modules, lists:member(M, Suites)].
get_tests(Config, SuitesProvided, ModuleBeamFiles, FilteredModules) ->
- case SuitesProvided of
+ Modules = case SuitesProvided of
false ->
%% No specific suites have been provided, use ModuleBeamFiles
%% which filters out "*_tests" modules so eunit won't doubly run
@@ -194,18 +201,19 @@ get_tests(Config, SuitesProvided, ModuleBeamFiles, FilteredModules) ->
%% public interface of the main module (and no other code)."
[rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- ModuleBeamFiles];
true ->
- %% Specific suites have been provided, return the existing modules
- build_tests(Config, FilteredModules)
- end.
+ %% Specific suites have been provided, return the filtered modules
+ FilteredModules
+ end,
+ build_tests(Config, Modules).
-build_tests(Config, SuitesModules) ->
+build_tests(Config, Modules) ->
RawFunctions = rebar_utils:get_experimental_global(Config, tests, ""),
Tests = [list_to_atom(F1) || F1 <- string:tokens(RawFunctions, ",")],
case Tests of
[] ->
- SuitesModules;
+ Modules;
Functions ->
- case build_tests1(SuitesModules, Functions, []) of
+ case build_tests1(Modules, Functions, []) of
[] ->
[];
RawTests ->