diff options
author | Luis Rascão <luis.rascao@gmail.com> | 2015-10-12 13:48:09 +0100 |
---|---|---|
committer | Luis Rascão <luis.rascao@gmail.com> | 2015-10-25 15:20:53 +0000 |
commit | ea84fdaf31fddab55ba3d9630710b21e5db209bc (patch) | |
tree | e7591d73546a068c34d22a72fcd3e895e9877b0e /test | |
parent | b870e061a3038039e1721723b17c8e8cd27b82b5 (diff) | |
download | rebar-ea84fdaf31fddab55ba3d9630710b21e5db209bc.tar.gz |
Fix windows eunit tests
File tests: windows file operations should abort on error
the same as unix operations invoked through sh. Also
windows does not support the '?' character in filenames.
Eunit tests: the 'All' prefix is missing on the 'x tests passed'
message. Eunit only prints the 'All' prefix if there are more
than 2 passed tests, dropping the prefix on the match works
for all cases.
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_compiler_tests.erl | 6 | ||||
-rw-r--r-- | test/rebar_eunit_tests.erl | 16 | ||||
-rw-r--r-- | test/rebar_file_utils_tests.erl | 2 | ||||
-rw-r--r-- | test/rebar_xref_eunit.erl | 4 |
4 files changed, 16 insertions, 12 deletions
diff --git a/test/rebar_compiler_tests.erl b/test/rebar_compiler_tests.erl index 3ed600b..104a7d8 100644 --- a/test/rebar_compiler_tests.erl +++ b/test/rebar_compiler_tests.erl @@ -84,11 +84,11 @@ not_keep_going_test_() -> setup, fun() -> setup_basic_project(), - setup_rebar_config(), - rebar("compile") + setup_rebar_config() end, fun teardown/1, - fun(RebarOut)-> + fun()-> + RebarOut = rebar("compile"), [ {"Exit after error", ?_assert(string:str(RebarOut, "ERROR: compile failed") =/= 0)} diff --git a/test/rebar_eunit_tests.erl b/test/rebar_eunit_tests.erl index cb331a4..d481dae 100644 --- a/test/rebar_eunit_tests.erl +++ b/test/rebar_eunit_tests.erl @@ -56,7 +56,7 @@ eunit_test_() -> ?_assert(string:str(RebarOut, "myapp_mymod:") =/= 0)}, {"Tests are only run once", - ?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}] + ?_assert(string:str(RebarOut, "2 tests passed") =/= 0)}] end}. eunit_with_suites_and_tests_test_() -> @@ -80,7 +80,7 @@ eunit_with_suites_and_tests_test_() -> ?_assert(string:str(RebarOut, "myapp_mymod:") =:= 0)}, {"Selected suite tests are only run once", - ?_assert(string:str(RebarOut, "All 4 tests passed") =/= 0)}] + ?_assert(string:str(RebarOut, "4 tests passed") =/= 0)}] end}, {"Ensure EUnit runs selected _tests suites", setup, fun() -> @@ -102,7 +102,7 @@ eunit_with_suites_and_tests_test_() -> ?_assert(string:str(RebarOut, "myapp_mymod:") =:= 0)}, {"Selected suite tests are only run once", - ?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}] + ?_assert(string:str(RebarOut, "2 tests passed") =/= 0)}] end}, {"Ensure EUnit runs a specific test defined in a selected suite", setup, fun() -> @@ -154,7 +154,7 @@ eunit_with_suites_and_tests_test_() -> "myapp_mymod2_tests:myfunc2_test/0") =/= 0)]}, {"Selected suite tests are run once", - ?_assert(string:str(RebarOut, "All 3 tests passed") =/= 0)}] + ?_assert(string:str(RebarOut, "3 tests passed") =/= 0)}] end}, {"Ensure EUnit runs specific test in a _tests suite", setup, @@ -190,7 +190,7 @@ eunit_with_suites_and_tests_test_() -> =/= 0)]}, {"Selected suite tests is run once", - ?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}] + ?_assert(string:str(RebarOut, "2 tests passed") =/= 0)}] end}, {"Ensure EUnit runs a specific test by qualified function name", setup, @@ -325,7 +325,11 @@ environment_test_() -> assert_rebar_runs() -> prepare_rebar_script(), - ?assert(string:str(os:cmd(filename:nativename("./" ++ ?TMP_DIR ++ "rebar")), + {ok, Cwd} = file:get_cwd(), + ok = file:set_cwd(?TMP_DIR), + RebarOut = os:cmd(filename:nativename("./rebar")), + ok = file:set_cwd(Cwd), + ?assert(string:str(RebarOut, "No command to run specified!") =/= 0). basic_setup_test_() -> diff --git a/test/rebar_file_utils_tests.erl b/test/rebar_file_utils_tests.erl index fc76d58..c9b4192 100644 --- a/test/rebar_file_utils_tests.erl +++ b/test/rebar_file_utils_tests.erl @@ -36,7 +36,7 @@ -define(TMP_DIR, "tmp_file_utils"). --define(SRC, "source dir?"). +-define(SRC, "source dir"). -define(DST, "dest (dir)"). -define(FILE1, "file 1"). -define(FILE2, "file(2)"). diff --git a/test/rebar_xref_eunit.erl b/test/rebar_xref_eunit.erl index 341fe2e..f32ea46 100644 --- a/test/rebar_xref_eunit.erl +++ b/test/rebar_xref_eunit.erl @@ -192,8 +192,8 @@ prepare_rebar_script() -> {unix, _} -> [] = os:cmd("chmod u+x " ++ Rebar); {win32, _} -> - {ok, _} = file:copy(?REBAR_SCRIPT ++ ".bat", - ?TMP_DIR ++ "rebar.bat") + {ok, _} = file:copy(?REBAR_SCRIPT ++ ".cmd", + ?TMP_DIR ++ "rebar.cmd") end. rebar() -> |