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 1B45B1144C for ; Tue, 3 Jun 2014 04:50:21 +0000 (UTC) Received: (qmail 27855 invoked by uid 500); 3 Jun 2014 04:50:20 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 27778 invoked by uid 500); 3 Jun 2014 04:50:20 -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 27768 invoked by uid 99); 3 Jun 2014 04:50:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jun 2014 04:50:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 724B092C7E6; Tue, 3 Jun 2014 04:50:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kxepal@apache.org To: commits@couchdb.apache.org Date: Tue, 03 Jun 2014 04:50:20 -0000 Message-Id: <15df0753d95844c7aa5e7990c1d98bb9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/31] couchdb commit: updated refs/heads/1963-eunit to 16528f8 Repository: couchdb Updated Branches: refs/heads/1963-eunit [created] 16528f8d5 Add run script to execute eunit tests Usage is the same as for test/etap/run: ./test/couchdb/run -v ${PATH} -v runs in verbose mode, as etap does. Also, you can use make for that: make check-eunit which will run tests everywhere in project where Makefile contains check-eunit subcommand definition. The ${PATH} thing could be single file or directory. The latter should contains *_tests.erl files which would be compiled and executed by eunit. The *_tests.erl The reason of compiling on run instead of using autoconf for that is to simplify tests developing and avoid situations, when you'd fixed the test or add new one, but forgot to remove/compile beam file. All test_*.beam files are been stored in test/couchdb/ebin directory, the temporary test files will be places to test/couchdb/temp one. Both directories will be removed by make clean/distclean command. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5d73db9a Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5d73db9a Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5d73db9a Branch: refs/heads/1963-eunit Commit: 5d73db9a3ca1f1125c1a890d893354ef8c197d43 Parents: ad8e28c Author: Alexander Shorin Authored: Fri May 16 00:08:36 2014 +0400 Committer: Alexander Shorin Committed: Tue Jun 3 02:16:34 2014 +0400 ---------------------------------------------------------------------- .gitignore | 2 +- Makefile.am | 5 +++ configure.ac | 2 + license.skip | 2 + test/Makefile.am | 2 +- test/couchdb/Makefile.am | 24 ++++++++++ test/couchdb/run.in | 102 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 137 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d73db9a/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 4b12bf7..85e2365 100644 --- a/.gitignore +++ b/.gitignore @@ -128,9 +128,9 @@ src/snappy/snappy.app stamp-h1 test/.deps/ test/bench/run +test/couchdb/run test/etap/.deps/ test/etap/run -test/etap/run test/etap/temp.* test/etap/test_cfg_register test/etap/test_util.erl http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d73db9a/Makefile.am ---------------------------------------------------------------------- diff --git a/Makefile.am b/Makefile.am index 22809f8..413c1a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,6 +92,11 @@ if TESTS $(top_builddir)/test/etap/run $(top_srcdir)/test/etap endif +check-eunit: dev +if TESTS + $(top_builddir)/test/couchdb/run -v $(top_srcdir)/test/couchdb +endif + cover: dev if TESTS rm -f cover/*.coverdata http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d73db9a/configure.ac ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index 01d0a7b..4b34811 100644 --- a/configure.ac +++ b/configure.ac @@ -753,6 +753,8 @@ AC_CONFIG_FILES([src/snappy/google-snappy/snappy-stubs-public.h]) AC_CONFIG_FILES([src/ejson/Makefile]) AC_CONFIG_FILES([test/Makefile]) AC_CONFIG_FILES([test/bench/Makefile]) +AC_CONFIG_FILES([test/couchdb/run]) +AC_CONFIG_FILES([test/couchdb/Makefile]) AC_CONFIG_FILES([test/etap/Makefile]) AC_CONFIG_FILES([test/etap/test_util.erl]) AC_CONFIG_FILES([test/javascript/Makefile]) http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d73db9a/license.skip ---------------------------------------------------------------------- diff --git a/license.skip b/license.skip index f5e49da..5d10e6c 100644 --- a/license.skip +++ b/license.skip @@ -168,6 +168,8 @@ ^test/Makefile.in ^test/bench/Makefile ^test/bench/Makefile.in +^test/couchdb/Makefile +^test/couchdb/Makefile.in ^test/etap/.*.beam ^test/etap/.*.o ^test/etap/.deps/.* http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d73db9a/test/Makefile.am ---------------------------------------------------------------------- diff --git a/test/Makefile.am b/test/Makefile.am index 7c70a5a..1237c6f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,6 +10,6 @@ ## License for the specific language governing permissions and limitations under ## the License. -SUBDIRS = bench etap javascript view_server +SUBDIRS = bench couchdb etap javascript view_server EXTRA_DIST = random_port.ini http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d73db9a/test/couchdb/Makefile.am ---------------------------------------------------------------------- diff --git a/test/couchdb/Makefile.am b/test/couchdb/Makefile.am new file mode 100644 index 0000000..5bd65dd --- /dev/null +++ b/test/couchdb/Makefile.am @@ -0,0 +1,24 @@ +## 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. + +noinst_SCRIPTS = run + +all: + mkdir -p {ebin,temp} + chmod +x run + +EXTRA_DIST = \ + run.in + +clean-local: + rm -rf ebin + rm -rf temp http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d73db9a/test/couchdb/run.in ---------------------------------------------------------------------- diff --git a/test/couchdb/run.in b/test/couchdb/run.in new file mode 100644 index 0000000..80f4041 --- /dev/null +++ b/test/couchdb/run.in @@ -0,0 +1,102 @@ +#!/usr/bin/env escript +%% -*- erlang -*- +%%! -DTEST -pa @abs_top_builddir@/test/couchdb/ebin +%% +%% 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. + +-define(BUILDDIR, "@abs_top_builddir@"). +-define(TESTS_EBIN, filename:join([?BUILDDIR, "test", "couchdb", "ebin"])). +-define(TESTS_TEMP, filename:join([?BUILDDIR, "test", "couchdb", "temp"])). + +main([]) -> + io:fwrite("Path to test file or directory wasn't specified.~n"), + erlang:halt(1); +main(["-v"]) -> + io:fwrite("Path to test file or directory wasn't specified.~n"), + erlang:halt(1); +main(["-v", Path]) -> + run(Path, [verbose]); +main(["-v", _ | _]) -> + io:fwrite("Only single tests source path is supported.~n"), + erlang:halt(1); +main([Path]) -> + run(Path, []), + ok; +main([_|_]) -> + io:fwrite("Only single tests source path is supported.~n"), + erlang:halt(1). + + +run(Path, Options) -> + Mask = "*_tests.erl", + Files = list_files(Path, Mask), + Mods = compile(Files), + run_tests(Mods, Options). + + +list_files(Path, Mask)-> + AbsPath = filename:absname(Path), + case filelib:is_file(AbsPath) of + true -> + ok; + false -> + io:fwrite("File or directory not found: ~p~n", [AbsPath]), + erlang:halt(1) + end, + case filelib:is_dir(AbsPath) of + true -> + case filelib:wildcard(filename:join([AbsPath, Mask])) of + [] -> + io:fwrite("No test files was found at ~p by mask ~p ~n", + [AbsPath, Mask]), + erlang:halt(1); + Files -> + Files + end; + false -> [AbsPath] + end. + + +compile(Files) -> + ok = filelib:ensure_dir(?TESTS_EBIN), + lists:map( + fun(File)-> + io:fwrite("compile ~p~n", [File]), + {ok, Mod} = compile:file(File, + [report, verbose, {outdir, ?TESTS_EBIN}]), + Mod + end, + Files). + + +run_tests(Mods, Options) -> + init_code_path(), + ok = filelib:ensure_dir(?TESTS_TEMP), + case eunit:test(Mods, Options) of + error -> erlang:halt(1); + _ -> ok + end. + + +init_code_path() -> + Paths = [ + "couchdb", + "ejson", + "erlang-oauth", + "ibrowse", + "mochiweb", + "snappy" + ], + lists:foreach(fun(Name) -> + code:add_patha(filename:join([?BUILDDIR, "src", Name])) + end, Paths).