Commit 150d4c45 by Chris Jerdonek

The pystache-tests script now accepts a spec test directory argument.

parent ae755339
...@@ -32,10 +32,17 @@ def run_tests(sys_argv): ...@@ -32,10 +32,17 @@ def run_tests(sys_argv):
try: try:
# TODO: use optparse command options instead. # TODO: use optparse command options instead.
project_dir = sys_argv[1] project_dir = sys_argv[1]
sys_argv.pop() sys_argv.pop(1)
except IndexError: except IndexError:
project_dir = PROJECT_DIR project_dir = PROJECT_DIR
try:
# TODO: use optparse command options instead.
spec_test_dir = sys_argv[1]
sys_argv.pop(1)
except IndexError:
spec_test_dir = SPEC_TEST_DIR
if len(sys_argv) <= 1 or sys_argv[-1].startswith("-"): if len(sys_argv) <= 1 or sys_argv[-1].startswith("-"):
# Then no explicit module or test names were provided, so # Then no explicit module or test names were provided, so
# auto-detect all unit tests. # auto-detect all unit tests.
...@@ -43,7 +50,7 @@ def run_tests(sys_argv): ...@@ -43,7 +50,7 @@ def run_tests(sys_argv):
sys_argv.extend(module_names) sys_argv.extend(module_names)
_PystacheTestProgram._text_doctest_dir = project_dir _PystacheTestProgram._text_doctest_dir = project_dir
_PystacheTestProgram._spec_test_dir = SPEC_TEST_DIR _PystacheTestProgram._spec_test_dir = spec_test_dir
# We pass None for the module because we do not want the unittest # We pass None for the module because we do not want the unittest
# module to resolve module names relative to a given module. # module to resolve module names relative to a given module.
......
...@@ -77,14 +77,18 @@ def get_spec_tests(spec_test_dir): ...@@ -77,14 +77,18 @@ def get_spec_tests(spec_test_dir):
case = _deserialize_spec_test(data, path) case = _deserialize_spec_test(data, path)
cases.append(case) cases.append(case)
# Store this as a value so that CheckSpecTestsFound is not checking
# a reference to cases that contains itself.
spec_test_count = len(cases)
# This test case lets us alert the user that spec tests are missing. # This test case lets us alert the user that spec tests are missing.
class CheckSpecTestsFound(unittest.TestCase): class CheckSpecTestsFound(unittest.TestCase):
def runTest(self): def runTest(self):
if len(cases) > 0: if spec_test_count > 0:
return return
raise Exception("Spec tests not found in: %s\n " raise Exception("Spec tests not found--\n in %s\n"
"Consult the README file on how to add the Mustache spec tests." % repr(spec_test_dir)) " Consult the README file on how to add the Mustache spec tests." % repr(spec_test_dir))
case = CheckSpecTestsFound() case = CheckSpecTestsFound()
cases.append(case) cases.append(case)
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
envlist = py24,py25,py26,py27,py31,py32 envlist = py24,py25,py26,py27,py31,py32
[testenv] [testenv]
# Change the working directory so that we don't import the pystache located
# in the original location.
changedir = changedir =
{envbindir} {envbindir}
commands = commands =
pystache-test {toxinidir} pystache-test {toxinidir} {toxinidir}/ext/spec/specs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment