Merge remote-tracking branch 'canonical/next'
[sinan.git] / test / sint_multirun_support.erl
blob79f6dff96e85c5154fdcb476a5d98c3231f5ca45
1 %%%-------------------------------------------------------------------
2 %%% @copyright (C) 2011, Erlware, LLC.
3 %%% @doc
4 %%% Add the ability to run sinan multiple times concurrently
5 %%% @end
6 %%% Created : 5 Sep 2011 by Eric Merritt <ericbmerritt@gmail.com>
7 %%%-------------------------------------------------------------------
8 -module(sint_multirun_support).
10 -export([given/3, 'when'/3, then/3]).
12 -include_lib("eunit/include/eunit.hrl").
14 %% Step definitions for the sample calculator Addition feature.
16 given([two, generated, projects], _, _) ->
17 BaseDir = ec_file:mkdtemp(),
18 ProjectDescs =
19 lists:map(fun(Number) ->
20 ProjectName = "foobachoo" ++
21 erlang:integer_to_list(Number),
22 {ProjectDir, _} =
23 sint_test_project_gen:single_app_project(BaseDir,
24 ProjectName),
25 {ProjectName, ProjectDir}
26 end,
27 lists:seq(0, 2)),
29 {ok, ProjectDescs}.
31 'when'([a, build, step, is, run, on, each, project, concurrently],
32 ProjectDescs, _) ->
33 Results = ec_plists:map(fun({_, ProjectDir}) ->
34 sinan:run_sinan(["-s", ProjectDir,
35 "build"])
36 end, ProjectDescs),
37 {ok, lists:zip(ProjectDescs, Results)}.
39 then([sinan, should, build, both, projects, without, a, problem],
40 ProjectDescs, _) ->
41 ?assertMatch(true,
42 lists:all(fun({{ProjectName, ProjectDir}, {ok, _}}) ->
43 ok == sint_test_project_gen:validate_single_app_project(ProjectDir, ProjectName);
44 ({_, {error, _}}) ->
45 false
46 end, ProjectDescs)),
47 {ok, ProjectDescs}.