Init.
authorStanislaw Klekot <dozzie@jarowit.net>
Sun, 14 Jun 2015 16:22:45 +0000 (18:22 +0200)
committerStanislaw Klekot <dozzie@jarowit.net>
Sun, 14 Jun 2015 16:22:45 +0000 (18:22 +0200)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
bin/estap [new file with mode: 0755]
rebar.config [new file with mode: 0644]
src/estap.app.src [new file with mode: 0644]
src/estap.erl [new file with mode: 0644]
src/estap_app.erl [new file with mode: 0644]
src/estap_server.erl [new file with mode: 0644]
src/estap_sup.erl [new file with mode: 0644]
src/overview.edoc [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..78ec35f
--- /dev/null
@@ -0,0 +1,7 @@
+.*.swp
+*.beam
+/ebin/*.app
+/doc/edoc-info
+/doc/*.png
+/doc/*.html
+/doc/*.css
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..0a5c004
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,35 @@
+#!/usr/bin/make
+
+#-----------------------------------------------------------------------------
+
+#DIALYZER_PLT = ~/.dialyzer_plt
+DIALYZER_OPTS = --no_check_plt $(foreach D,$(DIALYZER_PLT),--plt $D)
+
+DIAGRAMS = $(basename $(notdir $(wildcard diagrams/*.diag)))
+DIAGRAMS_SVG = $(foreach D,$(DIAGRAMS),doc/images/$D.svg)
+
+#-----------------------------------------------------------------------------
+
+.PHONY: all doc edoc diagrams compile build dialyzer
+
+all: compile doc
+
+doc edoc: diagrams
+       rebar doc
+
+compile build:
+       rebar compile
+
+diagrams: $(DIAGRAMS_SVG)
+
+doc/images/%.svg: diagrams/%.diag
+       blockdiag -o $@ -T svg $<
+
+YECC_ERL_FILES = $(subst .yrl,.erl,$(subst .xrl,.erl,$(wildcard src/*.[xy]rl)))
+ERL_SOURCE_FILES = $(filter-out $(YECC_ERL_FILES),$(wildcard src/*.erl))
+dialyzer:
+       @echo "dialyzer $(strip $(DIALYZER_OPTS)) --src src/*.erl"
+       @dialyzer $(strip $(DIALYZER_OPTS)) --src $(ERL_SOURCE_FILES)
+
+#-----------------------------------------------------------------------------
+# vim:ft=make
diff --git a/bin/estap b/bin/estap
new file mode 100755 (executable)
index 0000000..115f7cb
--- /dev/null
+++ b/bin/estap
@@ -0,0 +1,14 @@
+#!/usr/bin/escript
+%%
+%%----------------------------------------------------------------------------
+
+main([]) -> main(["--help"]);
+main(["-h"]) -> main(["--help"]);
+main(["--help"]) ->
+  io:fwrite("Usage: ~s filename~n", [escript:script_name()]);
+
+main([File]) ->
+  'TODO'.
+
+%%----------------------------------------------------------------------------
+%% vim:ft=erlang
diff --git a/rebar.config b/rebar.config
new file mode 100644 (file)
index 0000000..e96e851
--- /dev/null
@@ -0,0 +1,6 @@
+{erl_opts, [debug_info]}.
+{edoc_opts, [
+  {overview, "src/overview.edoc"},
+  {source_path, ["src", "examples"]},
+  todo
+]}.
diff --git a/src/estap.app.src b/src/estap.app.src
new file mode 100644 (file)
index 0000000..e5d2754
--- /dev/null
@@ -0,0 +1,8 @@
+{application, estap, [
+  {description, ""},
+  {vsn, "0.0.0"},
+  {registered, []},
+  {applications, [kernel, stdlib]},
+  {mod, {estap_app, []}},
+  {env, []}
+]}.
diff --git a/src/estap.erl b/src/estap.erl
new file mode 100644 (file)
index 0000000..ace5b8b
--- /dev/null
@@ -0,0 +1,85 @@
+%%%---------------------------------------------------------------------------
+%%% @doc
+%%%   Functions to use in test cases.
+%%% @end
+%%%---------------------------------------------------------------------------
+
+-module(estap).
+
+%% public interface
+-export([ok/2, is/3, isnt/3, eq/3, ne/3, cmp/4, like/3, unlike/3, matches/3]).
+
+-export_type([value/0, cmp/0, regexp/0, match_fun/0]).
+
+%%%---------------------------------------------------------------------------
+%%% types {{{
+
+-type value() :: term().
+
+-type cmp() :: '<' | '>' | '=<' | '>=' | '/=' | '=/=' | '==' | '=:='.
+
+-type regexp() :: iolist().
+
+-type match_fun() :: fun((value()) -> any()).
+
+%%% }}}
+%%%---------------------------------------------------------------------------
+%%% public interface
+%%%---------------------------------------------------------------------------
+
+-spec ok(value(), iolist()) ->
+  'TODO'.
+
+ok(_Value, _Description) ->
+  'TODO'.
+
+-spec is(value(), value(), iolist()) ->
+  'TODO'.
+
+is(_Value, _Expected, _Description) ->
+  'TODO'.
+
+-spec isnt(value(), value(), iolist()) ->
+  'TODO'.
+
+isnt(_Value, _Expected, _Description) ->
+  'TODO'.
+
+-spec eq(value(), value(), iolist()) ->
+  'TODO'.
+
+eq(Value, Expected, Description) ->
+  cmp(Value, '=:=', Expected, Description).
+
+-spec ne(value(), value(), iolist()) ->
+  'TODO'.
+
+ne(Value, Expected, Description) ->
+  cmp(Value, '=/=', Expected, Description).
+
+-spec cmp(value(), cmp(), value(), iolist()) ->
+  'TODO'.
+
+cmp(_Value, _Cmp, _Expected, _Description) ->
+  'TODO'.
+
+-spec like(value(), regexp(), iolist()) ->
+  'TODO'.
+
+like(_Value, _Expected, _Description) ->
+  'TODO'.
+
+-spec unlike(value(), regexp(), iolist()) ->
+  'TODO'.
+
+unlike(_Value, _Expected, _Description) ->
+  'TODO'.
+
+-spec matches(value(), match_fun(), iolist()) ->
+  'TODO'.
+
+matches(_Value, _MatchSpec, _Description) ->
+  'TODO'.
+
+%%%---------------------------------------------------------------------------
+%%% vim:ft=erlang:foldmethod=marker
diff --git a/src/estap_app.erl b/src/estap_app.erl
new file mode 100644 (file)
index 0000000..b27cf30
--- /dev/null
@@ -0,0 +1,32 @@
+%%%---------------------------------------------------------------------------
+%%% @private
+%%% @doc
+%%%   Application entry point.
+%%% @end
+%%%---------------------------------------------------------------------------
+
+-module(estap_app).
+
+-behaviour(application).
+
+%% application callbacks
+-export([start/2, stop/1]).
+
+%%%---------------------------------------------------------------------------
+%%% application callbacks
+%%%---------------------------------------------------------------------------
+
+%% @private
+%% @doc Start the application
+
+start(_StartType, _StartArgs) ->
+  estap_sup:start_link().
+
+%% @private
+%% @doc Terminate the application
+
+stop(_State) ->
+  ok.
+
+%%%---------------------------------------------------------------------------
+%%% vim:ft=erlang:foldmethod=marker
diff --git a/src/estap_server.erl b/src/estap_server.erl
new file mode 100644 (file)
index 0000000..185c06c
--- /dev/null
@@ -0,0 +1,106 @@
+%%%---------------------------------------------------------------------------
+%%% @doc
+%%%   Input/output and test plan tracking process.
+%%% @end
+%%%---------------------------------------------------------------------------
+
+-module(estap_server).
+
+-behaviour(gen_server).
+
+%% public interface
+-export([]).
+
+%% supervision tree API
+-export([start/0, start_link/0]).
+
+%% gen_server callbacks
+-export([init/1, terminate/2]).
+-export([handle_call/3, handle_cast/2, handle_info/2]).
+-export([code_change/3]).
+
+%%%---------------------------------------------------------------------------
+
+-record(state, {
+}).
+
+%%%---------------------------------------------------------------------------
+%%% public interface
+%%%---------------------------------------------------------------------------
+
+%%%---------------------------------------------------------------------------
+%%% supervision tree API
+%%%---------------------------------------------------------------------------
+
+%% @private
+%% @doc Start the process.
+
+start() ->
+  gen_server:start({local, ?MODULE}, ?MODULE, [], []).
+
+%% @private
+%% @doc Start the process.
+
+start_link() ->
+  gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+%%%---------------------------------------------------------------------------
+%%% gen_server callbacks
+%%%---------------------------------------------------------------------------
+
+%%----------------------------------------------------------
+%% initialization/termination {{{
+
+%% @private
+%% @doc Initialize event handler.
+
+init(_Args) ->
+  State = #state{},
+  {ok, State}.
+
+%% @private
+%% @doc Clean up after event handler.
+
+terminate(_Arg, _State) ->
+  ok.
+
+%% }}}
+%%----------------------------------------------------------
+%% communication {{{
+
+%% @private
+%% @doc Handle {@link gen_server:call/2}.
+
+%% unknown calls
+handle_call(_Request, _From, State) ->
+  {reply, {error, unknown_call}, State}.
+
+%% @private
+%% @doc Handle {@link gen_server:cast/2}.
+
+%% unknown casts
+handle_cast(_Request, State) ->
+  {noreply, State}.
+
+%% @private
+%% @doc Handle incoming messages.
+
+%% unknown messages
+handle_info(_Message, State) ->
+  {noreply, State}.
+
+%% }}}
+%%----------------------------------------------------------
+%% code change {{{
+
+%% @private
+%% @doc Handle code change.
+
+code_change(_OldVsn, State, _Extra) ->
+  {ok, State}.
+
+%% }}}
+%%----------------------------------------------------------
+
+%%%---------------------------------------------------------------------------
+%%% vim:ft=erlang:foldmethod=marker
diff --git a/src/estap_sup.erl b/src/estap_sup.erl
new file mode 100644 (file)
index 0000000..a8109f4
--- /dev/null
@@ -0,0 +1,44 @@
+%%%---------------------------------------------------------------------------
+%%% @doc
+%%%   estap top-level supervisor.
+%%% @end
+%%%---------------------------------------------------------------------------
+
+-module(estap_sup).
+
+-behaviour(supervisor).
+
+%% supervision tree API
+-export([start_link/0]).
+
+%% supervisor callbacks
+-export([init/1]).
+
+%%%---------------------------------------------------------------------------
+%%% supervision tree API
+%%%---------------------------------------------------------------------------
+
+%% @private
+%% @doc Start the supervisor process.
+
+start_link() ->
+  supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%%%---------------------------------------------------------------------------
+%%% supervisor callbacks
+%%%---------------------------------------------------------------------------
+
+%% @private
+%% @doc Initialize supervisor.
+
+init([] = _Args) ->
+  Strategy = {one_for_one, 5, 10},
+  Children = [
+    {estap_server,
+      {estap_server, start_link, []},
+      permanent, 5000, worker, [estap_server]}
+  ],
+  {ok, {Strategy, Children}}.
+
+%%%---------------------------------------------------------------------------
+%%% vim:ft=erlang:foldmethod=marker
diff --git a/src/overview.edoc b/src/overview.edoc
new file mode 100644 (file)
index 0000000..5b0c3d7
--- /dev/null
@@ -0,0 +1,18 @@
+@author Stanislaw Klekot <dozzie@jarowit.net>
+@title escript TAP producer
+@version 0.0.0
+@doc
+
+TAP producer for Erlang, running from command line.
+
+Goal of estap is to allow to write tests for Erlang application in similar
+manner as it is established in Perl world: `*.t' files in a directory, the
+files being executable and producing
+<a href="http://testanything.org/">TAP</a> output, thus being appropriate for
+TAP consumers like `prove' command.
+
+== Usage ==
+
+<b>TODO</b>
+
+<!-- vim:set ft=edoc: -->