You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/09/05 23:11:26 UTC
[02/12] couchdb commit: updated refs/heads/master to a5ceb62
Add setup_eunit rebar command
This adds a rebar plugin that introduces the setup_eunit function to
bootstrap the test ini files necessary to run the eunit test suite. It
grabs the ini template files from rel/overlay/*.ini primarily to be
able to set an absolute path for data directories and the prefix based
on the location of the CouchDB source directory.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0955cc94
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0955cc94
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0955cc94
Branch: refs/heads/master
Commit: 0955cc946d064772aa4c0148bd28519c01dd0631
Parents: 8c24cd1
Author: Russell Branca <ch...@apache.org>
Authored: Fri Aug 29 12:32:52 2014 -0700
Committer: Russell Branca <ch...@apache.org>
Committed: Fri Aug 29 13:35:00 2014 -0700
----------------------------------------------------------------------
.gitignore | 1 +
Makefile | 1 +
NOTICE | 4 ++++
rebar.config.script | 1 +
rel/overlay/etc/eunit.ini | 28 ++++++++++++++++++++++++++++
rel/plugins/eunit_plugin.erl | 39 +++++++++++++++++++++++++++++++++++++++
setup_eunit.template | 18 ++++++++++++++++++
7 files changed, 92 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0955cc94/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index ad9479d..d56dc6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ rel/dev*
rel/tmpdata
src/
/log
+tmp/
*.o
*.so
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0955cc94/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index b323d58..8a32d4e 100644
--- a/Makefile
+++ b/Makefile
@@ -58,6 +58,7 @@ docker:
@docker build --no-cache --rm -t couchdb/dev-cluster .
eunit:
+ @rebar setup_eunit
@rebar eunit skip_deps=meck,mochiweb,lager
javascript:
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0955cc94/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 41c1807..fe5a4ea 100644
--- a/NOTICE
+++ b/NOTICE
@@ -193,3 +193,7 @@ This product also includes the following third-party components:
* velocity.js (https://github.com/julianshapiro/velocity)
Copyright (c) 2014 Julian Shapiro
+
+* is_base_dir function in eunit_plugin.erl (https://github.com/ChicagoBoss/ChicagoBoss/blob/master/skel/priv/rebar/boss_plugin.erl)
+
+ Copyright (c) 2009-2011 Evan Miller
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0955cc94/rebar.config.script
----------------------------------------------------------------------
diff --git a/rebar.config.script b/rebar.config.script
index d58d85f..e0277a4 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -65,6 +65,7 @@ AddConfig = [
{sub_dirs, ["rel"]},
{lib_dirs, ["src/"]},
{erl_opts, [debug_info]},
+ {plugins, [eunit_plugin]},
{post_hooks, [{compile, "escript support/build_js.escript"}]}
],
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0955cc94/rel/overlay/etc/eunit.ini
----------------------------------------------------------------------
diff --git a/rel/overlay/etc/eunit.ini b/rel/overlay/etc/eunit.ini
new file mode 100644
index 0000000..50024a3
--- /dev/null
+++ b/rel/overlay/etc/eunit.ini
@@ -0,0 +1,28 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements. See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership. The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied. See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+[couchdb]
+; time to relax!
+uuid = 74696d6520746f2072656c617821
+
+[httpd]
+port = 0
+
+[log]
+; logging is disabled to remove unwanted noise in stdout from tests processing
+level = none
+include_sasl = false
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0955cc94/rel/plugins/eunit_plugin.erl
----------------------------------------------------------------------
diff --git a/rel/plugins/eunit_plugin.erl b/rel/plugins/eunit_plugin.erl
new file mode 100644
index 0000000..bbf83d2
--- /dev/null
+++ b/rel/plugins/eunit_plugin.erl
@@ -0,0 +1,39 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(eunit_plugin).
+
+
+-export([setup_eunit/2]).
+
+
+setup_eunit(Config, AppFile) ->
+ case is_base_dir(Config) of
+ false -> ok;
+ true -> build_eunit_config(Config, AppFile)
+ end.
+
+
+%% from https://github.com/ChicagoBoss/ChicagoBoss/blob/master/skel/priv/rebar/boss_plugin.erl
+is_base_dir(RebarConf) ->
+ filename:absname(rebar_utils:get_cwd()) =:= rebar_config:get_xconf(RebarConf, base_dir, undefined).
+
+
+build_eunit_config(Config0, AppFile) ->
+ Cwd = filename:absname(rebar_utils:get_cwd()),
+ DataDir = Cwd ++ "/tmp/data",
+ ViewIndexDir = Cwd ++ "/tmp/data",
+ Config1 = rebar_config:set_global(Config0, template, "setup_eunit"),
+ Config2 = rebar_config:set_global(Config1, prefix, Cwd),
+ Config3 = rebar_config:set_global(Config2, data_dir, DataDir),
+ Config = rebar_config:set_global(Config3, view_index_dir, ViewIndexDir),
+ rebar_templater:create(Config, AppFile).
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0955cc94/setup_eunit.template
----------------------------------------------------------------------
diff --git a/setup_eunit.template b/setup_eunit.template
new file mode 100644
index 0000000..1365970
--- /dev/null
+++ b/setup_eunit.template
@@ -0,0 +1,18 @@
+{variables, [
+ {package_author_name, "The Apache Software Foundation"},
+ {cluster_port, 5984},
+ {backend_port, 5986},
+ {node_name, "-name couchdbtest@127.0.0.1"},
+
+ {data_dir, "/tmp"},
+ {prefix, "/tmp"},
+ {view_index_dir, "/tmp"}
+]}.
+{dir, "tmp"}.
+{dir, "tmp/etc"}.
+{dir, "tmp/data"}.
+{dir, "tmp/tmp_data"}.
+{template, "rel/overlay/etc/default.ini", "tmp/etc/default_eunit.ini"}.
+{template, "rel/overlay/etc/local.ini", "tmp/etc/local_eunit.ini"}.
+{template, "rel/overlay/etc/eunit.ini", "tmp/etc/eunit.ini"}.
+{template, "rel/overlay/etc/vm.args", "tmp/etc/vm.args"}.