Gary Oberbrunner avatar Gary Oberbrunner committed ad575cb Merge

Merged in techtonik/scons (pull request #63: Another minor cleanup as the code study goes on)

Comments (0)

Files changed (13)

QMTest/TestCmd.py

 
 re_space = re.compile('\s')
 
-_Cleanup = []
-
-def _clean():
-    global _Cleanup
-    cleanlist = [ c for c in _Cleanup if c ]
-    del _Cleanup[:]
-    cleanlist.reverse()
-    for test in cleanlist:
-        test.cleanup()
-
-atexit.register(_clean)
-
 def _caller(tblist, skip):
     string = ""
     arr = []
             raise Exception(disconnect_message)
         data = memoryview(data)[sent:]
 
+_Cleanup = []
+
+def _clean():
+    global _Cleanup
+    cleanlist = [ c for c in _Cleanup if c ]
+    del _Cleanup[:]
+    cleanlist.reverse()
+    for test in cleanlist:
+        test.cleanup()
+
+atexit.register(_clean)
 
 
 class TestCmd(object):
                 shutil.rmtree(dir, ignore_errors = 1)
             self._dirlist = []
 
-        try:
             global _Cleanup
-            _Cleanup.remove(self)
-        except (AttributeError, ValueError):
-            pass
+            if self in _Cleanup:
+                _Cleanup.remove(self)
 
     def command_args(self, program = None,
                            interpreter = None,
 
         #
         self._dirlist.append(path)
+
         global _Cleanup
-        try:
-            _Cleanup.index(self)
-        except ValueError:
+        if self not in _Cleanup:
             _Cleanup.append(self)
 
         return path
                             'LICENSE.txt',
                             'README.txt',
                             'RELEASE.txt',
-                            'os_spawnv_fix.diff',
                             'scons.1',
                             'sconsign.1',
                             'scons-time.1',
         if len(args) > 1:
             print arg + ':'
 
-        command = [sys.executable, 'runtest.py', '--noqmtest']
+        command = [sys.executable, 'runtest.py']
         if opts.package:
             command.extend(['-p', opts.package])
         command.append(arg)

bin/scons-test.py

 # so that problems on different platforms can be identified sooner.
 #
 
+import atexit
 import getopt
 import imp
 import os
         import shutil
         os.chdir(startdir)
         shutil.rmtree(tempdir)
-    sys.exitfunc = cleanup
+    atexit.register(cleanup)
 
 # Fetch the input file if it happens to be across a network somewhere.
 # Ohmigod, does Python make this simple...
       * replaced `-o FILE --xml` combination with `--xml FILE`
       * changed `-o, --output FILE` option to capture stdout/stderr output
         from runtest.py
+    - Remove os_spawnv_fix.diff patch required to enable parallel builds
+      support prior to Python 2.2
 
   From Juan Lang:
     - Fix WiX Tool to use .wixobj rather than .wxiobj for compiler output

src/engine/SCons/cppTests.py

 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import atexit
 import sys
 import unittest
 
         if os.path.exists(dir):
             shutil.rmtree(dir)
 
-sys.exitfunc = _clean
+atexit.register(_clean)
 
 class fileTestCase(unittest.TestCase):
     cpp_class = cpp.DumbPreProcessor

src/engine/SCons/exitfuncs.py

 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 
+import atexit
 
 _exithandlers = []
 def _run_exitfuncs():
     """
     _exithandlers.append((func, targs, kargs))
 
-import sys
 
-try:
-    x = sys.exitfunc
-
-    # if x isn't our own exit func executive, assume it's another
-    # registered exit function - append it to our list...
-    if x != _run_exitfuncs:
-        register(x)
-
-except AttributeError:
-    pass
-
-# make our exit function get run by python when it exits:    
-sys.exitfunc = _run_exitfuncs
-
-del sys
+# make our exit function get run by python when it exits
+atexit.register(_run_exitfuncs)
 
 # Local Variables:
 # tab-width:4

src/os_spawnv_fix.diff

-? dist/src/Mac/IDE scripts/Hold option to open a script
-? dist/src/Mac/IDE scripts/Insert file name
-? dist/src/Mac/IDE scripts/Insert folder name
-? dist/src/Mac/IDE scripts/Search Python Documentation
-? dist/src/Mac/IDE scripts/Hack/Remove .pyc files
-? dist/src/Mac/IDE scripts/Hack/Toolbox Assistant
-Index: dist/src/Modules/posixmodule.c
-===================================================================
-RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
-retrieving revision 2.213
-diff -c -c -r2.213 posixmodule.c
-*** dist/src/Modules/posixmodule.c	2001/12/03 20:41:00	2.213
---- dist/src/Modules/posixmodule.c	2001/12/05 00:52:58
-***************
-*** 1668,1674 ****
-  #ifdef HAVE_SPAWNV
-  static char posix_spawnv__doc__[] =
-  "spawnv(mode, path, args)\n\
-! Execute an executable path with arguments, replacing current process.\n\
-  \n\
-  	mode: mode of process creation\n\
-  	path: path of executable file\n\
---- 1668,1674 ----
-  #ifdef HAVE_SPAWNV
-  static char posix_spawnv__doc__[] =
-  "spawnv(mode, path, args)\n\
-! Execute the program 'path' in a new process.\n\
-  \n\
-  	mode: mode of process creation\n\
-  	path: path of executable file\n\
-***************
-*** 1717,1724 ****
-  
-  	if (mode == _OLD_P_OVERLAY)
-  		mode = _P_OVERLAY;
-  	spawnval = _spawnv(mode, path, argvlist);
-! 
-  	PyMem_DEL(argvlist);
-  
-  	if (spawnval == -1)
---- 1717,1727 ----
-  
-  	if (mode == _OLD_P_OVERLAY)
-  		mode = _P_OVERLAY;
-+ 	
-+ 	Py_BEGIN_ALLOW_THREADS
-  	spawnval = _spawnv(mode, path, argvlist);
-! 	Py_END_ALLOW_THREADS
-! 	
-  	PyMem_DEL(argvlist);
-  
-  	if (spawnval == -1)
-***************
-*** 1734,1740 ****
-  
-  static char posix_spawnve__doc__[] =
-  "spawnve(mode, path, args, env)\n\
-! Execute a path with arguments and environment, replacing current process.\n\
-  \n\
-  	mode: mode of process creation\n\
-  	path: path of executable file\n\
---- 1737,1743 ----
-  
-  static char posix_spawnve__doc__[] =
-  "spawnve(mode, path, args, env)\n\
-! Execute the program 'path' in a new process.\n\
-  \n\
-  	mode: mode of process creation\n\
-  	path: path of executable file\n\
-***************
-*** 1830,1836 ****
---- 1833,1843 ----
-  
-  	if (mode == _OLD_P_OVERLAY)
-  		mode = _P_OVERLAY;
-+ 
-+ 	Py_BEGIN_ALLOW_THREADS
-  	spawnval = _spawnve(mode, path, argvlist, envlist);
-+ 	Py_END_ALLOW_THREADS
-+ 
-  	if (spawnval == -1)
-  		(void) posix_error();
-  	else

src/test_strings.py

             'engine/SCons/Conftest.py',
             'engine/SCons/dblite.py',
             'MANIFEST',
-            'os_spawnv_fix.diff',
             'setup.cfg',
         ],
         # We run epydoc on the *.py files, which generates *.pyc files.
             'QMTest/TestCmdTests.py',
             'QMTest/TestCommon.py',
             'QMTest/TestCommonTests.py',
-            'src/os_spawnv_fix.diff',
             'src/MANIFEST.in',
             'src/setup.cfg',
             'src/engine/MANIFEST.in',

test/GetBuildFailures/parallel.py

     for bf in sorted(GetBuildFailures(), key=lambda t: t.filename):
         print "%%s failed:  %%s" %% (bf.node, bf.errstr)
 
-try:
-    import atexit
-except ImportError:
-    import sys
-    sys.exitfunc = print_build_failures
-else:
-    atexit.register(print_build_failures)
+import atexit
+atexit.register(print_build_failures)
 """ % locals())
 
 test.write('f3.in', "f3.in\n")

test/GetBuildFailures/serial.py

         if bf.command:
             print "BF:    %%s" %% " ".join(Flatten(bf.command))
 
-try:
-    import atexit
-except ImportError:
-    import sys
-    sys.exitfunc = print_build_failures
-else:
-    atexit.register(print_build_failures)
+import atexit
+atexit.register(print_build_failures)
 """ % locals())
 
 test.write('f03.in', "f03.in\n")

test/runtest/noqmtest.py

 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 """
-Test that the --noqmtest option invokes tests directly via Python, not
+Test that by default tests are invoked directly via Python, not
 using qmtest.
 """
 
     test_pass_py,
 ]
 
-test.run(arguments = '-k --noqmtest %s' % ' '.join(testlist),
+test.run(arguments = '-k %s' % ' '.join(testlist),
          status = 1,
          stdout = expect_stdout,
          stderr = expect_stderr)

test/runtest/xml/output.py

 
 test.write_passing_test(['test', 'pass.py'])
 
-test.run(arguments = '-o xml.out --xml test', status=1)
+test.run(arguments = '--xml xml.out test', status=1)
 
 expect = """\
   <results>
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.