浏览代码

Merge branch 'Taure-windows-ct-fix' into windows-ct-fix

pull/489/head
Viacheslav Kovalev 10 年前
父节点
当前提交
66f007f7df
共有 3 个文件被更改,包括 59 次插入15 次删除
  1. +39
    -13
      src/rebar_file_utils.erl
  2. +1
    -1
      src/rebar_prv_dialyzer.erl
  3. +19
    -1
      test/rebar_test_utils.erl

+ 39
- 13
src/rebar_file_utils.erl 查看文件

@ -75,14 +75,40 @@ symlink_or_copy(Source, Target) ->
{error, eexist} -> {error, eexist} ->
ok; ok;
{error, _} -> {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. 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. %% @doc Remove files and directories.
%% Target is a single filename, directoryname or wildcard expression. %% Target is a single filename, directoryname or wildcard expression.
-spec rm_rf(string()) -> 'ok'. -spec rm_rf(string()) -> 'ok'.
@ -130,11 +156,11 @@ mv(Source, Dest) ->
ok; ok;
{win32, _} -> {win32, _} ->
Res = rebar_utils:sh( 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(Source),
filename:nativename(Dest)]), filename:nativename(Dest)]),
[{use_stdout, false}, return_on_error]), [{use_stdout, false}, return_on_error]),
case win32_robocopy_ok(Res) of
case win32_ok(Res) of
true -> ok; true -> ok;
false -> false ->
{error, lists:flatten( {error, lists:flatten(
@ -143,9 +169,9 @@ mv(Source, Dest) ->
end end
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([]) -> delete_each([]) ->
ok; ok;
@ -224,10 +250,10 @@ xcopy_win32(Source,Dest)->
%% "xcopy \"~s\" \"~s\" /q /y /e 2> nul", Chanegd to robocopy to %% "xcopy \"~s\" \"~s\" /q /y /e 2> nul", Chanegd to robocopy to
%% handle long names. May have issues with older windows. %% handle long names. May have issues with older windows.
Res = rebar_utils:sh( 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)]), [filename:nativename(Source), filename:nativename(Dest)]),
[{use_stdout, false}, return_on_error]), [{use_stdout, false}, return_on_error]),
case win32_robocopy_ok(Res) of
case win32_ok(Res) of
true -> ok; true -> ok;
false -> false ->
{error, lists:flatten( {error, lists:flatten(

+ 1
- 1
src/rebar_prv_dialyzer.erl 查看文件

@ -389,7 +389,7 @@ run_dialyzer(State, Opts, Output) ->
{check_plt, false} | {check_plt, false} |
Opts], Opts],
?DEBUG("Running dialyzer with options: ~p~n", [Opts2]), ?DEBUG("Running dialyzer with options: ~p~n", [Opts2]),
_ = dialyzer:run(Opts2),
dialyzer:run(Opts2),
{0, State} {0, State}
end. end.

+ 19
- 1
test/rebar_test_utils.erl 查看文件

@ -214,6 +214,7 @@ check_results(AppDir, Expected) ->
?assertNotEqual(false, lists:keyfind(Name, 1, DepsNames)) ?assertNotEqual(false, lists:keyfind(Name, 1, DepsNames))
; ({dep, Name, Vsn}) -> ; ({dep, Name, Vsn}) ->
ct:pal("Dep Name: ~p, Vsn: ~p", [Name, Vsn]), ct:pal("Dep Name: ~p, Vsn: ~p", [Name, Vsn]),
ct:pal("DepNames: ~p~n", [DepsNames]),
case lists:keyfind(Name, 1, DepsNames) of case lists:keyfind(Name, 1, DepsNames) of
false -> false ->
error({dep_not_found, Name}); error({dep_not_found, Name});
@ -273,11 +274,28 @@ check_results(AppDir, Expected) ->
LibDir = filename:join([ReleaseDir, Name, "lib"]), LibDir = filename:join([ReleaseDir, Name, "lib"]),
{ok, RelLibs} = file:list_dir(LibDir), {ok, RelLibs} = file:list_dir(LibDir),
ct:pal("RelLibs: ~p~n", [RelLibs]),
IsSymLinkFun = IsSymLinkFun =
fun(X) -> fun(X) ->
ec_file:is_symlink(filename:join(LibDir, X)) ec_file:is_symlink(filename:join(LibDir, X))
end, 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), ?assertEqual(ExpectedDevMode, DevMode),
%% throws not_found if it doesn't exist %% throws not_found if it doesn't exist

正在加载...
取消
保存