summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Kovalev <kovyl2404@gmail.com>2015-06-26 11:52:59 +0300
committerViacheslav Kovalev <kovyl2404@gmail.com>2015-06-26 11:52:59 +0300
commit250b626fc658f08b17bf0f9bf075b4d68ea260da (patch)
treec2c83f9c7689448ab2c58dfbe6c711644a7c2a35
parent24815ebc5f5481d95e379969eacfc0a041636f3c (diff)
parent4eaa21cd274ac69f13429a63b8b7f2ed446e6870 (diff)
Merge branch 'windows-ct-fix' of git://github.com/Taure/rebar3 into Taure-windows-ct-fix
Conflicts: src/rebar_file_utils.erl
-rw-r--r--src/rebar_file_utils.erl52
-rw-r--r--src/rebar_prv_dialyzer.erl2
-rw-r--r--test/rebar_test_utils.erl20
3 files changed, 59 insertions, 15 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index 32abd4b..735ab49 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -75,14 +75,40 @@ symlink_or_copy(Source, Target) ->
{error, eexist} ->
ok;
{error, _} ->
- Target2 = case is_binary(Target) of
- true -> unicode:characters_to_list(Target);
- false -> Target
- end,
- rm_rf(Target2),
- cp_r([Source], Target)
+ case os:type() of
+ {win32, _} ->
+ S = unicode:characters_to_list(Source),
+ T = unicode:characters_to_list(Target),
+ case filelib:is_dir(S) of
+ true ->
+ win32_symlink(S, T);
+ false ->
+ ok
+ end;
+ _ ->
+ case filelib:is_dir(Target) of
+ true ->
+ ok;
+ false ->
+ cp_r([Source], Target)
+ end
+ end
end.
+win32_symlink(Source, Target) ->
+ Res = rebar_utils:sh(
+ ?FMT("cmd /c mklink /j \"~s\" \"~s\"",
+ [filename:nativename(Target), filename:nativename(Source)]),
+ [{use_stdout, false}, return_on_error]),
+ case win32_ok(Res) of
+ true -> ok;
+ false ->
+ {error, lists:flatten(
+ io_lib:format("Failed to sumlink ~s to ~s~n",
+ [Source, Target]))}
+ end.
+
+
%% @doc Remove files and directories.
%% Target is a single filename, directoryname or wildcard expression.
-spec rm_rf(string()) -> 'ok'.
@@ -130,11 +156,11 @@ mv(Source, Dest) ->
ok;
{win32, _} ->
Res = rebar_utils:sh(
- ?FMT("robocopy /move /e \"~s\" \"~s\" 1> nul",
+ ?FMT("robocopy /move /s \"~s\" \"~s\" 1> nul",
[filename:nativename(Source),
filename:nativename(Dest)]),
[{use_stdout, false}, return_on_error]),
- case win32_robocopy_ok(Res) of
+ case win32_ok(Res) of
true -> ok;
false ->
{error, lists:flatten(
@@ -143,9 +169,9 @@ mv(Source, Dest) ->
end
end.
-win32_robocopy_ok({ok, _}) -> true;
-win32_robocopy_ok({error, {Rc, _}}) when Rc<9; Rc=:=16 -> true;
-win32_robocopy_ok(_) -> false.
+win32_ok({ok, _}) -> true;
+win32_ok({error, {Rc, _}}) when Rc<9; Rc=:=16 -> true;
+win32_ok(_) -> false.
delete_each([]) ->
ok;
@@ -224,10 +250,10 @@ xcopy_win32(Source,Dest)->
%% "xcopy \"~s\" \"~s\" /q /y /e 2> nul", Chanegd to robocopy to
%% handle long names. May have issues with older windows.
Res = rebar_utils:sh(
- ?FMT("robocopy \"~s\" \"~s\" /e /is 2> nul",
+ ?FMT("robocopy \"~s\" \"~s\" /e /is /purge 2> nul",
[filename:nativename(Source), filename:nativename(Dest)]),
[{use_stdout, false}, return_on_error]),
- case win32_robocopy_ok(Res) of
+ case win32_ok(Res) of
true -> ok;
false ->
{error, lists:flatten(
diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl
index fb0db95..af0bae3 100644
--- a/src/rebar_prv_dialyzer.erl
+++ b/src/rebar_prv_dialyzer.erl
@@ -389,7 +389,7 @@ run_dialyzer(State, Opts, Output) ->
{check_plt, false} |
Opts],
?DEBUG("Running dialyzer with options: ~p~n", [Opts2]),
- _ = dialyzer:run(Opts2),
+ dialyzer:run(Opts2),
{0, State}
end.
diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl
index 2f4d532..b210bc2 100644
--- a/test/rebar_test_utils.erl
+++ b/test/rebar_test_utils.erl
@@ -214,6 +214,7 @@ check_results(AppDir, Expected) ->
?assertNotEqual(false, lists:keyfind(Name, 1, DepsNames))
; ({dep, Name, Vsn}) ->
ct:pal("Dep Name: ~p, Vsn: ~p", [Name, Vsn]),
+ ct:pal("DepNames: ~p~n", [DepsNames]),
case lists:keyfind(Name, 1, DepsNames) of
false ->
error({dep_not_found, Name});
@@ -273,11 +274,28 @@ check_results(AppDir, Expected) ->
LibDir = filename:join([ReleaseDir, Name, "lib"]),
{ok, RelLibs} = file:list_dir(LibDir),
+ ct:pal("RelLibs: ~p~n", [RelLibs]),
IsSymLinkFun =
fun(X) ->
ec_file:is_symlink(filename:join(LibDir, X))
end,
- DevMode = lists:all(IsSymLinkFun, RelLibs),
+ IsDirFun =
+ fun(X) ->
+ filelib:is_dir(filename:join([LibDir, X]))
+ end,
+ DevMode =
+ case os:type() of
+ {unix, _} ->
+ lists:all(IsSymLinkFun, RelLibs);
+ {win32, _} ->
+ Bool = lists:all(IsDirFun, RelLibs),
+ case ExpectedDevMode of
+ true ->
+ Bool;
+ false ->
+ not Bool
+ end
+ end,
?assertEqual(ExpectedDevMode, DevMode),
%% throws not_found if it doesn't exist