Anonymous avatar Anonymous committed afca2ed

Added in a few tests for run_tests_sub.py in run_tests__test.py

Comments (0)

Files changed (4)

 # Defaults:
 #    See optparse options below for more options
 #
-ALWAYS_SUBPROCESS = 0
 
 # If an xxxx_test.py takes longer than TIME_OUT seconds it will be killed
 # This is only the default, can be over-ridden on command line
 # Set the command line options
 #
 
-opt_parser = optparse.OptionParser()
+USEAGE = """
+
+Runs all the test/xxxx_test.py tests.
+
+"""
+
+opt_parser = optparse.OptionParser(USEAGE)
 opt_parser.add_option(
      "-v",  "--verbose", action = 'store_true',
      help   = "be verbose in output (only single process mode)" )
      help   = "fail incomplete tests (only single process mode)" )
 
 opt_parser.add_option (
-     "-s",  "--subprocess", action = 'store_true', default = ALWAYS_SUBPROCESS,
-     help   = "run tests in subprocesses" )
+     "-s",  "--subprocess", action = 'store_true',
+     help   = "run test suites in subprocesses (default: same process)" )
 
 opt_parser.add_option (
      "-m",  "--multi_thread", metavar = 'THREADS', type = 'int',

test/run_tests__tests/all_ok/fake_1_test.py

-import unittest
-
-class KeyModuleTest(unittest.TestCase):
-    def test_get_focused(self):
-        self.assert_(True) 
-
-    def test_get_mods(self):
-        self.assert_(True) 
-
-    def test_get_pressed(self):
-        self.assert_(True) 
-
-    def test_name(self):
-        self.assert_(True) 
-
-    def test_set_mods(self):
-        self.assert_(True) 
-
-    def test_set_repeat(self):
-        self.assert_(True) 
-
-if __name__ == '__main__':
-    unittest.main()

test/run_tests__tests/all_ok/zero_tests_test.py

+import unittest
+
+class KeyModuleTest(unittest.TestCase):
+    pass
+
+if __name__ == '__main__':
+    unittest.main()

test/run_tests__tests/run_tests__test.py

+import subprocess, os, sys, re
+
+MERGE_PROGRAM = ""
+INTERACTIVE = 0
+
+IGNORE =  (
+    '.svn',
+    'infinite_loop',
+)
+
+NORMALIZERS = (
+    ("Ran (\d+) tests in (\d+\.\d+)s", "Ran XXX tests in X.XXXs" ),
+)
+
+main_dir = os.path.split(os.path.abspath(sys.argv[0]))[0]
+trunk_dir = os.path.normpath(os.path.join(main_dir, '../../'))
+
+single_cmd = "%s run_tests_sub.py -f %s" 
+subprocess_cmd = single_cmd + ' -s'
+
+test_suite_dirs = [x for x in os.listdir(main_dir) if os.path.isdir(x)
+                                                  and x not in IGNORE ]
+
+def norm_result(result):
+    """
+    
+    normalize differences, such as timing between output
+    
+    """
+
+    for normalizer, replacement in NORMALIZERS:
+        result = re.sub(normalizer, replacement, result)
+
+    return result
+
+def call_proc(cmd):
+    proc = subprocess.Popen (
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell = 1,
+    )
+    assert not proc.wait()
+    return proc.stdout.read()
+
+os.chdir(trunk_dir)
+for suite in test_suite_dirs:
+    single = call_proc(single_cmd % (sys.executable, suite))[1]
+    subs = call_proc(subprocess_cmd % (sys.executable, suite))[1]
+    
+    if norm_result(single) != norm_result(subs):
+        if INTERACTIVE:
+            pass ## open in MERGE_PROGRAM
+        else:
+            raise Exception("not matching")
+
+print 'OK'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.