[py-svn] r37502 - in py/trunk/py: doc test test/rsession test/rsession/testing

hpk at codespeak.net hpk at codespeak.net
Sun Jan 28 22:54:14 CET 2007


Author: hpk
Date: Sun Jan 28 22:54:12 2007
New Revision: 37502

Modified:
   py/trunk/py/doc/test.txt
   py/trunk/py/test/config.py
   py/trunk/py/test/rsession/hostmanage.py
   py/trunk/py/test/rsession/rsession.py
   py/trunk/py/test/rsession/testing/test_rsession.py
Log:
unify dist_* options and give dist_rsync_roots more precision:
you now specify relative paths (relative to the conftest.py 
where a dist_rsync_root setting resides) or absolute paths. 



Modified: py/trunk/py/doc/test.txt
==============================================================================
--- py/trunk/py/doc/test.txt	(original)
+++ py/trunk/py/doc/test.txt	Sun Jan 28 22:54:12 2007
@@ -691,9 +691,8 @@
 
 The options that you need to specify in that conftest.py file are:
 
-* **`dist_hosts`**: a required list of ssh addresses (which each may
-  include a path, default path is: ``$HOME/pytestcache-HOSTNAME``)
-* `dist_rsyncroots` - a list of packages to copy to the remote machines.
+* `dist_hosts`: a required list of host specifications
+* `dist_rsync_roots` - a list of relative locations to copy to the remote machines.
 * `dist_remotepython` - the remote python executable to run.
 * `dist_nicelevel` - process priority of remote nodes. 
 * `dist_boxing` - will run each single test in a separate process 
@@ -703,7 +702,7 @@
 Sample configuration::
 
     dist_hosts = ['localhost', 'user at someserver:/tmp/somedir']
-    dist_rsyncroots = ['pypy', 'py']
+    dist_rsyncroots = ['../pypy', '../py']
     dist_remotepython = 'python2.4'
     dist_nicelevel = 10 
     dist_boxing = True

Modified: py/trunk/py/test/config.py
==============================================================================
--- py/trunk/py/test/config.py	(original)
+++ py/trunk/py/test/config.py	Sun Jan 28 22:54:12 2007
@@ -118,13 +118,6 @@
         except KeyError:
             return self.conftest.rget(name, path)
 
-    def getvalue_and_confpath(self, name, path=None):
-        """ same as previous, but returns conftest's path
-        as well
-        """
-        val, mod = self.conftest.rget_with_confmod(name, path)
-        return val, py.path.local(mod.__file__).dirpath()
-
     def initsession(self):
         """ return an initialized session object. """
         cls = self._getsessionclass()

Modified: py/trunk/py/test/rsession/hostmanage.py
==============================================================================
--- py/trunk/py/test/rsession/hostmanage.py	(original)
+++ py/trunk/py/test/rsession/hostmanage.py	Sun Jan 28 22:54:12 2007
@@ -51,10 +51,10 @@
         dir, base = os.path.split(path)
         if base == '.svn':
             return False
-        if self.rsync_roots is None or dir != self.sourcedir:
+        if dir != self.sourcedir: 
             return True
         else:
-            return base in self.rsync_roots
+            return self.rsync_roots is None or path in self.rsync_roots
 
 class DummyGateway(object):
     pass

Modified: py/trunk/py/test/rsession/rsession.py
==============================================================================
--- py/trunk/py/test/rsession/rsession.py	(original)
+++ py/trunk/py/test/rsession/rsession.py	Sun Jan 28 22:54:12 2007
@@ -133,17 +133,17 @@
         super(RSession, self).fixoptions()
         config = self.config
         try:
-            config.getvalue('disthosts')
+            config.getvalue('dist_hosts')
         except KeyError:
-            print "You're trying to run RSession without disthosts specified"
-            print "you need to specify it in your conftest.py (ie. ~/conftest.py)"
+            print "For running ad-hoc distributed tests you need to specify"
+            print "dist_hosts in a local conftest.py file, for example:"
             print "for example:"
-            print "   disthosts = ['localhost'] * 4 # for 3 processors"
-            print "      - or -"
-            print "   disthosts = ['you at some.remote.com'] # for remote testing"
-            print "   # with your remote ssh account"
-            print "http://codespeak.net/py/current/doc/test.html#automated-distributed-testing"
-            print "   for more info..."
+            print
+            print "  dist_hosts = ['localhost'] * 4 # for 3 processors"
+            print "  dist_hosts = ['you at remote.com', '...'] # for testing on ssh accounts"
+            print "   # with your remote ssh accounts"
+            print 
+            print "see also: http://codespeak.net/py/current/doc/test.html#automated-distributed-testing"
             raise SystemExit
     
     def main(self, reporter=None):
