Skip to content

Commit

Permalink
improve rebar support and fix tests on erlang R14a
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Jul 14, 2010
1 parent 1d908aa commit ca2d9d5
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -8,3 +8,6 @@ util/*.beam
cover_report/
test/*.beam
test/*.log
test_ebin/
logs/
*.swp
6 changes: 6 additions & 0 deletions Emakefile
@@ -0,0 +1,6 @@
% -*- mode: erlang -*-
{["src/*"],
[{i, "include"},
{outdir, "ebin"},
debug_info]
}.
77 changes: 23 additions & 54 deletions Makefile
@@ -1,69 +1,38 @@
APPLICATION := lhttpc
APP_FILE := ebin/$(APPLICATION).app
SOURCES := $(wildcard src/*.erl)
HEADERS := $(wildcard src/*.hrl)
MODULES := $(patsubst src/%.erl,%,$(SOURCES))
BEAMS := $(patsubst %,ebin/%.beam,$(MODULES))

comma := ,
e :=
space := $(e) $(e)
MODULELIST := $(subst $(space),$(comma),$(MODULES))

TEST_SOURCES := $(wildcard test/*.erl)
TEST_BEAMS := $(patsubst %.erl,%.beam, $(TEST_SOURCES))
ERL ?= erl
ERLC ?= erlc
APP := lhttpc

include vsn.mk

.PHONY: all clean dialyzer

all: $(APPLICATION) doc

$(APPLICATION): $(BEAMS) $(APP_FILE)

test: $(APPLICATION) $(TEST_BEAMS) util/run_test.beam
@echo Running tests
@erl -pa util/ -pa ebin/ -pa test/ -noinput -s run_test run

test_shell: $(APPLICATION) $(TEST_BEAMS)
@echo Starting a shell with test paths included
@erl -pa ebin/ -pa test/

test/%.beam: test/%.erl
@echo Compiling $<
@erlc +debug_info -o test/ $<

$(APP_FILE): src/$(APPLICATION).app.src vsn.mk
@echo Generating $@
@sed -e 's/@MODULES@/$(MODULELIST)/' -e 's/@VSN@/$(VSN)/' $< > $@
all: doc
@(./rebar compile)

ebin/%.beam: src/%.erl $(HEADERS) $(filter-out $(wildcard ebin), ebin)
@echo Compiling $<
@erlc +debug_info +warn_missing_spec -o ebin/ $<

ebin:
@echo Creating ebin/
@mkdir ebin/
clean:
@(./rebar clean)
@rm -f test/*.beam doc/*.{html,css,png} doc/edoc-info
@rm -rf cover_report
@rm -f util/*.beam
@rm -rf tests_ebin


doc: doc/edoc-info

dialyzer:
@echo Running dialyzer on sources
@dialyzer --src -r src/

doc/edoc-info: doc/overview.edoc $(SOURCES)
@erlc -o util/ util/make_doc.erl
doc/edoc-info:
@$(ERLC) -o util/ util/make_doc.erl
@echo Generating documentation from edoc
@erl -pa util/ -noinput -s make_doc edoc

util/%.beam: util/%.erl
@erlc -o util/ util/run_test.erl
@$(ERL) -pa util/ -noinput -s make_doc edoc

clean:
@echo Cleaning
@rm -f ebin/*.{beam,app} test/*.beam doc/*.{html,css,png} doc/edoc-info
@rm -rf cover_report
@rm -f util/*.beam
test: all
@$(ERLC) -o util/ util/run_test.erl
@echo Running tests
@mkdir -p test_ebin
@cd test;$(ERL) -make
@$(ERL) -noshell -pa util/ -pa ebin -pa test_ebin -noinput -s run_test run

release: clean all test dialyzer
@util/releaser $(APPLICATION) $(VSN)
@util/releaser $(APP) $(VSN)

2 changes: 1 addition & 1 deletion ebin/lhttpc.app
Expand Up @@ -29,7 +29,7 @@
%%% @end
{application, lhttpc,
[{description, "Lightweight HTTP Client"},
{vsn, "1.2.4"},
{vsn, "1.2.5"},
{modules, [
lhttpc_client,
lhttpc,
Expand Down
Binary file modified rebar
Binary file not shown.
5 changes: 5 additions & 0 deletions rebar.config
@@ -0,0 +1,5 @@
%%-*- mode: erlang -*-
{fail_on_warning, true}.
{cover_enabled, true}.
{erl_opts, [debug_info]}.

4 changes: 4 additions & 0 deletions test/Emakefile
@@ -0,0 +1,4 @@
{"*", [warn_obsolete_guard, warn_unused_import,
warn_shadow_vars, warn_export_vars, debug_info,
{i, "../include"},
{outdir, "../test_ebin"}]}.
5 changes: 5 additions & 0 deletions test/lhttpc_manager_tests.erl
Expand Up @@ -36,7 +36,12 @@
%%% Eunit setup stuff

start_app() ->

ok = application:start(crypto),
case application:start(public_key) of
ok -> ok;
{error, _} -> ok
end,
ok = application:start(ssl),
ok = application:start(lhttpc).

Expand Down
6 changes: 6 additions & 0 deletions test/lhttpc_tests.erl
Expand Up @@ -99,7 +99,13 @@ test_no(N, Tests) ->
%%% Eunit setup stuff

start_app() ->

ok = application:start(crypto),
case application:start(public_key) of
{error, _} -> ok;
_ -> ok

end,
ok = application:start(ssl),
ok = lhttpc:start().

Expand Down

0 comments on commit ca2d9d5

Please sign in to comment.