diff options
author | Russell Branca <chewbranca@apache.org> | 2014-08-29 12:32:52 -0700 |
---|---|---|
committer | Russell Branca <chewbranca@apache.org> | 2014-08-29 13:35:00 -0700 |
commit | 0955cc946d064772aa4c0148bd28519c01dd0631 (patch) | |
tree | d42c77de076e64c1820d47ebc8e5d1dfd3d4f63b | |
parent | 8c24cd199c7d05dfc020130ca1f1d28b8fb52dce (diff) | |
download | couchdb-0955cc946d064772aa4c0148bd28519c01dd0631.tar.gz |
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.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | NOTICE | 4 | ||||
-rw-r--r-- | rebar.config.script | 1 | ||||
-rw-r--r-- | rel/overlay/etc/eunit.ini | 28 | ||||
-rw-r--r-- | rel/plugins/eunit_plugin.erl | 39 | ||||
-rw-r--r-- | setup_eunit.template | 18 |
7 files changed, 92 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index ad9479d23..d56dc6b9d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ rel/dev* rel/tmpdata src/ /log +tmp/ *.o *.so @@ -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: @@ -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 diff --git a/rebar.config.script b/rebar.config.script index d58d85f2e..e0277a472 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"}]} ], diff --git a/rel/overlay/etc/eunit.ini b/rel/overlay/etc/eunit.ini new file mode 100644 index 000000000..50024a375 --- /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 diff --git a/rel/plugins/eunit_plugin.erl b/rel/plugins/eunit_plugin.erl new file mode 100644 index 000000000..bbf83d2ec --- /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). diff --git a/setup_eunit.template b/setup_eunit.template new file mode 100644 index 000000000..13659705e --- /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"}. |