forked from numenta/nupic-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This requires some minor fixing-up of python namespaces to avoid namespace conflicts with pre-existing py module.
- Loading branch information
Austin Marshall
committed
Jul 24, 2013
1 parent
349a4d5
commit 7cb1470
Showing
40 changed files
with
144 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/usr/bin/env python | ||
# ---------------------------------------------------------------------- | ||
# Numenta Platform for Intelligent Computing (NuPIC) | ||
# Copyright (C) 2013, Numenta, Inc. Unless you have purchased from | ||
# Numenta, Inc. a separate commercial license for this software code, the | ||
# following terms and conditions apply: | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see http://www.gnu.org/licenses. | ||
# | ||
# http://numenta.org/licenses/ | ||
# ---------------------------------------------------------------------- | ||
import os | ||
import sys | ||
|
||
from optparse import OptionParser | ||
|
||
import pytest | ||
|
||
def collect(option, opt_str, value, parser): | ||
""" Collect multiple option values into a single list. Used in conjunction | ||
with callback argument to OptionParser.add_option(). | ||
""" | ||
|
||
assert value is None | ||
value = set([]) | ||
|
||
for arg in parser.rargs: | ||
if arg[:1] == "-": | ||
break | ||
value.add(arg) | ||
|
||
del parser.rargs[:len(value)] | ||
setattr(parser.values, option.dest, value) | ||
|
||
|
||
parser = OptionParser(usage="%prog [options]\n\n" \ | ||
"Run Grok Engine tests.") | ||
parser.add_option("-a", "--all", | ||
action="store_true", | ||
default=False, | ||
dest="all") | ||
parser.add_option("-c", "--coverage", | ||
action="store_true", | ||
default=False, | ||
dest="coverage") | ||
parser.add_option("-i", "--integration", | ||
action="store_true", | ||
default=False, | ||
dest="integration") | ||
parser.add_option("-n", "--num", | ||
dest="processes") | ||
parser.add_option("-r", "--results", | ||
dest="results", | ||
nargs=2) | ||
parser.add_option("-s", | ||
dest="tests", | ||
action="callback", | ||
callback=collect) | ||
parser.add_option("-u", "--unit", | ||
action="store_true", | ||
default=False, | ||
dest="unit") | ||
parser.add_option("-x", "--failfast", | ||
action="store_true", | ||
default=False, | ||
dest="failfast") | ||
|
||
|
||
def main(parser, parse_args): | ||
""" Parse CLI options and execute tests """ | ||
|
||
# Extensions to test spec (args not part of official test runner) | ||
|
||
parser.add_option("-v", "--verbose", | ||
action="store_true", | ||
dest="verbose") | ||
|
||
# Parse CLI args | ||
|
||
(options, tests) = parser.parse_args(args=parse_args) | ||
|
||
tests = set(tests) | ||
|
||
# Translate spec args to py.test args | ||
|
||
args = ["--boxed"] | ||
|
||
root = "tests" | ||
|
||
if options.coverage: | ||
args.append("--cov=nupic") | ||
|
||
if options.processes is not None: | ||
args.extend(["-n", options.processes]) | ||
|
||
if options.results is not None: | ||
(format, runid) = options.results | ||
|
||
results = os.path.join(root, "results", "py2", "xunit", str(runid)) | ||
|
||
try: | ||
os.makedirs(results) | ||
except os.error: | ||
pass | ||
|
||
args.append("--junitxml=" + os.path.join(results, "results.xml")) | ||
|
||
if options.tests is not None: | ||
tests.update(options.tests) | ||
|
||
if options.unit or options.all: | ||
tests.add(os.path.join(root, "unit", "py2")) | ||
|
||
if options.verbose: | ||
args.append("-v") | ||
|
||
if options.failfast: | ||
args.append("-x") | ||
|
||
if not tests or options.all: | ||
tests.add(os.path.join(root, "external", "py2")) | ||
tests.add(os.path.join(root, "unit", "py2")) | ||
|
||
|
||
# Run tests | ||
|
||
pytest.main(args + list(tests)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(parser, sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,2 @@ | ||
#!/bin/bash | ||
|
||
ROOTDIR=`dirname $0` | ||
TESTS="tests/external/py tests/unit/py" | ||
COVERAGE="" | ||
while true; do | ||
case $1 in | ||
-c) COVERAGE="--with-coverage --cover-package=nupic" ;; | ||
-u) TESTS="tests/unit/" ;; | ||
-r) case "$2" in | ||
xunit) | ||
case "$3" in | ||
-*) RUNID=`date +"%Y%m%d%H%M%S"` ;; | ||
"") RUNID=`date +"%Y%m%d%H%M%S"` ;; | ||
*) RUNID=$3 ; shift ; | ||
esac | ||
RESULTS="tests/results/py/xunit/${RUNID}" | ||
mkdir -p $RESULTS | ||
XUNIT="--with-xunit --xunit-file=$RESULTS/nosetests.xml" ;; | ||
stdout) XUNIT="" ;; | ||
--) break ;; | ||
esac | ||
shift ;; | ||
# Individual tests/modules | ||
-e) ENGINE_TESTS="true" ; | ||
TESTS=`cat tests/engine_aws_cluster_tests.testlist` ; | ||
case "$2" in | ||
-*) ;; | ||
"") ;; | ||
*.testlist) TESTS=`cat $2`; shift ;; | ||
*) TESTS=$2 ; shift ;; | ||
esac ;; | ||
-*) break ;; | ||
*) break ;; | ||
--) break ;; | ||
esac | ||
shift | ||
done | ||
shift | ||
|
||
run_engine_tests() { | ||
for TEST in $TESTS; do | ||
if [[ -n $XUNIT ]]; then | ||
XUNIT_NAME=`echo $TEST | sed "s/\//_/g"` | ||
XUNIT="--with-xunit --xunit-file=$RESULTS/$XUNIT_NAME.xml" | ||
fi | ||
echo "Running" `basename $TEST` 1>&2 | ||
nosetests -v --nologcapture $XUNIT $TEST $@ | ||
done | ||
} | ||
|
||
if [[ -n $ENGINE_TESTS ]]; then | ||
run_engine_tests $@ | ||
else | ||
nosetests -v --exe $COVERAGE $XUNIT $TESTS $@ | ||
fi | ||
|
||
|
||
#!/bin/sh | ||
python run_tests.py $@ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.