diff options
| author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2014-02-06 16:10:32 -0600 |
|---|---|---|
| committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2014-02-06 16:10:32 -0600 |
| commit | 3e09a9acb8cee93378c7241fd0d3fadcf99258a5 (patch) | |
| tree | 49e443002ad80db3e496ba7544faacc5b713b158 /test/javascript/run | |
| parent | b69f33f20baf74187d75d347b4b33c2240474147 (diff) | |
| download | couchdb-3e09a9acb8cee93378c7241fd0d3fadcf99258a5.tar.gz | |
Initial implementation of a new JS test runner
This fits into the dev/run format for allowing tests to run with an
available cluster. For now the JS tests only run against the backdoor
port.
Diffstat (limited to 'test/javascript/run')
| -rwxr-xr-x | test/javascript/run | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/test/javascript/run b/test/javascript/run new file mode 100755 index 000000000..8b754fb49 --- /dev/null +++ b/test/javascript/run @@ -0,0 +1,103 @@ +#!/usr/bin/env python +# +# 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. + +import atexit +import contextlib as ctx +import glob +import optparse as op +import os +import re +import select +import subprocess as sp +import sys +import time +import urllib + + +USAGE = "%prog [options] [command to run...]" +TEST_PATH = os.path.dirname(os.path.abspath(__file__)) +ROOT_PATH = os.path.dirname(os.path.dirname(TEST_PATH)) +N = 3 + +COUCHJS = "src/couch/priv/couchjs" + +SCRIPTS = """ + share/www/script/json2.js + share/www/script/sha1.js + share/www/script/oauth.js + share/www/script/couch.js + share/www/script/couch_test_runner.js + test/javascript/couch_http.js + test/javascript/test_setup.js +""".split() + +RUNNER = "test/javascript/cli_runner.js" + + +def run_couchjs(test): + sys.stderr.write(test + " ... ") + sys.stderr.flush() + cmd = [COUCHJS, "-H"] + SCRIPTS + [test, RUNNER] + p = sp.Popen( + cmd, + stdin = sp.PIPE, + stdout = sp.PIPE, + stderr = sys.stderr + ) + for line in p.stdout: + if line.strip() == "restart": + print "restart_nodes()" + else: + sys.stderr.write(line) + p.wait() + if p.returncode == 0: + sys.stderr.write("OK" + os.linesep) + else: + sys.stderr.write("FAIL" + os.linesep) + sys.stderr.flush() + + +def options(): + return [] + + +def main(): + parser = op.OptionParser(usage=USAGE, option_list=options()) + opts, args = parser.parse_args() + + tests = [] + if not len(args): + args = ["share/www/script/test"] + for name in args: + if os.path.isdir(name): + tests.extend(glob.glob(os.path.join(name, "*.js"))) + elif os.path.isfile(name): + tests.append(name) + else: + name = os.path.join("share/www/script/test", name) + if os.path.isfile(name): + tests.append(name) + elif os.path.isfile(name + ".js"): + tests.append(name + ".js") + + for test in tests: + run_couchjs(test) + + + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + pass |
