Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5029911C8E for ; Fri, 29 Aug 2014 20:33:42 +0000 (UTC) Received: (qmail 54420 invoked by uid 500); 29 Aug 2014 20:33:41 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 54301 invoked by uid 500); 29 Aug 2014 20:33:41 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 53078 invoked by uid 99); 29 Aug 2014 20:33:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2014 20:33:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 125049A8C8B; Fri, 29 Aug 2014 20:33:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chewbranca@apache.org To: commits@couchdb.apache.org Date: Fri, 29 Aug 2014 20:34:06 -0000 Message-Id: <391b73c5b7f446779e4540c441dc8b38@git.apache.org> In-Reply-To: <033924478b034d6c896f3621cbc55070@git.apache.org> References: <033924478b034d6c896f3621cbc55070@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [27/30] couchdb commit: updated refs/heads/1963-eunit-bigcouch to d1a82df 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/e3ebbb5c Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e3ebbb5c Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e3ebbb5c Branch: refs/heads/1963-eunit-bigcouch Commit: e3ebbb5c5e562bbb13bc4f18315064d0456fed8e Parents: aa9f32d Author: Russell Branca Authored: Fri Aug 29 12:32:52 2014 -0700 Committer: Russell Branca Committed: Fri Aug 29 13:33:05 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/e3ebbb5c/.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/e3ebbb5c/Makefile ---------------------------------------------------------------------- diff --git a/Makefile b/Makefile index ea1aba8..3ef0f0b 100644 --- a/Makefile +++ b/Makefile @@ -58,4 +58,5 @@ docker: @docker build --no-cache --rm -t couchdb/dev-cluster . eunit: + @rebar setup_eunit @rebar eunit skip_deps=meck,mochiweb,lager http://git-wip-us.apache.org/repos/asf/couchdb/blob/e3ebbb5c/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/e3ebbb5c/rebar.config.script ---------------------------------------------------------------------- diff --git a/rebar.config.script b/rebar.config.script index 3dab22f..18e4993 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -64,6 +64,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/e3ebbb5c/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/e3ebbb5c/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/e3ebbb5c/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"}.