You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2017/10/25 19:40:32 UTC

[couchdb] branch master updated: add ability to ignore javascript test suites (#889)

This is an automated email from the ASF dual-hosted git repository.

tonysun83 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 629a3e0  add ability to ignore javascript test suites (#889)
629a3e0 is described below

commit 629a3e00efde6c7af99358c7bd0071a9764c7c1e
Author: Tony Sun <to...@gmail.com>
AuthorDate: Wed Oct 25 12:40:30 2017 -0700

    add ability to ignore javascript test suites (#889)
    
    Developers can now ignore javascript test suites with the new option
    ignore_js_suites.
    
    Example usage:
    
    make javascript ignore_js_suites="all_docs basics"
    make javascript suites="all_docs basics view_errors" ignore_js_suites=
    "view_errors"
    
    The second example is redundant but the functionality works.
---
 Makefile            |  8 ++++++--
 README-DEV.rst      | 11 +++++++++--
 test/javascript/run | 57 +++++++++++++++++++++++++++++++++++++----------------
 3 files changed, 55 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 239a2db..2c4bca5 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,8 @@ DIALYZE_OPTS=$(shell echo "\
 	skip_deps=$(skip_deps) \
 	" | sed -e 's/[a-z]\+= / /g')
 
+#ignore javascript tests
+ignore_js_suites=
 
 ################################################################################
 # Main commands
@@ -123,7 +125,8 @@ endif
 	@rm -rf dev/lib
 	@dev/run -n 1 -q --with-admin-party-please \
             -c 'startup_jitter=0' \
-            test/javascript/run $(suites)
+            'test/javascript/run --suites "$(suites)" \
+            --ignore "$(ignore_js_suites)"'
 
 .PHONY: soak-javascript
 soak-javascript:
@@ -138,7 +141,8 @@ endif
 	while [ $$? -eq 0 ]; do \
 		dev/run -n 1 -q --with-admin-party-please \
 				-c 'startup_jitter=0' \
-				test/javascript/run $(suites); \
+				'test/javascript/run --suites "$(suites)" \
+				--ignore "$(ignore_js_suites)"'  \
 	done
 
 .PHONY: check-qs
diff --git a/README-DEV.rst b/README-DEV.rst
index 613aea2..f8d80ac 100644
--- a/README-DEV.rst
+++ b/README-DEV.rst
@@ -173,8 +173,15 @@ JavaScript tests accepts only `suites` option, but in the same way::
     # Run only basic and design_options tests
     make javascript suites="basic design_options"
 
-Note that tests are delimited here by whitespace, not by comma. You can get list
-of all possible test targets with the following command::
+    # Ignore specific test suites via command line
+    make javascript ignore_js_suites="all_docs bulk_docs"
+
+    # Ignore specific test suites in makefile
+    ignore_js_suites=all_docs,bulk_docs
+
+Note that tests on the command line are delimited here by whitespace,
+not by comma.You can get list of all possible test targets with the
+following command::
 
     make list-js-suites
 
diff --git a/test/javascript/run b/test/javascript/run
index f7659b0..96b3a56 100755
--- a/test/javascript/run
+++ b/test/javascript/run
@@ -17,6 +17,7 @@ import optparse as op
 import os
 import subprocess as sp
 import sys
+import re
 
 
 USAGE = "%prog [options] [command to run...]"
@@ -100,7 +101,13 @@ def options():
                        help="Start from the given filename if multiple files "
                             "are passed"),
         op.make_option("-a", "--all", action="store_true", dest="all",
-                       help="Run all tests, even if one or more fail")
+                       help="Run all tests, even if one or more fail"),
+        op.make_option("-i", "--ignore", type="string", action="callback",
+                       default=None, callback=get_delimited_list,
+                       dest="ignore", help="Ignore test suites"),
+        op.make_option("-u", "--suites", type="string", action="callback",
+                       default=None, callback=get_delimited_list,
+                       dest="suites", help="Run specific suites")
     ]
 
 
@@ -108,23 +115,15 @@ def main():
     parser = op.OptionParser(usage=USAGE, option_list=options())
     opts, args = parser.parse_args()
 
+    run_list = []
+    ignore_list = []
     tests = []
-    if not len(args):
-        args = ["test/javascript/tests"]
-    for name in args:
-        if os.path.isdir(name):
-            tests.extend(sorted(glob.glob(os.path.join(name, "*.js"))))
-        elif os.path.isfile(name):
-            tests.append(name)
-        else:
-            pname = os.path.join("test/javascript/tests", name)
-            if os.path.isfile(pname):
-                tests.append(pname)
-            elif os.path.isfile(pname + ".js"):
-                tests.append(pname + ".js")
-            else:
-                sys.stderr.write("Unknown test: " + name + os.linesep)
-                exit(1)
+
+    run_list = ["test/javascript/tests"] if not opts.suites else opts.suites
+    run_list = build_test_case_paths(run_list)
+    ignore_list = build_test_case_paths(opts.ignore)
+    # sort is needed because certain tests fail if executed out of order
+    tests = sorted(list(set(run_list)-set(ignore_list)))
 
     if opts.start is not None:
         tmp = []
@@ -152,6 +151,30 @@ def main():
         failed, passed) + os.linesep)
     exit(failed > 0)
 
+def build_test_case_paths(args=None):
+    tests = []
+    if args is None:
+        args = []
+    for name in args:
+        if os.path.isdir(name):
+            tests.extend(sorted(glob.glob(os.path.join(name, "*.js"))))
+        elif os.path.isfile(name):
+            check = tests.append(name)
+        else:
+            pname = os.path.join("test/javascript/tests", name)
+            if os.path.isfile(pname):
+                tests.append(pname)
+            elif os.path.isfile(pname + ".js"):
+                tests.append(pname + ".js")
+            else:
+                sys.stderr.write("Unknown test: " + name + os.linesep)
+                exit(1)
+    return tests
+
+
+def get_delimited_list(option, opt, value, parser):
+    delimited = [i for i in re.split(r',|\s', value.strip()) if i]
+    setattr(parser.values, option.dest, delimited)
 
 if __name__ == "__main__":
     try:

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].