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

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