@@ -195,11 +195,22 @@
         """ Read from conftest file the configuration of distributed testing
         """
         try:
-            rsync_roots = self.config.getvalue("distrsync_roots")
-        except:
-            rsync_roots = None    # all files and directories in the pkgdir
+            conftest = self.config.conftest
+            value, mod = conftest.rget_with_confmod('dist_rsync_roots')
+        except KeyError:
+            rsync_roots = [self.config.topdir] # our best guess likely
+        else:
+            assert isinstance(value, (list,tuple)), value
+            base = py.path.local(mod.__file__).dirpath()
+            print "base", base
+            rsync_roots = [base.join(path, abs=True)
+                                for path in value]
+            for root in rsync_roots:
+                assert root.check(dir=1)
+            #rsync_roots = value
+            print "rsync_roots", rsync_roots
         sshhosts = [HostInfo(i) for i in
-                    self.config.getvalue("disthosts")]
+                    self.config.getvalue("dist_hosts")]
         parse_directories(sshhosts)
         remotepython = self.config.getvalue("dist_remotepython")
         return sshhosts, remotepython, rsync_roots

Modified: py/trunk/py/test/rsession/testing/test_rsession.py
==============================================================================
--- py/trunk/py/test/rsession/testing/test_rsession.py	(original)
+++ py/trunk/py/test/rsession/testing/test_rsession.py	Sun Jan 28 22:54:12 2007
@@ -76,7 +76,7 @@
     def test_example_distribution_minus_x(self):
         tmpdir = py.test.ensuretemp("example_distribution_minus_x")
         tmpdir.ensure("sub", "conftest.py").write(py.code.Source("""
-            disthosts = [%r]
+            dist_hosts = [%r]
         """ % ('localhost',)))
         tmpdir.ensure("sub", "__init__.py")
         tmpdir.ensure("sub", "test_one.py").write(py.code.Source("""
@@ -106,9 +106,9 @@
         subdir = "sub_example_dist"
         tmpdir = py.test.ensuretemp("example_distribution")
         tmpdir.ensure(subdir, "conftest.py").write(py.code.Source("""
-            disthosts = [%r]
-            distrsync_roots = ["%s", "py"]
-        """ % ('localhost', subdir)))
+            dist_hosts = [%r]
+            dist_rsync_roots = ["%s", "../py"]
+        """ % ('localhost', tmpdir.join(subdir), )))
         tmpdir.ensure(subdir, "__init__.py")
         tmpdir.ensure(subdir, "test_one.py").write(py.code.Source("""
             def test_1(): 
@@ -161,7 +161,8 @@
         teardown_events = []
         
         config = py.test.config._reparse([])
-        opts = HostOptions(optimise_localhost=False, rsync_roots=['py'])
+        opts = HostOptions(optimise_localhost=False, 
+                           rsync_roots=[py.path.local(py.__file__).dirpath()])
         hm = HostManager(hosts, config, opts)
         nodes = hm.init_hosts(setup_events.append)
         hm.teardown_hosts(teardown_events.append, 
@@ -188,7 +189,8 @@
         allevents = []
         
         config = py.test.config._reparse([])
-        opts = HostOptions(optimise_localhost=False, rsync_roots=['py'])
+        opts = HostOptions(optimise_localhost=False, 
+                           rsync_roots=[py.path.local(py.__file__).dirpath()])
         hm = HostManager(hosts, config, opts)
         nodes = hm.init_hosts(allevents.append)
         
@@ -235,7 +237,8 @@
         from py.__.test.rsession.master import defaultconftestnames
         defaultconftestnames.append("custom")
         try:
-            opts = HostOptions(optimise_localhost=False, rsync_roots=['py'])
+            opts = HostOptions(optimise_localhost=False, 
+                               rsync_roots=[py.path.local(py.__file__).dirpath()])
             hm = HostManager(hosts, config, opts)
             nodes = hm.init_hosts(allevents.append)
 
@@ -267,7 +270,7 @@
         tmpdir = py.test.ensuretemp("nice")
         tmpdir.ensure("__init__.py")
         tmpdir.ensure("conftest.py").write(py.code.Source("""
-        disthosts = ['localhost']
+        dist_hosts = ['localhost']
         dist_nicelevel = 10
         """))
         tmpdir.ensure("test_one.py").write("""def test_nice():



More information about the pytest-commit mailing list