Merge pull request #47 from ericbmerritt/master
fix various issues in ci and dialyzer
This commit is contained in:
commit
71e6458251
4 changed files with 55 additions and 28 deletions
|
@ -7,8 +7,7 @@ otp_release:
|
||||||
- R14B04
|
- R14B04
|
||||||
- R14B03
|
- R14B03
|
||||||
- R14B02
|
- R14B02
|
||||||
script: "make"
|
script: "make rebuild"
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- next
|
|
||||||
|
|
45
Makefile
45
Makefile
|
@ -3,22 +3,49 @@
|
||||||
# BSD License see COPYING
|
# BSD License see COPYING
|
||||||
|
|
||||||
ERL = $(shell which erl)
|
ERL = $(shell which erl)
|
||||||
ERL_VER = $(shell erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell)
|
ERL_VER = $(shell erl -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().' -noshell)
|
||||||
|
ERLWARE_COMMONS_PLT=$(CURDIR)/.erlware_commons_plt
|
||||||
|
|
||||||
ERLFLAGS= -pa $(CURDIR)/.eunit -pa $(CURDIR)/ebin -pa $(CURDIR)/*/ebin
|
ERLFLAGS= -pa $(CURDIR)/.eunit -pa $(CURDIR)/ebin -pa $(CURDIR)/*/ebin
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Verify that the programs we need to run are installed on this system
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
REBAR=$(shell which rebar)
|
REBAR=$(shell which rebar)
|
||||||
|
|
||||||
ifeq ($(REBAR),)
|
ifeq ($(REBAR),)
|
||||||
$(error "Rebar not available on this system")
|
$(error "Rebar not available on this system")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ERLWARE_COMMONS_PLT=$(CURDIR)/.erlware_commons_plt
|
# =============================================================================
|
||||||
|
# Handle version discovery
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# We have a problem that we only have 10 minutes to build on travis
|
||||||
|
# and those travis boxes are quite small. This is ok for the fast
|
||||||
|
# dialyzer on R15 and above. However on R14 and below we have the
|
||||||
|
# problem that travis times out. The code below lets us not run
|
||||||
|
# dialyzer on R14
|
||||||
|
OTP_VSN=$(shell erl -noshell -eval 'io:format("~p", [erlang:system_info(otp_release)]), erlang:halt(0).' | perl -lne 'print for /R(\d+).*/g')
|
||||||
|
TRAVIS_SLOW=$(shell expr $(OTP_VSN) \<= 15 )
|
||||||
|
|
||||||
|
ifeq ($(TRAVIS_SLOW), 0)
|
||||||
|
DIALYZER=$(shell which dialyzer)
|
||||||
|
else
|
||||||
|
DIALYZER=: not running dialyzer on R14 or R15
|
||||||
|
endif
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Rules to build the system
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
.PHONY: all compile doc clean test shell distclean pdf get-deps rebuild dialyzer typer
|
.PHONY: all compile doc clean test shell distclean pdf get-deps rebuild dialyzer typer
|
||||||
|
|
||||||
all: compile doc test
|
all: compile doc test
|
||||||
|
|
||||||
|
rebuild: distclean deps compile dialyzer test
|
||||||
|
|
||||||
deps: .DEV_MODE
|
deps: .DEV_MODE
|
||||||
$(REBAR) get-deps compile
|
$(REBAR) get-deps compile
|
||||||
|
|
||||||
|
@ -43,29 +70,29 @@ $(ERLWARE_COMMONS_PLT).$(ERL_VER).erts:
|
||||||
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
- dialyzer --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).base --build_plt \
|
- $(DIALYZER) --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).erts --build_plt \
|
||||||
--apps erts
|
--apps erts
|
||||||
|
|
||||||
$(ERLWARE_COMMONS_PLT).$(ERL_VER).kernel:$(ERLWARE_COMMONS_PLT).$(ERL_VER).erts
|
$(ERLWARE_COMMONS_PLT).$(ERL_VER).kernel:$(ERLWARE_COMMONS_PLT).$(ERL_VER).erts
|
||||||
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
||||||
@echo
|
@echo
|
||||||
- dialyzer --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).base --build_plt \
|
- $(DIALYZER) --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).kernel --build_plt \
|
||||||
--apps kernel
|
--apps kernel
|
||||||
|
|
||||||
$(ERLWARE_COMMONS_PLT).$(ERL_VER).base:$(ERLWARE_COMMONS_PLT).$(ERL_VER).kernel
|
$(ERLWARE_COMMONS_PLT).$(ERL_VER).base:$(ERLWARE_COMMONS_PLT).$(ERL_VER).kernel
|
||||||
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
||||||
@echo
|
@echo
|
||||||
- dialyzer --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).base --build_plt \
|
- $(DIALYZER) --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).base --build_plt \
|
||||||
--apps stdlib
|
--apps stdlib
|
||||||
|
|
||||||
$(ERLWARE_COMMONS_PLT).$(ERL_VER): $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
$(ERLWARE_COMMONS_PLT).$(ERL_VER): $(ERLWARE_COMMONS_PLT).$(ERL_VER).base
|
||||||
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
@echo Building local plt at $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
||||||
@echo
|
@echo
|
||||||
- dialyzer --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER) --add_to_plt --plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).base \
|
- $(DIALYZER) --fullpath --verbose --output_plt $(ERLWARE_COMMONS_PLT).$(ERL_VER) --add_to_plt --plt $(ERLWARE_COMMONS_PLT).$(ERL_VER).base \
|
||||||
--apps eunit -r deps
|
--apps eunit -r deps
|
||||||
|
|
||||||
dialyzer: $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
dialyzer: compile $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
||||||
dialyzer --fullpath --plt $(ERLWARE_COMMONS_PLT).$(ERL_VER) -Wrace_conditions -r ./ebin
|
$(DIALYZER) --fullpath --plt $(ERLWARE_COMMONS_PLT).$(ERL_VER) -Wrace_conditions -r ./ebin
|
||||||
|
|
||||||
typer: $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
typer: $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
||||||
typer --plt $(ERLWARE_COMMONS_PLT).$(ERL_VER) -r ./src
|
typer --plt $(ERLWARE_COMMONS_PLT).$(ERL_VER) -r ./src
|
||||||
|
@ -90,5 +117,3 @@ distclean: clean
|
||||||
rm -rf $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
rm -rf $(ERLWARE_COMMONS_PLT).$(ERL_VER)
|
||||||
rm -rvf $(CURDIR)/deps
|
rm -rvf $(CURDIR)/deps
|
||||||
rm -rvf .DEV_MODE
|
rm -rvf .DEV_MODE
|
||||||
|
|
||||||
rebuild: distclean all
|
|
||||||
|
|
|
@ -49,9 +49,8 @@
|
||||||
|
|
||||||
-define(PREFIX, "===> ").
|
-define(PREFIX, "===> ").
|
||||||
|
|
||||||
-record(state_t, {mod=?MODULE :: ec_log,
|
-record(state_t, {log_level=0 :: int_log_level(),
|
||||||
log_level=0 :: int_log_level(),
|
caller=api :: caller()}).
|
||||||
caller=api :: api | command_line}).
|
|
||||||
|
|
||||||
%%============================================================================
|
%%============================================================================
|
||||||
%% types
|
%% types
|
||||||
|
@ -60,8 +59,11 @@
|
||||||
int_log_level/0,
|
int_log_level/0,
|
||||||
atom_log_level/0,
|
atom_log_level/0,
|
||||||
log_level/0,
|
log_level/0,
|
||||||
|
caller/0,
|
||||||
log_fun/0]).
|
log_fun/0]).
|
||||||
|
|
||||||
|
-type caller() :: api | command_line.
|
||||||
|
|
||||||
-type log_level() :: int_log_level() | atom_log_level().
|
-type log_level() :: int_log_level() | atom_log_level().
|
||||||
|
|
||||||
-type int_log_level() :: 0..3.
|
-type int_log_level() :: 0..3.
|
||||||
|
@ -82,8 +84,9 @@
|
||||||
new(LogLevel) ->
|
new(LogLevel) ->
|
||||||
new(LogLevel, api).
|
new(LogLevel, api).
|
||||||
|
|
||||||
|
-spec new(log_level(), caller()) -> t().
|
||||||
new(LogLevel, Caller) when LogLevel >= 0, LogLevel =< 3 ->
|
new(LogLevel, Caller) when LogLevel >= 0, LogLevel =< 3 ->
|
||||||
#state_t{mod=?MODULE, log_level=LogLevel, caller=Caller};
|
#state_t{log_level=LogLevel, caller=Caller};
|
||||||
new(AtomLogLevel, Caller)
|
new(AtomLogLevel, Caller)
|
||||||
when AtomLogLevel =:= error;
|
when AtomLogLevel =:= error;
|
||||||
AtomLogLevel =:= warn;
|
AtomLogLevel =:= warn;
|
||||||
|
@ -165,7 +168,7 @@ warn(LogState, FormatString, Args) ->
|
||||||
|
|
||||||
%% @doc Execute the fun passed in if log level is as expected.
|
%% @doc Execute the fun passed in if log level is as expected.
|
||||||
-spec log(t(), int_log_level(), log_fun()) -> ok.
|
-spec log(t(), int_log_level(), log_fun()) -> ok.
|
||||||
log(#state_t{mod=?MODULE, log_level=DetailLogLevel}, LogLevel, Fun)
|
log(#state_t{log_level=DetailLogLevel}, LogLevel, Fun)
|
||||||
when DetailLogLevel >= LogLevel ->
|
when DetailLogLevel >= LogLevel ->
|
||||||
io:format("~s~n", [Fun()]);
|
io:format("~s~n", [Fun()]);
|
||||||
log(_, _, _) ->
|
log(_, _, _) ->
|
||||||
|
@ -174,7 +177,7 @@ log(_, _, _) ->
|
||||||
%% @doc when the module log level is less then or equal to the log level for the
|
%% @doc when the module log level is less then or equal to the log level for the
|
||||||
%% call then write the log info out. When its not then ignore the call.
|
%% call then write the log info out. When its not then ignore the call.
|
||||||
-spec log(t(), int_log_level(), string(), [any()]) -> ok.
|
-spec log(t(), int_log_level(), string(), [any()]) -> ok.
|
||||||
log(#state_t{mod=?MODULE, log_level=DetailLogLevel}, LogLevel, FormatString, Args)
|
log(#state_t{log_level=DetailLogLevel}, LogLevel, FormatString, Args)
|
||||||
when DetailLogLevel >= LogLevel,
|
when DetailLogLevel >= LogLevel,
|
||||||
erlang:is_list(Args) ->
|
erlang:is_list(Args) ->
|
||||||
io:format(FormatString, Args);
|
io:format(FormatString, Args);
|
||||||
|
@ -184,7 +187,7 @@ log(_, _, _, _) ->
|
||||||
%% @doc return a boolean indicating if the system should log for the specified
|
%% @doc return a boolean indicating if the system should log for the specified
|
||||||
%% levelg
|
%% levelg
|
||||||
-spec should(t(), int_log_level() | any()) -> boolean().
|
-spec should(t(), int_log_level() | any()) -> boolean().
|
||||||
should(#state_t{mod=?MODULE, log_level=DetailLogLevel}, LogLevel)
|
should(#state_t{log_level=DetailLogLevel}, LogLevel)
|
||||||
when DetailLogLevel >= LogLevel ->
|
when DetailLogLevel >= LogLevel ->
|
||||||
true;
|
true;
|
||||||
should(_, _) ->
|
should(_, _) ->
|
||||||
|
@ -192,18 +195,18 @@ should(_, _) ->
|
||||||
|
|
||||||
%% @doc get the current log level as an integer
|
%% @doc get the current log level as an integer
|
||||||
-spec log_level(t()) -> int_log_level().
|
-spec log_level(t()) -> int_log_level().
|
||||||
log_level(#state_t{mod=?MODULE, log_level=DetailLogLevel}) ->
|
log_level(#state_t{log_level=DetailLogLevel}) ->
|
||||||
DetailLogLevel.
|
DetailLogLevel.
|
||||||
|
|
||||||
%% @doc get the current log level as an atom
|
%% @doc get the current log level as an atom
|
||||||
-spec atom_log_level(t()) -> atom_log_level().
|
-spec atom_log_level(t()) -> atom_log_level().
|
||||||
atom_log_level(#state_t{mod=?MODULE, log_level=?EC_ERROR}) ->
|
atom_log_level(#state_t{log_level=?EC_ERROR}) ->
|
||||||
error;
|
error;
|
||||||
atom_log_level(#state_t{mod=?MODULE, log_level=?EC_WARN}) ->
|
atom_log_level(#state_t{log_level=?EC_WARN}) ->
|
||||||
warn;
|
warn;
|
||||||
atom_log_level(#state_t{mod=?MODULE, log_level=?EC_INFO}) ->
|
atom_log_level(#state_t{log_level=?EC_INFO}) ->
|
||||||
info;
|
info;
|
||||||
atom_log_level(#state_t{mod=?MODULE, log_level=?EC_DEBUG}) ->
|
atom_log_level(#state_t{log_level=?EC_DEBUG}) ->
|
||||||
debug.
|
debug.
|
||||||
|
|
||||||
-spec format(t()) -> iolist().
|
-spec format(t()) -> iolist().
|
||||||
|
|
|
@ -175,7 +175,7 @@ mkdir_path(Path) ->
|
||||||
|
|
||||||
|
|
||||||
%% @doc read a file from the file system. Provide UEX exeption on failure.
|
%% @doc read a file from the file system. Provide UEX exeption on failure.
|
||||||
-spec read(FilePath::file:filename()) -> binary() | {error, Reason::term()}.
|
-spec read(FilePath::file:filename()) -> {ok, binary()} | {error, Reason::term()}.
|
||||||
read(FilePath) ->
|
read(FilePath) ->
|
||||||
%% Now that we are moving away from exceptions again this becomes
|
%% Now that we are moving away from exceptions again this becomes
|
||||||
%% a bit redundant but we want to be backwards compatible as much
|
%% a bit redundant but we want to be backwards compatible as much
|
||||||
|
@ -373,9 +373,9 @@ find_test() ->
|
||||||
{BaseDir, _SourceDir, {Name1, Name2, Name3, _NoName}} = setup_base_and_target(),
|
{BaseDir, _SourceDir, {Name1, Name2, Name3, _NoName}} = setup_base_and_target(),
|
||||||
Result = find(BaseDir, "file[a-z]+\$"),
|
Result = find(BaseDir, "file[a-z]+\$"),
|
||||||
?assertMatch(3, erlang:length(Result)),
|
?assertMatch(3, erlang:length(Result)),
|
||||||
?assert(lists:member(Name1, Result)),
|
?assertEqual(true, lists:member(Name1, Result)),
|
||||||
?assert(lists:member(Name2, Result)),
|
?assertEqual(true, lists:member(Name2, Result)),
|
||||||
?assert(lists:member(Name3, Result)),
|
?assertEqual(true, lists:member(Name3, Result)),
|
||||||
remove(BaseDir, [recursive]).
|
remove(BaseDir, [recursive]).
|
||||||
|
|
||||||
-endif.
|
-endif.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue