Skip to content

Commit b2f2f25

Browse files
author
Brett Hazen
committed
Fix creation of test plans from GiddyUp
1 parent d893259 commit b2f2f25

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

src/giddyup.erl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ fetch_all_test_plans(Platform, Product, VersionNumber, DefaultVersion, Host) ->
266266
Id = kvc:path(id, Test),
267267
Module = binary_to_atom(kvc:path(name, Test), utf8),
268268
Plan0 = rt_test_plan:new([{id, Id}, {module, Module}, {project, Project}, {platform, Platform}, {version, VersionNumber}]),
269-
Plan1 = case kvc:path('tags.backend', Test) of
270-
[] -> Plan0;
271-
X -> rt_test_plan:set(backend, binary_to_atom(X, utf8), Plan0)
269+
{ok, Plan1} = case kvc:path('tags.backend', Test) of
270+
[] -> {ok, Plan0};
271+
Backend -> rt_test_plan:set(backend, binary_to_atom(Backend, utf8), Plan0)
272272
end,
273-
Plan2 = case kvc:path('tags.upgrade_version', Test) of
274-
[] -> Plan1;
273+
{ok, Plan2} = case kvc:path('tags.upgrade_version', Test) of
274+
[] -> {ok, Plan1};
275275
UpgradeVsn ->
276276
UpgradeVersion = case UpgradeVsn of
277277
<<"legacy">> -> rt_config:get_legacy_version();
@@ -285,6 +285,7 @@ fetch_all_test_plans(Platform, Product, VersionNumber, DefaultVersion, Host) ->
285285
%% [] -> Plan1;
286286
%% MultiConfig -> rt_test_plan:set(multi_config, binary_to_atom(MultiConfig, utf8), Plan2)
287287
%%end,
288+
lager:debug("Giddyup Module ~p using TestPlan ~p", [Module, Plan2]),
288289
Plan2
289290
end,
290291
[ TestProps(Test) || Test <- Tests].

src/rt_planner.erl

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,26 @@ init([]) ->
187187
%% If none are specified, run everything
188188
handle_call({load_from_giddyup, Backends, CommandLineTests}, _From, State) ->
189189
AllGiddyupTests = giddyup:get_test_plans(),
190-
FilteredNames = case CommandLineTests of
190+
{Included, Excluded} = case CommandLineTests of
191191
[] ->
192-
AllGiddyupTests;
192+
{AllGiddyupTests, []};
193193
_ ->
194-
[TestPlan || TestPlan <- AllGiddyupTests,
195-
CName <- CommandLineTests,
196-
rt_test_plan:get_module(TestPlan) =:= CName]
194+
Inc = [TestPlan || TestPlan <- AllGiddyupTests,
195+
CName <- CommandLineTests,
196+
rt_test_plan:get_module(TestPlan) =:= CName],
197+
{Inc, lists:filter(fun(Elem) -> not lists:member(Elem, Inc) end, AllGiddyupTests)}
197198
end,
198-
FilteredTests = case Backends of
199+
{Included1, Excluded1} = case Backends of
199200
undefined ->
200-
FilteredNames;
201+
{Included, Excluded};
201202
_ ->
202-
[TestPlan || TestPlan <- FilteredNames,
203-
lists:member(rt_test_plan:get(backend, TestPlan), Backends)]
203+
Inc1 = [TestPlan || TestPlan <- Included,
204+
lists:member(rt_test_plan:get(backend, TestPlan), Backends)],
205+
{Inc1, lists:filter(fun(Elem) -> not lists:member(Elem, Inc1) end, AllGiddyupTests)}
204206
end,
205-
State1 = lists:foldl(fun sort_and_queue/2, State, FilteredTests),
206-
{reply, ok, State1};
207+
State1 = lists:foldl(fun sort_and_queue/2, State, Included1),
208+
State2 = lists:foldl(fun exclude_test_plan/2, State1, Excluded1),
209+
{reply, ok, State2};
207210
%% Add a single test plan to the queue
208211
handle_call({add_test_plan, Module, Platform, Backends, _Version, _Properties}, _From, State) ->
209212
State1 = lists:foldl(fun(Backend, AccState) ->
@@ -330,3 +333,13 @@ is_runnable_test_plan(TestPlan) ->
330333
code:ensure_loaded(Mod),
331334
erlang:function_exported(Mod, Fun, 0) orelse
332335
erlang:function_exported(Mod, Fun, 1).
336+
337+
%%--------------------------------------------------------------------
338+
%% @private
339+
%% @doc
340+
%% Add a unused test to the list of non_runnable_test_plans
341+
%% @end
342+
%%--------------------------------------------------------------------
343+
exclude_test_plan(TestPlan, State) ->
344+
QNR = queue:in(TestPlan, State#state.non_runnable_test_plans),
345+
State#state{non_runnable_test_plans=QNR}.

src/rt_test_plan.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ set_fields(_, _, {error, _}=Error) ->
161161
validate_request(Field, TestPlan) ->
162162
validate_field(Field, validate_record(TestPlan)).
163163

164-
-spec validate_record(test_plan()) -> ok | {error, invalid_properties}.
164+
-spec validate_record(test_plan()) -> ok | {error, invalid_test_plan}.
165165
validate_record(Record) ->
166166
case is_valid_record(Record) of
167167
true ->
168168
ok;
169169
false ->
170-
{error, invalid_properties}
170+
{error, invalid_test_plan}
171171
end.
172172

173173
-spec validate_field(atom(), ok | {error, atom()}) -> ok | {error, invalid_field}.

0 commit comments

Comments
 (0)