mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
rebar_eunit_tests: check return values
This commit is contained in:
parent
773a3dc1f5
commit
e3fe1c6903
1 changed files with 15 additions and 21 deletions
|
@ -168,46 +168,40 @@ basic_setup_test_() ->
|
||||||
"myfunc_test() -> ?assertMatch(ok, myapp_mymod:myfunc()).\n"]).
|
"myfunc_test() -> ?assertMatch(ok, myapp_mymod:myfunc()).\n"]).
|
||||||
|
|
||||||
make_tmp_dir() ->
|
make_tmp_dir() ->
|
||||||
file:make_dir(?TMP_DIR).
|
ok = file:make_dir(?TMP_DIR).
|
||||||
|
|
||||||
setup_environment() ->
|
setup_environment() ->
|
||||||
make_tmp_dir(),
|
ok = make_tmp_dir(),
|
||||||
prepare_rebar_script(),
|
prepare_rebar_script(),
|
||||||
file:set_cwd(?TMP_DIR).
|
ok = file:set_cwd(?TMP_DIR).
|
||||||
|
|
||||||
setup_basic_project() ->
|
setup_basic_project() ->
|
||||||
setup_environment(),
|
setup_environment(),
|
||||||
rebar("create-app appid=myapp"),
|
rebar("create-app appid=myapp"),
|
||||||
file:make_dir("ebin"),
|
ok = file:make_dir("ebin"),
|
||||||
file:make_dir("test"),
|
ok = file:make_dir("test"),
|
||||||
file:write_file("test/myapp_mymod_tests.erl", ?myapp_mymod_tests),
|
ok = file:write_file("test/myapp_mymod_tests.erl", ?myapp_mymod_tests),
|
||||||
file:write_file("src/myapp_mymod.erl", ?myapp_mymod).
|
ok = file:write_file("src/myapp_mymod.erl", ?myapp_mymod).
|
||||||
|
|
||||||
setup_cover_project() ->
|
setup_cover_project() ->
|
||||||
setup_basic_project(),
|
setup_basic_project(),
|
||||||
file:write_file("rebar.config", "{cover_enabled, true}.\n").
|
ok = file:write_file("rebar.config", "{cover_enabled, true}.\n").
|
||||||
|
|
||||||
setup_cover_project_with_suite() ->
|
setup_cover_project_with_suite() ->
|
||||||
setup_cover_project(),
|
setup_cover_project(),
|
||||||
file:write_file("test/mysuite.erl", ?mysuite),
|
ok = file:write_file("test/mysuite.erl", ?mysuite),
|
||||||
file:write_file("test/myapp_mymod_defined_in_mysuite_tests.erl",
|
ok = file:write_file("test/myapp_mymod_defined_in_mysuite_tests.erl",
|
||||||
?myapp_mymod_defined_in_mysuite_tests).
|
?myapp_mymod_defined_in_mysuite_tests).
|
||||||
|
|
||||||
teardown(_) ->
|
teardown(_) ->
|
||||||
file:set_cwd(".."),
|
ok = file:set_cwd(".."),
|
||||||
remove_tmp_dir(),
|
ok = remove_tmp_dir().
|
||||||
ok.
|
|
||||||
|
|
||||||
remove_tmp_dir() ->
|
remove_tmp_dir() ->
|
||||||
remove_tmp_dir(arg_for_eunit).
|
remove_tmp_dir(arg_for_eunit).
|
||||||
|
|
||||||
remove_tmp_dir(_) ->
|
remove_tmp_dir(_) ->
|
||||||
case os:type() of
|
ok = rebar_file_utils:rm_rf(?TMP_DIR).
|
||||||
{unix, _} ->
|
|
||||||
os:cmd("rm -rf " ++ ?TMP_DIR ++ " 2>/dev/null");
|
|
||||||
{win32, _} ->
|
|
||||||
os:cmd("rmdir /S /Q " ++ filename:nativename(?TMP_DIR))
|
|
||||||
end.
|
|
||||||
|
|
||||||
%% ====================================================================
|
%% ====================================================================
|
||||||
%% Helper Functions
|
%% Helper Functions
|
||||||
|
@ -252,6 +246,6 @@ assert_full_coverage(Mod) ->
|
||||||
Result = [X || X <- string:tokens(binary_to_list(F), "\n"),
|
Result = [X || X <- string:tokens(binary_to_list(F), "\n"),
|
||||||
string:str(X, Mod) =/= 0,
|
string:str(X, Mod) =/= 0,
|
||||||
string:str(X, "100%") =/= 0],
|
string:str(X, "100%") =/= 0],
|
||||||
file:close(F),
|
ok = file:close(F),
|
||||||
?assert(length(Result) =:= 1)
|
?assert(length(Result) =:= 1)
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in a new issue