Merge remote-tracking branch 'canonical/next'
[sinan.git] / test / sint_gh78.erl
blob14577a4dffb885d942abbdc7abcff30fd3025110
1 %%%-------------------------------------------------------------------
2 %%% @copyright (C) 2011, Erlware, LLC.
3 %%% @doc
4 %%% Test the ability to correctly correctly handle parse_transform
5 %%% dependencies
6 %%% @end
7 %%%-------------------------------------------------------------------
8 -module(sint_gh78).
10 -include_lib("eunit/include/eunit.hrl").
12 -export([given/3, 'when'/3, then/3]).
14 given([a,generated,project], _State, _) ->
15 sint_test_project_gen:a_generated_project();
16 given([that,project,an,includes,a,header,in,the,include,directory],
17 State={ProjectDir, _}, _) ->
18 io:format("~p~n", [ProjectDir]),
19 File = filename:join([ProjectDir, "include",
20 "test.hrl"]),
21 ok = file:write_file(File, header_contents()),
22 {ok, State};
23 given([that,project,contains,an,erl,file,that,includes,that,header],
24 State={ProjectDir, _}, _) ->
25 AFile = filename:join([ProjectDir, "src", "sint_gh78_includer.erl"]),
26 ok = file:write_file(AFile, dependent_contents()),
27 {ok, State}.
29 'when'([a,build,step,is,run,on,this,project],
30 {ProjectDir, ProjectName}, _) ->
31 Ret = sinan:run_sinan(["-s", ProjectDir, "build"]),
32 ?assertMatch({_, _}, Ret),
33 {_, TrueRet} = Ret,
34 {ok, {ProjectDir, ProjectName, TrueRet}}.
36 then([build,the,app,normally],
37 State = {_, _, BuildState}, _) ->
38 ?assertMatch([], sin_state:get_run_errors(BuildState)),
39 {ok, State}.
41 header_contents() ->
42 "-define(FOO, ok).
45 dependent_contents() ->
46 "-module(sint_gh78_includer).
47 -include(\"test.hrl\").
48 -export([new/2]).
49 new(_, _) -> ?FOO.