[Yt-svn] yt: Adding entry point for enzo_test, updating output_tests and ...

hg at spacepope.org hg at spacepope.org
Tue Jul 6 11:19:43 PDT 2010


hg Repository: yt
details:   yt/rev/f2b189060bf0
changeset: 1872:f2b189060bf0
user:      Matthew Turk <matthewturk at gmail.com>
date:
Tue Jul 06 11:19:35 2010 -0700
description:
Adding entry point for enzo_test, updating output_tests and runner to include
entry point for test runner and module importer

diffstat:

 setup.py                                |   1 +
 yt/extensions/enzo_test/__init__.py     |   5 +++--
 yt/extensions/enzo_test/output_tests.py |   8 +++++++-
 yt/extensions/enzo_test/runner.py       |  36 +++++++++++++++++++++---------------
 4 files changed, 32 insertions(+), 18 deletions(-)

diffs (105 lines):

diff -r d860925c4eea -r f2b189060bf0 setup.py
--- a/setup.py	Tue Jul 06 10:43:07 2010 -0700
+++ b/setup.py	Tue Jul 06 11:19:35 2010 -0700
@@ -58,6 +58,7 @@
                            'pdf' : ['pypdf']},
         entry_points = { 'console_scripts' : [
                             'yt = yt.command_line:run_main',
+                            'enzo_test = yt.extensions.enzo_test:run_main',
                        ]},
         author="Matthew J. Turk",
         author_email="matthewturk at gmail.com",
diff -r d860925c4eea -r f2b189060bf0 yt/extensions/enzo_test/__init__.py
--- a/yt/extensions/enzo_test/__init__.py	Tue Jul 06 10:43:07 2010 -0700
+++ b/yt/extensions/enzo_test/__init__.py	Tue Jul 06 11:19:35 2010 -0700
@@ -23,7 +23,8 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
+import runner, output_tests
+from runner import RegressionTestRunner, run_main
+
 from output_tests import RegressionTest, SingleOutputTest, \
     MultipleOutputTest, YTStaticOutputTest, create_test
-
-from runner import RegressionTestRunner, run
diff -r d860925c4eea -r f2b189060bf0 yt/extensions/enzo_test/output_tests.py
--- a/yt/extensions/enzo_test/output_tests.py	Tue Jul 06 10:43:07 2010 -0700
+++ b/yt/extensions/enzo_test/output_tests.py	Tue Jul 06 11:19:35 2010 -0700
@@ -2,7 +2,13 @@
 
 # We first create our dictionary of tests to run.  This starts out empty, and
 # as tests are imported it will be filled.
-test_registry = {}
+class TestRegistry(dict):
+    def __new__(cls, *p, **k):
+        if not '_the_instance' in cls.__dict__:
+            cls._the_instance = dict.__new__(cls)
+            return cls._the_instance
+    
+test_registry = TestRegistry()
 
 # The exceptions we raise, related to the character of the failure.
 
diff -r d860925c4eea -r f2b189060bf0 yt/extensions/enzo_test/runner.py
--- a/yt/extensions/enzo_test/runner.py	Tue Jul 06 10:43:07 2010 -0700
+++ b/yt/extensions/enzo_test/runner.py	Tue Jul 06 11:19:35 2010 -0700
@@ -100,37 +100,43 @@
             print "Running '%s'" % (test_name)
             self.run_test(line.strip())
 
-def run():
-    # This should be made to work with the optparse library
-    if sys.argv[-1] == "-f":
-        first_runner = RegressionTestRunner("first")
-        first_runner.run_all_tests()
-    else:
-        second_runner = RegressionTestRunner("second", "first")
-        second_runner.run_all_tests()
-
 class EnzoTestRunnerCommands(cmdln.Cmdln):
     name = "enzo_tests"
 
-    def do_store(self, subcmd, opts, name):
+    def do_store(self, subcmd, opts, name, *test_modules):
         """
-        Run and store a new dataset.
+        ${cmd_name}: Run and store a new dataset.
 
+        ${cmd_usage}
         ${cmd_option_list}
         """
+        sys.path.insert(0, ".")
+        for fn in test_modules:
+            if fn.endswith(".py"): fn = fn[:-3]
+            print "Loading module %s" % (fn)
+            __import__(fn)
         test_runner = RegressionTestRunner(name)
         test_runner.run_all_tests()
 
-    def do_compare(self, subcmd, opts, reference, comparison):
+    def do_compare(self, subcmd, opts, reference, comparison, *test_modules):
         """
-        Compare a reference dataset against a new dataset.  The new dataset
-        will be run regardless of whether it exists or not.
+        ${cmd_name}: Compare a reference dataset against a new dataset.  The
+        new dataset will be run regardless of whether it exists or not.
 
+        ${cmd_usage}
         ${cmd_option_list}
         """
+        sys.path.insert(0, ".")
+        for fn in test_filenames:
+            if fn.endswith(".py"): fn = fn[:-3]
+            print "Loading module %s" % (fn)
+            __import__(fn)
         test_runner = RegressionTestRunner(comparison, reference)
         test_runner.run_all_tests()
 
-if __name__ == "__main__":
+def run_main():
     etrc = EnzoTestRunnerCommands()
     sys.exit(etrc.main())
+
+if __name__ == "__main__":
+    run_main()



More information about the yt-svn mailing list