summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrey Teplyashin <platinumthinker@gmail.com>2015-09-15 22:21:04 +0600
committerAndrey Teplyashin <platinumthinker@gmail.com>2015-09-21 12:47:47 +0600
commit06c4b5df68095b598b08600c17090b3e822492df (patch)
tree53c27053eb3e57998427da73d0f9d96d3a11fb54 /test
parenta7e83237a478523f3ffe5cad55089e603c2556a0 (diff)
downloadrebar-06c4b5df68095b598b08600c17090b3e822492df.tar.gz
Add test for eunit_first_files
Diffstat (limited to 'test')
-rw-r--r--test/rebar_eunit_tests.erl38
1 files changed, 37 insertions, 1 deletions
diff --git a/test/rebar_eunit_tests.erl b/test/rebar_eunit_tests.erl
index a7fc51e..cb331a4 100644
--- a/test/rebar_eunit_tests.erl
+++ b/test/rebar_eunit_tests.erl
@@ -231,7 +231,21 @@ eunit_with_suites_and_tests_test_() ->
[?_assert(string:str(RebarOut,
"Failed: 1. Skipped: 0. Passed: 1")
=/= 0)]}]
- end}].
+ end},
+ {"Ensure EUnit runs a test with eunit_first_files",
+ setup,
+ fun() ->
+ setup_eunit_first_files(),
+ rebar("eunit")
+ end,
+ fun teardown/1,
+ fun(RebarOut) ->
+ [
+ {"Don't pass tests without erl_first_file",
+ [?_assert(string:str(RebarOut,
+ "Test passed.") =/= 0)]}]
+ end}
+ ].
cover_test_() ->
{"Ensure Cover runs with tests in a test dir and no defined suite",
@@ -420,6 +434,19 @@ code_path_test_() ->
"myfunc3() -> ok.\n",
"mygenerator_test_() -> [?_assertEqual(true, false)].\n"]).
+-define(myapp_mymod4,
+ ["-module(myapp_mymod4).\n",
+ "-compile({parse_transform, myapp_mymod4_parse_transform}).\n",
+ "-include_lib(\"eunit/include/eunit.hrl\").\n",
+ "-export([ok/0]).\n",
+ "pt_test() -> ?assert(myapp_mymod4:ok()).\n"]).
+
+-define(myapp_mymod4_parse_transform,
+ ["-module(myapp_mymod4_parse_transform).\n",
+ "-export([parse_transform/2]).\n",
+ "parse_transform(Forms, _Options) ->\n",
+ "Forms ++ [{function,29,ok,0,[{clause,9,[],[],[{atom,9,true}]}]}].\n"]).
+
-define(mysuite,
["-module(mysuite).\n",
"-export([all_test_/0]).\n",
@@ -462,6 +489,15 @@ setup_project_with_multiple_modules() ->
ok = file:write_file("src/myapp_mymod2.erl", ?myapp_mymod2),
ok = file:write_file("src/myapp_mymod3.erl", ?myapp_mymod3).
+setup_eunit_first_files() ->
+ setup_environment(),
+ rebar("create-app appid=myapp"),
+ ok = file:write_file("src/myapp_mymod4.erl", ?myapp_mymod4),
+ ok = file:write_file("src/myapp_mymod4_parse_transform.erl",
+ ?myapp_mymod4_parse_transform),
+ ok = file:write_file("rebar.config",
+ "{erl_first_files, [\"src/myapp_mymod4_parse_transform.erl\"]}.\n").
+
setup_cover_project() ->
setup_basic_project(),
ok = file:write_file("rebar.config", "{cover_enabled, true}.\n").