選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

548 行
23 KiB

  1. -module(rebar_eunit_SUITE).
  2. -export([all/0, groups/0]).
  3. -export([init_per_suite/1, init_per_group/2, end_per_group/2]).
  4. -export([basic_app_compiles/1, basic_app_files/1, basic_app_exports/1, basic_app_testset/1]).
  5. -export([multi_app_compiles/1, multi_app_files/1, multi_app_exports/1, multi_app_testset/1]).
  6. -export([eunit_tests/1, eunit_opts/1, eunit_first_files/1]).
  7. -export([single_application_arg/1, multi_application_arg/1, missing_application_arg/1]).
  8. -export([single_module_arg/1, multi_module_arg/1, missing_module_arg/1]).
  9. -export([single_suite_arg/1, multi_suite_arg/1, missing_suite_arg/1]).
  10. -export([single_file_arg/1, multi_file_arg/1, missing_file_arg/1]).
  11. -export([single_dir_arg/1, multi_dir_arg/1, missing_dir_arg/1]).
  12. -export([multiple_arg_composition/1, multiple_arg_errors/1]).
  13. -export([misspecified_eunit_tests/1]).
  14. -export([misspecified_eunit_compile_opts/1]).
  15. -export([misspecified_eunit_first_files/1]).
  16. -include_lib("common_test/include/ct.hrl").
  17. -include_lib("eunit/include/eunit.hrl").
  18. -include_lib("kernel/include/file.hrl").
  19. all() ->
  20. [{group, basic_app}, {group, multi_app}, {group, cmd_line_args},
  21. misspecified_eunit_tests,
  22. misspecified_eunit_compile_opts,
  23. misspecified_eunit_first_files].
  24. groups() ->
  25. [{basic_app, [sequence], [basic_app_compiles, {group, basic_app_results}]},
  26. {basic_app_results, [], [basic_app_files, basic_app_exports, basic_app_testset]},
  27. {multi_app, [sequence], [multi_app_compiles, {group, multi_app_results}]},
  28. {multi_app_results, [], [multi_app_files, multi_app_exports, multi_app_testset]},
  29. {cmd_line_args, [], [eunit_tests, eunit_opts, eunit_first_files,
  30. single_application_arg, multi_application_arg, missing_application_arg,
  31. single_module_arg, multi_module_arg, missing_module_arg,
  32. single_suite_arg, multi_suite_arg, missing_suite_arg,
  33. single_file_arg, multi_file_arg, missing_file_arg,
  34. single_dir_arg, multi_dir_arg, missing_dir_arg,
  35. multiple_arg_composition, multiple_arg_errors]}].
  36. %% this just unzips the example apps used by tests to the priv dir for later use
  37. init_per_suite(Config) ->
  38. PrivDir = ?config(priv_dir, Config),
  39. DataDir = ?config(data_dir, Config),
  40. {ok, Cwd} = file:get_cwd(),
  41. file:set_cwd(PrivDir),
  42. ok = ec_file:copy(filename:join([DataDir, "basic_app.zip"]), filename:join([PrivDir, "basic_app.zip"])),
  43. {ok, _} = zip:extract(filename:join([PrivDir, "basic_app.zip"])),
  44. ok = ec_file:copy(filename:join([DataDir, "multi_app.zip"]), filename:join([PrivDir, "multi_app.zip"])),
  45. {ok, _} = zip:extract(filename:join([PrivDir, "multi_app.zip"])),
  46. file:set_cwd(Cwd),
  47. Config.
  48. init_per_group(basic_app, Config) ->
  49. GroupState = rebar_test_utils:init_rebar_state(Config, "basic_app_"),
  50. AppDir = ?config(apps, GroupState),
  51. PrivDir = ?config(priv_dir, GroupState),
  52. AppDirs = ["src", "include", "test"],
  53. lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "basic_app", F]),
  54. filename:join([AppDir, F]),
  55. [recursive]) end, AppDirs),
  56. RebarConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, [{d, eunit_compile_define}]}],
  57. {ok, State} = rebar_test_utils:run_and_check(GroupState, RebarConfig, ["as", "test", "lock"], return),
  58. [{result, State}|GroupState];
  59. init_per_group(multi_app, Config) ->
  60. GroupState = rebar_test_utils:init_rebar_state(Config, "multi_app_"),
  61. AppDir = ?config(apps, GroupState),
  62. PrivDir = ?config(priv_dir, GroupState),
  63. AppDirs = ["apps", "test"],
  64. lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "multi_app", F]),
  65. filename:join([AppDir, F]),
  66. [recursive]) end, AppDirs),
  67. RebarConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, [{d, eunit_compile_define}]}],
  68. {ok, State} = rebar_test_utils:run_and_check(GroupState, RebarConfig, ["as", "test", "lock"], return),
  69. [{result, State}|GroupState];
  70. init_per_group(cmd_line_args, Config) ->
  71. GroupState = rebar_test_utils:init_rebar_state(Config, "cmd_line_args_"),
  72. AppDir = ?config(apps, GroupState),
  73. PrivDir = ?config(priv_dir, GroupState),
  74. AppDirs = ["apps", "test"],
  75. lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "multi_app", F]),
  76. filename:join([AppDir, F]),
  77. [recursive]) end, AppDirs),
  78. RebarConfig = [{erl_opts, [{d, config_define}]},
  79. {eunit_compile_opts, [{d, eunit_compile_define}]},
  80. %% test set not supported by cmd line args
  81. {eunit_tests, [{test, multi_app_bar, sanity_test},
  82. {test, multi_app_baz, sanity_test}]},
  83. {eunit_opts, [verbose]},
  84. {eunit_first_files, [filename:join(["apps", "multi_app_bar", "test", "multi_app_bar_tests_helper.erl"]),
  85. filename:join(["apps", "multi_app_baz", "test", "multi_app_baz_tests_helper.erl"])]}],
  86. {ok, State} = rebar_test_utils:run_and_check(GroupState, RebarConfig, ["eunit"], return),
  87. [{result, State}|GroupState];
  88. init_per_group(_, Config) -> Config.
  89. end_per_group(_, Config) -> Config.
  90. %% === tests for a single application at the root of a project ===
  91. %% check that project compiles properly
  92. basic_app_compiles(Config) ->
  93. AppDir = ?config(apps, Config),
  94. State = ?config(result, Config),
  95. {ok, _} = rebar_prv_eunit:do(State),
  96. rebar_test_utils:check_results(AppDir, [{app, "basic_app"}], "*").
  97. %% check that all files expected to be present are present
  98. basic_app_files(Config) ->
  99. AppDir = ?config(apps, Config),
  100. lists:foreach(fun(F) -> true = ec_file:exists(filename:join([AppDir, "_build", "test", "lib", "basic_app", "ebin", F])) end,
  101. ["basic_app.app", "basic_app.beam"]),
  102. lists:foreach(fun(F) -> true = ec_file:exists(filename:join([AppDir, "_build", "test", "lib", "basic_app", "test", F])) end,
  103. ["basic_app_tests.beam", "basic_app_tests_helper.beam"]).
  104. %% check that the correct tests are exported from modules for project
  105. %% note that this implies `TEST` is set correctly
  106. basic_app_exports(_Config) ->
  107. Tests = fun(Mod) ->
  108. begin
  109. Path = code:which(Mod),
  110. {ok, {Mod, [{exports, Ex}]}} = beam_lib:chunks(Path, [exports]),
  111. true = lists:member({sanity_test, 0}, Ex)
  112. end
  113. end,
  114. Helpers = fun(Mod) ->
  115. begin
  116. Path = code:which(Mod),
  117. {ok, {Mod, [{exports, Ex}]}} = beam_lib:chunks(Path, [exports]),
  118. true = lists:member({help, 0}, Ex)
  119. end
  120. end,
  121. lists:foreach(Tests, [basic_app, basic_app_tests]),
  122. lists:foreach(Helpers, [basic_app_tests_helper]).
  123. %% check that the correct tests are schedule to run for project
  124. basic_app_testset(Config) ->
  125. Result = ?config(result, Config),
  126. {ok, [{application, basic_app}]} = rebar_prv_eunit:prepare_tests(Result).
  127. %% === tests for multiple applications in the `apps' directory of a project ===
  128. %% check that project compiles properly
  129. multi_app_compiles(Config) ->
  130. AppDir = ?config(apps, Config),
  131. State = ?config(result, Config),
  132. {ok, _} = rebar_prv_eunit:do(State),
  133. rebar_test_utils:check_results(AppDir, [{app, "multi_app_bar"}, {app, "multi_app_baz"}], "*").
  134. %% check that all files expected to be present are present
  135. multi_app_files(Config) ->
  136. AppDir = ?config(apps, Config),
  137. lists:foreach(fun(F) -> true = ec_file:exists(filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin", F])) end,
  138. ["multi_app_bar.app", "multi_app_bar.beam"]),
  139. lists:foreach(fun(F) -> true = ec_file:exists(filename:join([AppDir, "_build", "test", "lib", "multi_app_baz", "ebin", F])) end,
  140. ["multi_app_baz.app", "multi_app_baz.beam"]),
  141. lists:foreach(fun(F) -> true = ec_file:exists(filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "test", F])) end,
  142. ["multi_app_bar_tests.beam", "multi_app_bar_tests_helper.beam"]),
  143. lists:foreach(fun(F) -> true = ec_file:exists(filename:join([AppDir, "_build", "test", "lib", "multi_app_baz", "test", F])) end,
  144. ["multi_app_baz_tests.beam", "multi_app_baz_tests_helper.beam"]),
  145. lists:foreach(fun(F) -> true = ec_file:exists(filename:join([AppDir, "_build", "test", "extras", "test", F])) end,
  146. ["multi_app_tests.beam", "multi_app_tests_helper.beam"]).
  147. %% check that the correct tests are exported from modules for project
  148. %% note that this implies `TEST` is set correctly
  149. multi_app_exports(_Config) ->
  150. Tests = fun(Mod) ->
  151. begin
  152. Ex = Mod:module_info(exports),
  153. true = lists:member({sanity_test, 0}, Ex)
  154. end
  155. end,
  156. Helpers = fun(Mod) ->
  157. begin
  158. Ex = Mod:module_info(exports),
  159. true = lists:member({help, 0}, Ex)
  160. end
  161. end,
  162. lists:foreach(Tests, [multi_app_bar, multi_app_bar_tests,
  163. multi_app_baz, multi_app_baz_tests,
  164. multi_app_tests]),
  165. lists:foreach(Helpers, [multi_app_bar_tests_helper, multi_app_baz_tests_helper, multi_app_tests_helper]).
  166. %% check that the correct tests are schedule to run for project
  167. multi_app_testset(Config) ->
  168. AppDir = ?config(apps, Config),
  169. Result = ?config(result, Config),
  170. Set = {ok, [{application, multi_app_bar},
  171. {application, multi_app_baz},
  172. {dir, filename:join([AppDir, "test"])}]},
  173. Set = rebar_prv_eunit:prepare_tests(Result).
  174. %% === tests for command line arguments ===
  175. %% no explicit test for cmd line args taking precedence over the rebar.config since
  176. %% almost every single test implies it
  177. %% check tests in the rebar.config are run if no cmd line opts are specified
  178. eunit_tests(Config) ->
  179. State = ?config(result, Config),
  180. Expect = {ok, [{test, multi_app_bar, sanity_test}, {test, multi_app_baz, sanity_test}]},
  181. Expect = rebar_prv_eunit:prepare_tests(State).
  182. %% check eunit_opts from the rebar.config are respected
  183. eunit_opts(Config) ->
  184. State = ?config(result, Config),
  185. Apps = rebar_state:project_apps(State),
  186. lists:foreach(fun(App) -> [verbose] = rebar_app_info:get(App, eunit_opts) end,
  187. Apps).
  188. %% check eunit_first_files from the rebar.config are respected
  189. eunit_first_files(Config) ->
  190. State = ?config(result, Config),
  191. FirstFiles = [filename:join(["apps", "multi_app_bar", "test", "multi_app_bar_tests_helper.erl"]),
  192. filename:join(["apps", "multi_app_baz", "test", "multi_app_baz_tests_helper.erl"])],
  193. Apps = rebar_state:project_apps(State),
  194. lists:foreach(fun(App) -> FirstFiles = rebar_app_info:get(App, eunit_first_files) end,
  195. Apps).
  196. %% check that the --application cmd line opt generates the correct test set
  197. single_application_arg(Config) ->
  198. S = ?config(result, Config),
  199. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--application=multi_app_bar"]),
  200. State = rebar_state:command_parsed_args(S, Args),
  201. {ok, [{application, multi_app_bar}]} = rebar_prv_eunit:prepare_tests(State).
  202. multi_application_arg(Config) ->
  203. S = ?config(result, Config),
  204. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--application=multi_app_bar,multi_app_baz"]),
  205. State = rebar_state:command_parsed_args(S, Args),
  206. {ok, [{application, multi_app_bar}, {application, multi_app_baz}]} = rebar_prv_eunit:prepare_tests(State).
  207. %% check that an invalid --application cmd line opt generates an error
  208. missing_application_arg(Config) ->
  209. S = ?config(result, Config),
  210. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--application=missing_app"]),
  211. State = rebar_state:command_parsed_args(S, Args),
  212. Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Application `missing_app' not found in project."]}}},
  213. Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)).
  214. %% check that the --module cmd line opt generates the correct test set
  215. single_module_arg(Config) ->
  216. AppDir = ?config(apps, Config),
  217. S = ?config(result, Config),
  218. %% necessary to fix paths
  219. Path = code:get_path(),
  220. code:add_paths([filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"])]),
  221. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--module=multi_app_bar"]),
  222. State = rebar_state:command_parsed_args(S, Args),
  223. {ok, [{module, multi_app_bar}]} = rebar_prv_eunit:prepare_tests(State),
  224. %% restore path
  225. code:set_path(Path).
  226. multi_module_arg(Config) ->
  227. AppDir = ?config(apps, Config),
  228. S = ?config(result, Config),
  229. %% necessary to fix paths
  230. Path = code:get_path(),
  231. code:add_paths([filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"])]),
  232. code:add_paths([filename:join([AppDir, "_build", "test", "lib", "multi_app_baz", "ebin"])]),
  233. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--module=multi_app_bar,multi_app_baz"]),
  234. State = rebar_state:command_parsed_args(S, Args),
  235. {ok, [{module, multi_app_bar}, {module, multi_app_baz}]} = rebar_prv_eunit:prepare_tests(State),
  236. %% restore path
  237. code:set_path(Path).
  238. %% check that an invalid --module cmd line opt generates an error
  239. missing_module_arg(Config) ->
  240. S = ?config(result, Config),
  241. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--module=missing_app"]),
  242. State = rebar_state:command_parsed_args(S, Args),
  243. T = rebar_prv_eunit:prepare_tests(State),
  244. Tests = rebar_prv_eunit:validate_tests(S, T),
  245. Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Module `missing_app' not found in project."]}}},
  246. Error = Tests.
  247. %% check that the --suite cmd line opt generates the correct test set
  248. single_suite_arg(Config) ->
  249. AppDir = ?config(apps, Config),
  250. S = ?config(result, Config),
  251. %% necessary to fix paths
  252. Path = code:get_path(),
  253. code:add_paths([filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"])]),
  254. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--suite=multi_app_bar"]),
  255. State = rebar_state:command_parsed_args(S, Args),
  256. {ok, [{module, multi_app_bar}]} = rebar_prv_eunit:prepare_tests(State),
  257. %% restore path
  258. code:set_path(Path).
  259. multi_suite_arg(Config) ->
  260. AppDir = ?config(apps, Config),
  261. S = ?config(result, Config),
  262. %% necessary to fix paths
  263. Path = code:get_path(),
  264. code:add_paths([filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"])]),
  265. code:add_paths([filename:join([AppDir, "_build", "test", "lib", "multi_app_baz", "ebin"])]),
  266. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--suite=multi_app_bar,multi_app_baz"]),
  267. State = rebar_state:command_parsed_args(S, Args),
  268. {ok, [{module, multi_app_bar}, {module, multi_app_baz}]} = rebar_prv_eunit:prepare_tests(State),
  269. %% restore path
  270. code:set_path(Path).
  271. %% check that an invalid --suite cmd line opt generates an error
  272. missing_suite_arg(Config) ->
  273. S = ?config(result, Config),
  274. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--suite=missing_app"]),
  275. State = rebar_state:command_parsed_args(S, Args),
  276. Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Module `missing_app' not found in project."]}}},
  277. Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)).
  278. %% check that the --file cmd line opt generates the correct test set
  279. single_file_arg(Config) ->
  280. S = ?config(result, Config),
  281. AppDir = ?config(apps, Config),
  282. Path = filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin", "multi_app_bar.beam"]),
  283. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--file=" ++ Path]),
  284. State = rebar_state:command_parsed_args(S, Args),
  285. {ok, [{file, Path}]} = rebar_prv_eunit:prepare_tests(State).
  286. multi_file_arg(Config) ->
  287. S = ?config(result, Config),
  288. AppDir = ?config(apps, Config),
  289. BarPath = filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin", "multi_app_bar.beam"]),
  290. BazPath = filename:join([AppDir, "_build", "test", "lib", "multi_app_baz", "ebin", "multi_app_baz.beam"]),
  291. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--file=" ++ BarPath ++ "," ++ BazPath]),
  292. State = rebar_state:command_parsed_args(S, Args),
  293. {ok, [{file, BarPath}, {file, BazPath}]} = rebar_prv_eunit:prepare_tests(State).
  294. %% check that an invalid --file cmd line opt generates an error
  295. missing_file_arg(Config) ->
  296. S = ?config(result, Config),
  297. AppDir = ?config(apps, Config),
  298. Path = filename:join([AppDir, "_build", "test", "lib", "missing_app", "ebin", "missing_app.beam"]),
  299. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--file=" ++ Path]),
  300. State = rebar_state:command_parsed_args(S, Args),
  301. Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["File `" ++ Path ++"' not found."]}}},
  302. Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)).
  303. %% check that the --dir cmd line opt generates the correct test set
  304. single_dir_arg(Config) ->
  305. S = ?config(result, Config),
  306. AppDir = ?config(apps, Config),
  307. Path = filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"]),
  308. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--dir=" ++ Path]),
  309. State = rebar_state:command_parsed_args(S, Args),
  310. {ok, [{dir, Path}]} = rebar_prv_eunit:prepare_tests(State).
  311. multi_dir_arg(Config) ->
  312. S = ?config(result, Config),
  313. AppDir = ?config(apps, Config),
  314. BarPath = filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"]),
  315. BazPath = filename:join([AppDir, "_build", "test", "lib", "multi_app_baz", "ebin"]),
  316. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--dir=" ++ BarPath ++ "," ++ BazPath]),
  317. State = rebar_state:command_parsed_args(S, Args),
  318. {ok, [{dir, BarPath}, {dir, BazPath}]} = rebar_prv_eunit:prepare_tests(State).
  319. %% check that an invalid --dir cmd line opt generates an error
  320. missing_dir_arg(Config) ->
  321. S = ?config(result, Config),
  322. AppDir = ?config(apps, Config),
  323. Path = filename:join([AppDir, "_build", "test", "lib", "missing_app", "ebin"]),
  324. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--dir=" ++ Path]),
  325. State = rebar_state:command_parsed_args(S, Args),
  326. Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Directory `" ++ Path ++"' not found."]}}},
  327. Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)).
  328. %% check that multiple args are composed
  329. multiple_arg_composition(Config) ->
  330. S = ?config(result, Config),
  331. AppDir = ?config(apps, Config),
  332. %% necessary to fix paths
  333. Path = code:get_path(),
  334. code:add_paths([filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"])]),
  335. FilePath = filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin", "multi_app_bar.beam"]),
  336. DirPath = filename:join([AppDir, "_build", "test", "lib", "multi_app_bar", "ebin"]),
  337. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--application=multi_app_bar",
  338. "--module=multi_app_bar",
  339. "--suite=multi_app_bar",
  340. "--file=" ++ FilePath,
  341. "--dir=" ++ DirPath]),
  342. State = rebar_state:command_parsed_args(S, Args),
  343. Expect = [{application, multi_app_bar},
  344. {dir, DirPath},
  345. {file, FilePath},
  346. {module, multi_app_bar},
  347. {module, multi_app_bar}],
  348. {ok, Expect} = rebar_prv_eunit:prepare_tests(State),
  349. %% restore path
  350. code:set_path(Path).
  351. %% check that multiple errors are reported
  352. multiple_arg_errors(Config) ->
  353. S = ?config(result, Config),
  354. AppDir = ?config(apps, Config),
  355. FilePath = filename:join([AppDir, "_build", "test", "lib", "missing_app", "ebin", "missing_app.beam"]),
  356. DirPath = filename:join([AppDir, "_build", "test", "lib", "missing_app", "ebin"]),
  357. {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--application=missing_app",
  358. "--module=missing_app",
  359. "--suite=missing_app",
  360. "--file=" ++ FilePath,
  361. "--dir=" ++ DirPath]),
  362. State = rebar_state:command_parsed_args(S, Args),
  363. T = rebar_prv_eunit:prepare_tests(State),
  364. Tests = rebar_prv_eunit:validate_tests(S, T),
  365. Expect = ["Application `missing_app' not found in project.",
  366. "Directory `" ++ DirPath ++ "' not found.",
  367. "File `" ++ FilePath ++ "' not found.",
  368. "Module `missing_app' not found in project.",
  369. "Module `missing_app' not found in project."],
  370. {error, {rebar_prv_eunit, {eunit_test_errors, Expect}}} = Tests.
  371. misspecified_eunit_tests(Config) ->
  372. State = rebar_test_utils:init_rebar_state(Config, "basic_app_"),
  373. AppDir = ?config(apps, State),
  374. PrivDir = ?config(priv_dir, State),
  375. AppDirs = ["src", "include", "test"],
  376. lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "basic_app", F]),
  377. filename:join([AppDir, F]),
  378. [recursive]) end, AppDirs),
  379. BaseConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, [{d, eunit_compile_define}]}],
  380. RebarConfig = [{eunit_tests, {dir, "test"}}|BaseConfig],
  381. {error, {rebar_prv_eunit, Error}} = rebar_test_utils:run_and_check(State, RebarConfig, ["eunit"], return),
  382. {badconfig, {"Value `~p' of option `~p' must be a list", {{dir, "test"}, eunit_tests}}} = Error.
  383. misspecified_eunit_compile_opts(Config) ->
  384. State = rebar_test_utils:init_rebar_state(Config, "basic_app_"),
  385. AppDir = ?config(apps, State),
  386. PrivDir = ?config(priv_dir, State),
  387. AppDirs = ["src", "include", "test"],
  388. lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "basic_app", F]),
  389. filename:join([AppDir, F]),
  390. [recursive]) end, AppDirs),
  391. RebarConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, {d, eunit_compile_define}}],
  392. {error, {rebar_prv_eunit, Error}} = rebar_test_utils:run_and_check(State, RebarConfig, ["eunit"], return),
  393. {badconfig, {"Value `~p' of option `~p' must be a list", {{d, eunit_compile_define}, eunit_compile_opts}}} = Error.
  394. misspecified_eunit_first_files(Config) ->
  395. State = rebar_test_utils:init_rebar_state(Config, "basic_app_"),
  396. AppDir = ?config(apps, State),
  397. PrivDir = ?config(priv_dir, State),
  398. AppDirs = ["src", "include", "test"],
  399. lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "basic_app", F]),
  400. filename:join([AppDir, F]),
  401. [recursive]) end, AppDirs),
  402. BaseConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, [{d, eunit_compile_define}]}],
  403. RebarConfig = [{eunit_first_files, some_file}|BaseConfig],
  404. {error, {rebar_prv_eunit, Error}} = rebar_test_utils:run_and_check(State, RebarConfig, ["eunit"], return),
  405. {badconfig, {"Value `~p' of option `~p' must be a list", {some_file, eunit_first_files}}} = Error.