summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-10-26 08:31:52 -0400
committerFred Hebert <mononcqc@ferd.ca>2015-10-26 08:31:52 -0400
commit992dfacdbf4bdf4f9c35911bce2cb50c36c75f27 (patch)
tree3198e836a3f5ad26f6efecbdf072b723d5e18a22
parentf4538e1f69e38baa31a526484a93e93a04136397 (diff)
parentea84fdaf31fddab55ba3d9630710b21e5db209bc (diff)
downloadrebar-992dfacdbf4bdf4f9c35911bce2cb50c36c75f27.tar.gz
Merge pull request #557 from lrascao/fix/windows_eunit_tests
Fix windows eunit tests
-rw-r--r--src/rebar_file_utils.erl12
-rw-r--r--test/rebar_compiler_tests.erl6
-rw-r--r--test/rebar_eunit_tests.erl16
-rw-r--r--test/rebar_file_utils_tests.erl2
-rw-r--r--test/rebar_xref_eunit.erl4
5 files changed, 23 insertions, 17 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index 0fc1403..a4d3be7 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -88,7 +88,7 @@ mv(Source, Dest) ->
?FMT("move /y \"~s\" \"~s\" 1> nul",
[filename:nativename(Source),
filename:nativename(Dest)]),
- [{use_stdout, false}, return_on_error]),
+ [{use_stdout, false}, abort_on_error]),
case R of
[] ->
ok;
@@ -131,14 +131,14 @@ delete_each_dir_win32([]) -> ok;
delete_each_dir_win32([Dir | Rest]) ->
{ok, []} = rebar_utils:sh(?FMT("rd /q /s \"~s\"",
[filename:nativename(Dir)]),
- [{use_stdout, false}, return_on_error]),
+ [{use_stdout, false}, abort_on_error]),
delete_each_dir_win32(Rest).
xcopy_win32(Source,Dest)->
{ok, R} = rebar_utils:sh(
?FMT("xcopy \"~s\" \"~s\" /q /y /e 2> nul",
[filename:nativename(Source), filename:nativename(Dest)]),
- [{use_stdout, false}, return_on_error]),
+ [{use_stdout, false}, abort_on_error]),
case length(R) > 0 of
%% when xcopy fails, stdout is empty and and error message is printed
%% to stderr (which is redirected to nul)
@@ -162,8 +162,10 @@ cp_r_win32({false, Source} = S,{true, DestDir}) ->
cp_r_win32(S, {false, filename:join(DestDir, filename:basename(Source))});
cp_r_win32({false, Source},{false, Dest}) ->
%% from file to file
- {ok,_} = file:copy(Source, Dest),
- ok;
+ case file:copy(Source, Dest) of
+ {ok,_} -> ok;
+ _ -> throw(rebar_abort)
+ end;
cp_r_win32({true, SourceDir}, {false, DestDir}) ->
case filelib:is_regular(DestDir) of
true ->
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() ->