Skip to content

Commit

Permalink
Revert "Fixing bug in etap_can documentation. Adding framewerk files …
Browse files Browse the repository at this point in the history
…and components."

This reverts commit aa961b2.
  • Loading branch information
ngerakines committed Jul 29, 2009
1 parent f192c63 commit 46e2193
Show file tree
Hide file tree
Showing 47 changed files with 242 additions and 196 deletions.
3 changes: 0 additions & 3 deletions AUTHORS

This file was deleted.

32 changes: 32 additions & 0 deletions Makefile
@@ -0,0 +1,32 @@
LIBDIR=`erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell`
.PHONY: doc
VERSION=0.3.4

all:
mkdir -p ebin
(cd src;$(MAKE))

doc:
(cd src; $(MAKE) doc)

test: all
(cd t;$(MAKE))
(cd t;$(MAKE) test)

prove: all
(cd t;$(MAKE))
prove t/*.t

clean:
(cd src;$(MAKE) clean)
(cd t;$(MAKE) clean)
rm -rf cover/

package: clean
@mkdir etap-$(VERSION)/ && cp -rf ChangeLog Makefile README.markdown scripts src support t etap-$(VERSION)
@COPYFILE_DISABLE=true tar zcf etap-$(VERSION).tgz etap-$(VERSION)
@rm -rf etap-$(VERSION)/

install:
mkdir -p $(prefix)/$(LIBDIR)/etap-$(VERSION)/ebin
for i in ebin/*.beam; do install $$i $(prefix)/$(LIBDIR)/etap-$(VERSION)/$$i ; done
1 change: 0 additions & 1 deletion Makefile.am.local

This file was deleted.

17 changes: 0 additions & 17 deletions bootstrap

This file was deleted.

2 changes: 0 additions & 2 deletions configure.ac.local

This file was deleted.

1 change: 0 additions & 1 deletion fw-pkgin/Makefile.am.local

This file was deleted.

55 changes: 0 additions & 55 deletions fw-pkgin/config

This file was deleted.

9 changes: 0 additions & 9 deletions fw-pkgin/post-install

This file was deleted.

9 changes: 0 additions & 9 deletions fw-pkgin/post-remove

This file was deleted.

9 changes: 0 additions & 9 deletions fw-pkgin/pre-install

This file was deleted.

9 changes: 0 additions & 9 deletions fw-pkgin/pre-remove

This file was deleted.

10 changes: 0 additions & 10 deletions fw-pkgin/start

This file was deleted.

10 changes: 0 additions & 10 deletions fw-pkgin/stop

This file was deleted.

18 changes: 18 additions & 0 deletions scripts/collect.erl
@@ -0,0 +1,18 @@
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -noshell

%% @doc Takes the coverdata files generated by the cover module and creates
%% reports out of them. Each module analysed by the system generates an
%% X_coverage.txt file.
main(_) ->
[cover:import(File) || File <- filelib:wildcard("*.coverdata")],
lists:foreach(
fun(Module) ->
cover:analyse_to_file(
Module, atom_to_list(Mod) ++ "_coverage.txt", []
)
end,
cover:imported_modules()
).

16 changes: 16 additions & 0 deletions src/Makefile
@@ -0,0 +1,16 @@
include ../support/include.mk

all: $(EBIN_FILES)

doc:
mkdir -p $(DOC_DIR)
$(ERL) -noshell -run edoc files $(ERL_SOURCES) -run init stop
mv *.html *.png *.css $(DOC_DIR)

debug:
$(MAKE) DEBUG=-DDEBUG

clean:
rm -rf $(EBIN_FILES)
rm -rf edoc-info
rm -rf $(DOC_DIR)
14 changes: 0 additions & 14 deletions src/Makefile.am.local

This file was deleted.

11 changes: 10 additions & 1 deletion src/etap_can.erl
Expand Up @@ -59,12 +59,21 @@ has_attrib(M, A) when is_atom(M), is_atom(A) ->
lists:concat([M, " has attribute ", A]) lists:concat([M, " has attribute ", A])
). ).


is_attrib(M, A, V) when is_atom(M), is_atom(A) -> %% @spec has_attrib(M, A. V) -> true | false
%% M = atom()
%% A = atom()
%% V = any()
%% @doc Asserts that a module has a given attribute with a given value.
is_attrib(M, A, V) when is_atom(M) andalso is_atom(A) ->
etap:is( etap:is(
proplists:get_value(A, M:module_info(attributes)), proplists:get_value(A, M:module_info(attributes)),
[V], [V],
lists:concat([M, "'s ", A, " is ", V]) lists:concat([M, "'s ", A, " is ", V])
). ).


%% @spec is_behavior(M, B) -> true | false
%% M = atom()
%% B = atom()
%% @doc Asserts that a given module has a specific behavior.
is_behaviour(M, B) when is_atom(M) andalso is_atom(B) -> is_behaviour(M, B) when is_atom(M) andalso is_atom(B) ->
is_attrib(M, behaviour, B). is_attrib(M, behaviour, B).
75 changes: 75 additions & 0 deletions src/overview.edoc
@@ -0,0 +1,75 @@

@title A TAP testing client.
@author Nick Gerakines <nick@gerakines.net>
@author Jeremy Wall <jeremy@marzhillstudios.com>
@version 0.3.4
@doc A TAP testing client.

<p>etap is a collection of Erlang modules that provide a TAP testing client library. These modules allow developers to create extensive and comprehensive tests covering many aspects of application and module development. This includes simple assertions, exceptions, the application behavior and event web requests. This library was originally written by Jeremy wall.</p>
<p>As per the TAP wiki:</p>
<blockquote>TAP, the Test Anything Protocol, is a simple text-based interface between testing modules in a test harness. TAP started life as part of the test harness for Perl but now has implementations in C/C++, Python, PHP, Perl and probably others by the time you read this.</blockquote>
<p>These modules are not meant to compete with eunit, but to offer a more general testing facility that isn't provides by eunit.</p>
<pre><code>http://en.wikipedia.org/wiki/Test_Anything_Protocol
http://testanything.org/wiki/index.php/Main_Page
</code></pre>

<h1>CREATING TESTS</h1>

<p>A test is any number of etap:* or etap_*:* tests that are part of a test plan. When a plan is created using etap:plan/1, a process is started that tracks the status of the tests executed and handles diagnostic output.</p>
<p>Consider the following example test plan:</p>
<pre><code>etap:plan(3),
etap:ok(true, "the 'true' atom is recognized"),
etap:is(1 + 1, 2, "simple math"),
etap:isnt(2 + 2, 5, "some would argue"),
etap:end_tests().
</code></pre>
<p>At this time, etap does not support pattern matching. To work around this there are a number of utility tests that can be used. The etap:any/3, etap:none/3 and etap:fun_is/3 use functions to return either <code>true</code> or <code>false</code>.</p>
<pre><code>Numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9],
FunWithNumbers = fun(X) case X of [1, 2, 3 | _] -&gt; true; _ -&gt; false end end,
etap:fun_is(FunWithNumbers, Numbers, "Match the first three numbers").
</code></pre>

<p>There are many examples in t/*.erl.</p>

<h1>BUILD &amp; INSTALL</h1>

<p>To build this library, from the root directory execute the <code>make</code> command. You should also execute the <code>make test</code> command to verify that the library functions correctly on your system. If you have the Perl module TAP::Harness you can use it to collect and display test results using the <code>make prove</code> target.</p>

<pre><code>$ make
$ make test
$ make prove
</code></pre>

<p>If you choose to run the <code>make test</code> command then please be sure to <code>make clean</code> after to remove any of the temporary beam files created by the tests in the <code>t/</code> directory.</p>

<p>The included tests cover the basic functionality of the etap modules. They can also be used as a reference when writing your own tests. </p>

<p>To install etap you need to create the <code>etap/ebin/</code> directory in your current Erlang library and copy all of the .beam files created by the <code>make</code> file.</p>

<pre><code>$ sudo mkdir -p /usr/lib/erlang/lib/etap-0.3.4/ebin
$ make clean &amp;&amp; make
$ sudo cp ebin/*.beam /usr/lib/erlang/lib/etap-0.3.4/ebin/
</code></pre>

<p>The <code>make dist-src</code> target can be used to create source distributions for further packaging and deployment.</p>

<h1>SUPPORTED FUNCTIONALITY</h1>

<p>There are a number of proposals listed on the TAP wiki that are not supported by this library. Please be aware of this when creating your tests.</p>

<ul>
<li>LIMITED SUPPORTED: TAP diagnostic syntax</li>
<li>LIMITED SUPPORTED: TAP meta information</li>
<li>LIMITED SUPPORTED: TAP logging syntax</li>
<li>NOT SUPPORTED: Test groups</li>
<li>NOT SUPPORTED: Test blocks</li>
<li>LIMITED SUPPORTED: SKIP</li>
<li>NOT SUPPORTED: TODO</li>
<li>LIMITED SUPPORTED: TAP datetime</li>
</ul>

<h1>CREDITS</h1>

<p>2008 Nick Gerakines<br />
2007-2008 Jeremy Wall<br />
2008 Jacob Vorreuter</p>
38 changes: 38 additions & 0 deletions support/include.mk
@@ -0,0 +1,38 @@
## -*- makefile -*-

ERL := erl
ERLC := $(ERL)c

INCLUDE_DIRS := ../include
DOC_DIR := ../doc
EBIN_DIRS :=
ERLC_FLAGS := -W $(INCLUDE_DIRS:../%=-I ../%) $(EBIN_DIRS:%=-pa %)

ifndef no_debug_info
ERLC_FLAGS += +debug_info
endif

ifdef debug
ERLC_FLAGS += -Ddebug
endif

EBIN_DIR := ../ebin
EMULATOR := beam

ERL_SOURCES := $(wildcard *.erl)
ERL_DOCS := $(wildcard *.erl) $(wildcard *.edoc)
ERL_HEADERS := $(wildcard *.hrl) $(wildcard ../include/*.hrl)
ERL_OBJECTS := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.$(EMULATOR))
ERL_OBJECTS_LOCAL := $(ERL_SOURCES:%.erl=./%.$(EMULATOR))
APP_FILES := $(wildcard *.app)
EBIN_FILES = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app)
MODULES = $(ERL_SOURCES:%.erl=%)

../ebin/%.app: %.app
cp $< $@

$(EBIN_DIR)/%.$(EMULATOR): %.erl
$(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $<

./%.$(EMULATOR): %.erl
$(ERLC) $(ERLC_FLAGS) -o . $<
12 changes: 12 additions & 0 deletions t/Makefile
@@ -0,0 +1,12 @@
include ../support/include.mk

all: $(EBIN_FILES)

clean:
rm -rf $(EBIN_FILES) erl_crash.dump

test: $(MODULES)

./$(MODULES):
@echo "Running tests for $@"
erl -pa ../ebin -run $@ start -run init stop -noshell

0 comments on commit 46e2193

Please sign in to comment.