您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

527 行
21 KiB

10 年前
10 年前
10 年前
10 年前
10 年前
10 年前
  1. -module(rebar_compile_SUITE).
  2. -export([suite/0,
  3. init_per_suite/1,
  4. end_per_suite/1,
  5. init_per_testcase/2,
  6. end_per_testcase/2,
  7. all/0,
  8. build_basic_app/1,
  9. build_release_apps/1,
  10. build_checkout_apps/1,
  11. build_checkout_deps/1,
  12. build_all_srcdirs/1,
  13. recompile_when_hrl_changes/1,
  14. recompile_when_opts_change/1,
  15. dont_recompile_when_opts_dont_change/1,
  16. dont_recompile_yrl_or_xrl/1,
  17. deps_in_path/1,
  18. delete_beam_if_source_deleted/1,
  19. checkout_priority/1,
  20. compile_plugins/1,
  21. compile_global_plugins/1,
  22. highest_version_of_pkg_dep/1,
  23. parse_transform_test/1]).
  24. -include_lib("common_test/include/ct.hrl").
  25. -include_lib("eunit/include/eunit.hrl").
  26. -include_lib("kernel/include/file.hrl").
  27. suite() ->
  28. [].
  29. init_per_suite(Config) ->
  30. Config.
  31. end_per_suite(_Config) ->
  32. ok.
  33. init_per_testcase(_, Config) ->
  34. rebar_test_utils:init_rebar_state(Config).
  35. end_per_testcase(_, _Config) ->
  36. catch meck:unload().
  37. all() ->
  38. [build_basic_app, build_release_apps,
  39. build_checkout_apps, build_checkout_deps,
  40. build_all_srcdirs, recompile_when_hrl_changes,
  41. recompile_when_opts_change, dont_recompile_when_opts_dont_change,
  42. dont_recompile_yrl_or_xrl, delete_beam_if_source_deleted,
  43. deps_in_path, checkout_priority, compile_plugins, compile_global_plugins,
  44. highest_version_of_pkg_dep, parse_transform_test].
  45. build_basic_app(Config) ->
  46. AppDir = ?config(apps, Config),
  47. Name = rebar_test_utils:create_random_name("app1_"),
  48. Vsn = rebar_test_utils:create_random_vsn(),
  49. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  50. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}).
  51. build_release_apps(Config) ->
  52. AppDir = ?config(apps, Config),
  53. Name1 = rebar_test_utils:create_random_name("relapp1_"),
  54. Vsn1 = rebar_test_utils:create_random_vsn(),
  55. rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1, [kernel, stdlib]),
  56. Name2 = rebar_test_utils:create_random_name("relapp2_"),
  57. Vsn2 = rebar_test_utils:create_random_vsn(),
  58. rebar_test_utils:create_app(filename:join([AppDir,Name2]), Name2, Vsn2, [kernel, stdlib]),
  59. rebar_test_utils:run_and_check(
  60. Config, [], ["compile"],
  61. {ok, [{app, Name1}, {app, Name2}]}
  62. ).
  63. build_checkout_apps(Config) ->
  64. AppDir = ?config(apps, Config),
  65. CheckoutsDir = ?config(checkouts, Config),
  66. Name1 = rebar_test_utils:create_random_name("checkapp1_"),
  67. Vsn1 = rebar_test_utils:create_random_vsn(),
  68. rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1, [kernel, stdlib]),
  69. Name2 = rebar_test_utils:create_random_name("checkapp2_"),
  70. Vsn2 = rebar_test_utils:create_random_vsn(),
  71. rebar_test_utils:create_app(filename:join([CheckoutsDir,Name2]), Name2, Vsn2, [kernel, stdlib]),
  72. rebar_test_utils:run_and_check(
  73. Config, [], ["compile"],
  74. {ok, [{app, Name1}, {checkout, Name2}]}
  75. ).
  76. build_checkout_deps(Config) ->
  77. AppDir = ?config(apps, Config),
  78. CheckoutsDir = ?config(checkouts, Config),
  79. DepsDir = filename:join([AppDir, "_build", "default", "lib"]),
  80. Name1 = rebar_test_utils:create_random_name("checkapp1_"),
  81. Vsn1 = rebar_test_utils:create_random_vsn(),
  82. rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1, [kernel, stdlib]),
  83. Name2 = rebar_test_utils:create_random_name("checkapp2_"),
  84. Vsn2 = rebar_test_utils:create_random_vsn(),
  85. rebar_test_utils:create_app(filename:join([CheckoutsDir,Name2]), Name2, Vsn2, [kernel, stdlib]),
  86. rebar_test_utils:create_app(filename:join([DepsDir,Name2]), Name2, Vsn1, [kernel, stdlib]),
  87. Deps = [{list_to_atom(Name2), Vsn2, {git, "", ""}}],
  88. {ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, Deps}])),
  89. {ok, State} = rebar_test_utils:run_and_check(
  90. Config, RebarConfig, ["compile"],
  91. {ok, [{app, Name1}, {checkout, Name2}]}
  92. ),
  93. code:add_paths(rebar_state:code_paths(State, all_deps)),
  94. ok = application:load(list_to_atom(Name2)),
  95. Loaded = application:loaded_applications(),
  96. {_, _, Vsn2} = lists:keyfind(list_to_atom(Name2), 1, Loaded).
  97. build_all_srcdirs(Config) ->
  98. AppDir = ?config(apps, Config),
  99. RebarConfig = [{erl_opts, [{src_dirs, ["src", "extra"]}]}],
  100. Name = rebar_test_utils:create_random_name("app1_"),
  101. Vsn = rebar_test_utils:create_random_vsn(),
  102. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  103. ExtraSrc = <<"-module(extra_src).\n"
  104. "-export([ok/0]).\n"
  105. "ok() -> ok.\n">>,
  106. ok = filelib:ensure_dir(filename:join([AppDir, "extra", "dummy"])),
  107. ok = file:write_file(filename:join([AppDir, "extra", "extra_src.erl"]), ExtraSrc),
  108. rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
  109. %% check a beam corresponding to the src in the extra src_dir exists in ebin
  110. EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
  111. true = filelib:is_file(filename:join([EbinDir, "extra_src.beam"])),
  112. %% check the extra src_dir was linked into the _build dir
  113. true = filelib:is_dir(filename:join([AppDir, "_build", "default", "lib", Name, "extra"])).
  114. recompile_when_hrl_changes(Config) ->
  115. AppDir = ?config(apps, Config),
  116. Name = rebar_test_utils:create_random_name("app1_"),
  117. Vsn = rebar_test_utils:create_random_vsn(),
  118. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  119. ExtraSrc = <<"-module(test_header_include).\n"
  120. "-export([main/0]).\n"
  121. "-include(\"test_header_include.hrl\").\n"
  122. "main() -> ?SOME_DEFINE.\n">>,
  123. ExtraHeader = <<"-define(SOME_DEFINE, true).\n">>,
  124. HeaderFile = filename:join([AppDir, "src", "test_header_include.hrl"]),
  125. ok = file:write_file(filename:join([AppDir, "src", "test_header_include.erl"]), ExtraSrc),
  126. ok = file:write_file(HeaderFile, ExtraHeader),
  127. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  128. EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
  129. {ok, Files} = file:list_dir(EbinDir),
  130. ModTime = [filelib:last_modified(filename:join([EbinDir, F]))
  131. || F <- Files, filename:extension(F) == ".beam"],
  132. timer:sleep(1000),
  133. os:cmd("touch " ++ HeaderFile),
  134. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  135. {ok, NewFiles} = file:list_dir(EbinDir),
  136. NewModTime = [filelib:last_modified(filename:join([EbinDir, F]))
  137. || F <- NewFiles, filename:extension(F) == ".beam"],
  138. ?assert(ModTime =/= NewModTime).
  139. recompile_when_opts_change(Config) ->
  140. AppDir = ?config(apps, Config),
  141. Name = rebar_test_utils:create_random_name("app1_"),
  142. Vsn = rebar_test_utils:create_random_vsn(),
  143. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  144. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  145. EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
  146. {ok, Files} = file:list_dir(EbinDir),
  147. ModTime = [filelib:last_modified(filename:join([EbinDir, F]))
  148. || F <- Files, filename:extension(F) == ".beam"],
  149. timer:sleep(1000),
  150. rebar_test_utils:create_config(AppDir, [{erl_opts, [{d, some_define}]}]),
  151. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  152. {ok, NewFiles} = file:list_dir(EbinDir),
  153. NewModTime = [filelib:last_modified(filename:join([EbinDir, F]))
  154. || F <- NewFiles, filename:extension(F) == ".beam"],
  155. ?assert(ModTime =/= NewModTime).
  156. dont_recompile_when_opts_dont_change(Config) ->
  157. AppDir = ?config(apps, Config),
  158. Name = rebar_test_utils:create_random_name("app1_"),
  159. Vsn = rebar_test_utils:create_random_vsn(),
  160. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  161. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  162. EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
  163. {ok, Files} = file:list_dir(EbinDir),
  164. ModTime = [filelib:last_modified(filename:join([EbinDir, F]))
  165. || F <- Files, filename:extension(F) == ".beam"],
  166. timer:sleep(1000),
  167. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  168. {ok, NewFiles} = file:list_dir(EbinDir),
  169. NewModTime = [filelib:last_modified(filename:join([EbinDir, F]))
  170. || F <- NewFiles, filename:extension(F) == ".beam"],
  171. ?assert(ModTime == NewModTime).
  172. dont_recompile_yrl_or_xrl(Config) ->
  173. AppDir = ?config(apps, Config),
  174. Name = rebar_test_utils:create_random_name("app1_"),
  175. Vsn = rebar_test_utils:create_random_vsn(),
  176. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  177. Xrl = filename:join([AppDir, "src", "not_a_real_xrl_" ++ Name ++ ".xrl"]),
  178. ok = filelib:ensure_dir(Xrl),
  179. XrlBody =
  180. "Definitions."
  181. "\n\n"
  182. "D = [0-9]"
  183. "\n\n"
  184. "Rules."
  185. "\n\n"
  186. "{D}+ :"
  187. " {token,{integer,TokenLine,list_to_integer(TokenChars)}}."
  188. "\n\n"
  189. "{D}+\\.{D}+((E|e)(\\+|\\-)?{D}+)? :"
  190. " {token,{float,TokenLine,list_to_float(TokenChars)}}."
  191. "\n\n"
  192. "Erlang code.",
  193. ok = ec_file:write(Xrl, XrlBody),
  194. XrlBeam = filename:join([AppDir, "ebin", filename:basename(Xrl, ".xrl") ++ ".beam"]),
  195. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  196. ModTime = filelib:last_modified(XrlBeam),
  197. timer:sleep(1000),
  198. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  199. NewModTime = filelib:last_modified(XrlBeam),
  200. ?assert(ModTime == NewModTime).
  201. delete_beam_if_source_deleted(Config) ->
  202. AppDir = ?config(apps, Config),
  203. Name = rebar_test_utils:create_random_name("app1_"),
  204. Vsn = rebar_test_utils:create_random_vsn(),
  205. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  206. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  207. EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
  208. SrcDir = filename:join([AppDir, "_build", "default", "lib", Name, "src"]),
  209. ?assert(filelib:is_regular(filename:join(EbinDir, "not_a_real_src_" ++ Name ++ ".beam"))),
  210. file:delete(filename:join(SrcDir, "not_a_real_src_" ++ Name ++ ".erl")),
  211. rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}),
  212. ?assertNot(filelib:is_regular(filename:join(EbinDir, "not_a_real_src_" ++ Name ++ ".beam"))).
  213. deps_in_path(Config) ->
  214. AppDir = ?config(apps, Config),
  215. StartPaths = code:get_path(),
  216. Name = rebar_test_utils:create_random_name("app1_"),
  217. Vsn = rebar_test_utils:create_random_vsn(),
  218. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  219. DepName = rebar_test_utils:create_random_name("dep1_"),
  220. PkgName = rebar_test_utils:create_random_name("pkg1_"),
  221. mock_git_resource:mock([]),
  222. mock_pkg_resource:mock([
  223. {pkgdeps, [{{iolist_to_binary(PkgName), iolist_to_binary(Vsn)}, []}]}
  224. ]),
  225. RConfFile = rebar_test_utils:create_config(AppDir, [{deps, [
  226. {list_to_atom(DepName), {git, "http://site.com/user/"++DepName++".git", {tag, Vsn}}},
  227. {list_to_atom(PkgName), Vsn}
  228. ]}]),
  229. {ok, RConf} = file:consult(RConfFile),
  230. %% Make sure apps we look for are not visible
  231. %% Hope not to find src name
  232. ?assertEqual([], [Path || Path <- code:get_path(),
  233. {match, _} <- [re:run(Path, DepName)]]),
  234. %% Hope not to find pkg name in there
  235. ?assertEqual([], [Path || Path <- code:get_path(),
  236. {match, _} <- [re:run(Path, PkgName)]]),
  237. %% Build things
  238. {ok, State} = rebar_test_utils:run_and_check(
  239. Config, RConf, ["compile"],
  240. {ok, [{app, Name}, {dep, DepName}, {dep, PkgName}]}
  241. ),
  242. code:add_paths(rebar_state:code_paths(State, all_deps)),
  243. %% Find src name in there
  244. ?assertNotEqual([], [Path || Path <- code:get_path(),
  245. {match, _} <- [re:run(Path, DepName)]]),
  246. %% find pkg name in there
  247. ?assertNotEqual([], [Path || Path <- code:get_path(),
  248. {match, _} <- [re:run(Path, PkgName)]]),
  249. code:set_path(StartPaths),
  250. %% Make sure apps we look for are not visible again
  251. %% Hope not to find src name
  252. ?assertEqual([], [Path || Path <- code:get_path(),
  253. {match, _} <- [re:run(Path, DepName)]]),
  254. %% Hope not to find pkg name in there
  255. ?assertEqual([], [Path || Path <- code:get_path(),
  256. {match, _} <- [re:run(Path, PkgName)]]),
  257. %% Rebuild
  258. {ok, State1} = rebar_test_utils:run_and_check(
  259. Config, RConf, ["compile"],
  260. {ok, [{app, Name}, {dep, DepName}, {dep, PkgName}]}
  261. ),
  262. %% Find src name in there
  263. code:add_paths(rebar_state:code_paths(State1, all_deps)),
  264. ?assertNotEqual([], [Path || Path <- code:get_path(),
  265. {match, _} <- [re:run(Path, DepName)]]),
  266. %% find pkg name in there
  267. ?assertNotEqual([], [Path || Path <- code:get_path(),
  268. {match, _} <- [re:run(Path, PkgName)]]).
  269. checkout_priority(Config) ->
  270. AppDir = ?config(apps, Config),
  271. CheckoutsDir = ?config(checkouts, Config),
  272. StartPaths = code:get_path(),
  273. Name = rebar_test_utils:create_random_name("app1_"),
  274. Vsn = rebar_test_utils:create_random_vsn(),
  275. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  276. DepName = rebar_test_utils:create_random_name("dep1_"),
  277. PkgName = rebar_test_utils:create_random_name("pkg1_"),
  278. mock_git_resource:mock([]),
  279. mock_pkg_resource:mock([
  280. {pkgdeps, [{{iolist_to_binary(PkgName), iolist_to_binary(Vsn)}, []}]}
  281. ]),
  282. RConfFile = rebar_test_utils:create_config(AppDir, [{deps, [
  283. {list_to_atom(DepName), {git, "http://site.com/user/"++DepName++".git", {tag, Vsn}}},
  284. {list_to_atom(PkgName), Vsn}
  285. ]}]),
  286. {ok, RConf} = file:consult(RConfFile),
  287. %% Build with deps.
  288. rebar_test_utils:run_and_check(
  289. Config, RConf, ["compile"],
  290. {ok, [{app, Name}, {dep, DepName}, {dep, PkgName}]}
  291. ),
  292. %% Build two checkout apps similar to dependencies to be fetched,
  293. %% but on a different version
  294. Vsn2 = rebar_test_utils:create_random_vsn(),
  295. rebar_test_utils:create_app(filename:join([CheckoutsDir,DepName]), DepName, Vsn2, [kernel, stdlib]),
  296. rebar_test_utils:create_app(filename:join([CheckoutsDir,PkgName]), PkgName, Vsn2, [kernel, stdlib]),
  297. %% Rebuild and make sure the checkout apps are in path
  298. code:set_path(StartPaths),
  299. {ok, State} = rebar_test_utils:run_and_check(
  300. Config, RConf, ["compile"],
  301. {ok, [{app, Name}, {checkout, DepName}, {checkout, PkgName}]}
  302. ),
  303. code:add_paths(rebar_state:code_paths(State, all_deps)),
  304. [DepPath] = [Path || Path <- code:get_path(),
  305. {match, _} <- [re:run(Path, DepName)]],
  306. [PkgPath] = [Path || Path <- code:get_path(),
  307. {match, _} <- [re:run(Path, PkgName)]],
  308. {ok, [DepApp]} = file:consult(filename:join([DepPath, DepName ++ ".app"])),
  309. {ok, [PkgApp]} = file:consult(filename:join([PkgPath, PkgName ++ ".app"])),
  310. {application, _, DepProps} = DepApp,
  311. {application, _, PkgProps} = PkgApp,
  312. ?assertEqual(Vsn2, proplists:get_value(vsn, DepProps)),
  313. ?assertEqual(Vsn2, proplists:get_value(vsn, PkgProps)).
  314. %% Tests that compiling a project installs and compiles the plugins of deps
  315. compile_plugins(Config) ->
  316. AppDir = ?config(apps, Config),
  317. Name = rebar_test_utils:create_random_name("app1_"),
  318. Vsn = rebar_test_utils:create_random_vsn(),
  319. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  320. DepName = rebar_test_utils:create_random_name("dep1_"),
  321. PluginName = rebar_test_utils:create_random_name("plugin1_"),
  322. mock_git_resource:mock([{config, [{plugins, [
  323. {list_to_atom(PluginName), Vsn}
  324. ]}]}]),
  325. mock_pkg_resource:mock([
  326. {pkgdeps, [{{iolist_to_binary(PluginName), iolist_to_binary(Vsn)}, []}]}
  327. ]),
  328. RConfFile =
  329. rebar_test_utils:create_config(AppDir,
  330. [{deps, [
  331. {list_to_atom(DepName), {git, "http://site.com/user/"++DepName++".git", {tag, Vsn}}}
  332. ]}]),
  333. {ok, RConf} = file:consult(RConfFile),
  334. %% Build with deps.
  335. rebar_test_utils:run_and_check(
  336. Config, RConf, ["compile"],
  337. {ok, [{app, Name}, {plugin, PluginName}, {dep, DepName}]}
  338. ).
  339. %% Tests that compiling a project installs and compiles the global plugins
  340. compile_global_plugins(Config) ->
  341. AppDir = ?config(apps, Config),
  342. GlobalDir = filename:join(AppDir, "global"),
  343. GlobalConfigDir = filename:join([GlobalDir, ".config", "rebar3"]),
  344. GlobalConfig = filename:join([GlobalDir, ".config", "rebar3", "rebar.config"]),
  345. meck:new(rebar_dir, [passthrough]),
  346. meck:expect(rebar_dir, global_config, fun() -> GlobalConfig end),
  347. meck:expect(rebar_dir, global_cache_dir, fun(_) -> GlobalDir end),
  348. Name = rebar_test_utils:create_random_name("app1_"),
  349. Vsn = rebar_test_utils:create_random_vsn(),
  350. Vsn2 = rebar_test_utils:create_random_vsn(),
  351. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  352. DepName = rebar_test_utils:create_random_name("dep1_"),
  353. PluginName = rebar_test_utils:create_random_name("plugin1_"),
  354. mock_git_resource:mock([{deps, [{list_to_atom(PluginName), Vsn},
  355. {list_to_atom(PluginName), Vsn2},
  356. {{iolist_to_binary(DepName), iolist_to_binary(Vsn)}, []}]}]),
  357. rebar_test_utils:create_config(GlobalConfigDir,
  358. [{plugins, [
  359. {list_to_atom(PluginName), {git, "http://site.com/user/"++PluginName++".git", {tag, Vsn}}}
  360. ]}]),
  361. RConfFile =
  362. rebar_test_utils:create_config(AppDir,
  363. [{deps, [
  364. {list_to_atom(DepName), {git, "http://site.com/user/"++DepName++".git", {tag, Vsn}}}
  365. ]},
  366. {plugins, [
  367. {list_to_atom(PluginName), {git, "http://site.com/user/"++PluginName++".git", {tag, Vsn2}}}
  368. ]}]),
  369. {ok, RConf} = file:consult(RConfFile),
  370. %% Runs global plugin install
  371. rebar3:init_config(),
  372. %% Build with deps.
  373. rebar_test_utils:run_and_check(
  374. Config, RConf, ["compile"],
  375. {ok, [{app, Name},
  376. {global_plugin, PluginName, Vsn},
  377. {plugin, PluginName, Vsn2},
  378. {dep, DepName}]}
  379. ),
  380. meck:unload(rebar_dir).
  381. highest_version_of_pkg_dep(Config) ->
  382. AppDir = ?config(apps, Config),
  383. Name = rebar_test_utils:create_random_name("app1_"),
  384. Vsn = rebar_test_utils:create_random_vsn(),
  385. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  386. PkgName = rebar_test_utils:create_random_name("pkg1_"),
  387. mock_git_resource:mock([]),
  388. mock_pkg_resource:mock([
  389. {pkgdeps, [{{iolist_to_binary(PkgName), <<"0.1.0">>}, []},
  390. {{iolist_to_binary(PkgName), <<"0.0.1">>}, []},
  391. {{iolist_to_binary(PkgName), <<"0.1.3">>}, []},
  392. {{iolist_to_binary(PkgName), <<"0.1.1">>}, []}]}
  393. ]),
  394. RConfFile = rebar_test_utils:create_config(AppDir, [{deps, [list_to_atom(PkgName)]}]),
  395. {ok, RConf} = file:consult(RConfFile),
  396. %% Build with deps.
  397. rebar_test_utils:run_and_check(
  398. Config, RConf, ["compile"],
  399. {ok, [{app, Name}, {dep, PkgName, <<"0.1.3">>}]}
  400. ).
  401. parse_transform_test(Config) ->
  402. AppDir = ?config(apps, Config),
  403. RebarConfig = [{erl_opts, [{parse_transform, pascal}]}],
  404. Name = rebar_test_utils:create_random_name("app1_"),
  405. Vsn = rebar_test_utils:create_random_vsn(),
  406. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  407. ExtraSrc = <<"-module(pascal). "
  408. "-export([parse_transform/2]). "
  409. "parse_transform(Forms, _Options) -> "
  410. "Forms.">>,
  411. ok = file:write_file(filename:join([AppDir, "src", "pascal.erl"]), ExtraSrc),
  412. rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
  413. EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
  414. true = filelib:is_file(filename:join([EbinDir, "pascal.beam"])).