Skip to content

Commit

Permalink
Rebar support.
Browse files Browse the repository at this point in the history
Relatively untested...
  • Loading branch information
oscarh committed Aug 22, 2010
1 parent 1cd58a6 commit d34fc40
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 138 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ util/*.beam
cover_report/
test/*.beam
test/*.log

.eunit

*.swp
*.swo
71 changes: 10 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,69 +1,18 @@
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))
REBAR := ./rebar

comma := ,
e :=
space := $(e) $(e)
MODULELIST := $(subst $(space),$(comma),$(MODULES))
.PHONY: all clean test dialyzer

TEST_SOURCES := $(wildcard test/*.erl)
TEST_BEAMS := $(patsubst %.erl,%.beam, $(TEST_SOURCES))
all:
$(REBAR) compile

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
@echo Generating $@
@sed -e 's/{modules, \[\]}/{modules, \[$(MODULELIST)\]}/' $< > $@

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/

doc: doc/edoc-info
test:
$(REBAR) eunit

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

doc/edoc-info: doc/overview.edoc $(SOURCES)
@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
$(REBAR) analyze

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
$(REBAR) clean

release: clean all test dialyzer
@util/releaser $(APPLICATION) $(VSN)
release: all dialyzer test
$(REBAR) release
Binary file added rebar
Binary file not shown.
1 change: 1 addition & 0 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{cover_enabled, true}.
4 changes: 1 addition & 3 deletions test/lhttpc_manager_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
%%% Eunit setup stuff

start_app() ->
ok = application:start(crypto),
application:start(public_key),
ok = application:start(ssl),
ok = application:start(lhttpc).

stop_app(_) ->
ok = application:stop(lhttpc),
ok = application:stop(ssl),
ok = application:stop(crypto).
ok = application:stop(ssl).

manager_test_() ->
{inorder,
Expand Down
141 changes: 70 additions & 71 deletions test/lhttpc_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,77 +37,76 @@
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
).

test_no(N, Tests) ->
setelement(2, Tests,
setelement(4, element(2, Tests),
lists:nth(N, element(4, element(2, Tests))))).

%%% Eunit setup stuff

start_app() ->
ok = application:start(crypto),
application:start(public_key),
ok = application:start(ssl),
ok = lhttpc:start().

stop_app(_) ->
ok = lhttpc:stop(),
ok = application:stop(ssl),
ok = application:stop(crypto).
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
"This is a relatively long body, that we send to the client... "
).

test_no(N, Tests) ->
setelement(2, Tests,
setelement(4, element(2, Tests),
lists:nth(N, element(4, element(2, Tests))))).

%%% Eunit setup stuff

start_app() ->
application:start(crypto),
application:start(public_key),
ok = application:start(ssl),
ok = lhttpc:start().

stop_app(_) ->
ok = lhttpc:stop(),
ok = application:stop(ssl).

tcp_test_() ->
{inorder,
Expand Down
4 changes: 2 additions & 2 deletions test/webserver.erl
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ listen(ssl) ->
{active, false},
{ip, {127,0,0,1}},
{verify,0},
{keyfile, "test/key.pem"},
{certfile, "test/crt.pem"}
{keyfile, "../test/key.pem"},
{certfile, "../test/crt.pem"}
],
{ok, LS} = ssl:listen(0, Opts),
LS;
Expand Down
1 change: 0 additions & 1 deletion vsn.mk

This file was deleted.

0 comments on commit d34fc40

Please sign in to comment.