summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_eunit_tests.erl40
-rw-r--r--test/rebar_file_utils_tests.erl4
-rw-r--r--test/rebar_require_vsn_tests.erl23
3 files changed, 65 insertions, 2 deletions
diff --git a/test/rebar_eunit_tests.erl b/test/rebar_eunit_tests.erl
index 61a9bbf..bb64507 100644
--- a/test/rebar_eunit_tests.erl
+++ b/test/rebar_eunit_tests.erl
@@ -191,6 +191,46 @@ eunit_with_suites_and_tests_test_() ->
{"Selected suite tests is run once",
?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}]
+ end},
+ {"Ensure EUnit runs a specific test by qualified function name",
+ setup,
+ fun() ->
+ setup_project_with_multiple_modules(),
+ rebar("-v eunit tests=myapp_mymod:myprivate_test")
+ end,
+ fun teardown/1,
+ fun(RebarOut) ->
+ [{"Selected test is run",
+ [?_assert(string:str(RebarOut,
+ "myapp_mymod:myprivate_test/0")
+ =/= 0)]},
+
+ {"Only selected test is run",
+ [?_assert(string:str(RebarOut,
+ "Test passed.") =/= 0)]}]
+ end},
+ {"Ensure EUnit runs a specific test by qualified function "
+ ++ "name and tests from other module",
+ setup,
+ fun() ->
+ setup_project_with_multiple_modules(),
+ rebar("-v eunit suites=myapp_mymod3 "
+ ++ "tests=myapp_mymod:myprivate_test")
+ end,
+ fun teardown/1,
+ fun(RebarOut) ->
+ [{"Selected test is run",
+ [?_assert(string:str(RebarOut,
+ "myapp_mymod:myprivate_test/0") =/= 0)]},
+
+ {"Tests from module are run",
+ [?_assert(string:str(RebarOut,
+ "myapp_mymod3:") =/= 0)]},
+
+ {"Only selected tests are run",
+ [?_assert(string:str(RebarOut,
+ "Failed: 1. Skipped: 0. Passed: 1")
+ =/= 0)]}]
end}].
cover_test_() ->
diff --git a/test/rebar_file_utils_tests.erl b/test/rebar_file_utils_tests.erl
index 26a6f9f..a191765 100644
--- a/test/rebar_file_utils_tests.erl
+++ b/test/rebar_file_utils_tests.erl
@@ -191,7 +191,7 @@ cp_r_overwrite_file_fail_test_() ->
filename:join([?TMP_DIR,"dest","file1"]),0)
end,
fun teardown/1,
- [?_assertError({badmatch,_},
+ [?_assertThrow(rebar_abort,
rebar_file_utils:cp_r(
[filename:join([?TMP_DIR,"source","file1"])],
filename:join([?TMP_DIR,"dest"])))]}.
@@ -210,7 +210,7 @@ cp_r_overwrite_dir_fail_test_() ->
filename:join([?TMP_DIR,"dest","source","file1"]),0)
end,
fun teardown/1,
- [?_assertError({badmatch,_},
+ [?_assertThrow(rebar_abort,
rebar_file_utils:cp_r(
[filename:join([?TMP_DIR,"source"])],
filename:join([?TMP_DIR,"dest"])))]}.
diff --git a/test/rebar_require_vsn_tests.erl b/test/rebar_require_vsn_tests.erl
new file mode 100644
index 0000000..2d3a1ec
--- /dev/null
+++ b/test/rebar_require_vsn_tests.erl
@@ -0,0 +1,23 @@
+-module(rebar_require_vsn_tests).
+
+-compile(export_all).
+
+-include_lib("eunit/include/eunit.hrl").
+
+version_tuple_test_() ->
+ [%% typical cases
+ ?_assert(rebar_require_vsn:version_tuple("R15B", "eunit") =:= {15, 0}),
+ ?_assert(rebar_require_vsn:version_tuple("R15B01", "eunit") =:= {15, 1}),
+ ?_assert(rebar_require_vsn:version_tuple("R15B02", "eunit") =:= {15, 2}),
+ ?_assert(rebar_require_vsn:version_tuple("R15B03-1", "eunit") =:= {15, 3}),
+ ?_assert(rebar_require_vsn:version_tuple("R15B03", "eunit") =:= {15, 3}),
+ ?_assert(rebar_require_vsn:version_tuple("R16B", "eunit") =:= {16, 0}),
+ ?_assert(rebar_require_vsn:version_tuple("R16B01", "eunit") =:= {16, 1}),
+ ?_assert(rebar_require_vsn:version_tuple("R16B02", "eunit") =:= {16, 2}),
+ ?_assert(rebar_require_vsn:version_tuple("R16B03", "eunit") =:= {16, 3}),
+ ?_assert(rebar_require_vsn:version_tuple("R16B03-1", "eunit") =:= {16, 3}),
+ ?_assert(rebar_require_vsn:version_tuple("17", "eunit") =:= {17, 0}),
+ %% error cases
+ ?_assertException(throw, rebar_abort, rebar_require_vsn:version_tuple("", "eunit")),
+ ?_assertException(throw, rebar_abort, rebar_require_vsn:version_tuple("abc", "eunit"))
+ ].