[svn r63000] * do an as lightweight config.mktemp() as possible
* avoid writing lock files if lock_timeout is 0 or None --HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									47a91d2aa9
								
							
						
					
					
						commit
						4aac96fa13
					
				|  | @ -618,6 +618,7 @@ class LocalPath(common.FSPathBase, PlatformMixin): | ||||||
| 
 | 
 | ||||||
|         # put a .lock file in the new directory that will be removed at |         # put a .lock file in the new directory that will be removed at | ||||||
|         # process exit |         # process exit | ||||||
|  |         if lock_timeout: | ||||||
|             lockfile = udir.join('.lock') |             lockfile = udir.join('.lock') | ||||||
|             mypid = os.getpid() |             mypid = os.getpid() | ||||||
|             if hasattr(lockfile, 'mksymlinkto'): |             if hasattr(lockfile, 'mksymlinkto'): | ||||||
|  | @ -647,7 +648,7 @@ class LocalPath(common.FSPathBase, PlatformMixin): | ||||||
|                     try: |                     try: | ||||||
|                         t1 = lf.lstat().mtime |                         t1 = lf.lstat().mtime | ||||||
|                         t2 = lockfile.lstat().mtime |                         t2 = lockfile.lstat().mtime | ||||||
|                         if abs(t2-t1) < lock_timeout: |                         if not lock_timeout or abs(t2-t1) < lock_timeout: | ||||||
|                             continue   # skip directories still locked |                             continue   # skip directories still locked | ||||||
|                     except py.error.Error: |                     except py.error.Error: | ||||||
|                         pass   # assume that it means that there is no 'lf' |                         pass   # assume that it means that there is no 'lf' | ||||||
|  |  | ||||||
|  | @ -275,8 +275,6 @@ class TestExecution(LocalSetup): | ||||||
|                 assert not numdir.new(ext=str(i-3)).check() |                 assert not numdir.new(ext=str(i-3)).check() | ||||||
| 
 | 
 | ||||||
|     def test_locked_make_numbered_dir(self): |     def test_locked_make_numbered_dir(self): | ||||||
|         if py.test.config.option.boxed:  |  | ||||||
|             py.test.skip("Fails when run as boxed tests") |  | ||||||
|         root = self.tmpdir |         root = self.tmpdir | ||||||
|         for i in range(10): |         for i in range(10): | ||||||
|             numdir = local.make_numbered_dir(prefix='base2.', rootdir=root, |             numdir = local.make_numbered_dir(prefix='base2.', rootdir=root, | ||||||
|  |  | ||||||
|  | @ -140,7 +140,7 @@ class Config(object): | ||||||
|             return basetemp.mkdir(basename) |             return basetemp.mkdir(basename) | ||||||
|         else: |         else: | ||||||
|             return py.path.local.make_numbered_dir(prefix=basename + "-",  |             return py.path.local.make_numbered_dir(prefix=basename + "-",  | ||||||
|                 keep=0, rootdir=basetemp) |                 keep=0, rootdir=basetemp, lock_timeout=None) | ||||||
| 
 | 
 | ||||||
|     def getcolitems(self): |     def getcolitems(self): | ||||||
|         return [self.getfsnode(arg) for arg in self.args] |         return [self.getfsnode(arg) for arg in self.args] | ||||||
|  |  | ||||||
|  | @ -1,12 +1,6 @@ | ||||||
| 
 |  | ||||||
| """ Tests various aspects of dist, like ssh hosts setup/teardown |  | ||||||
| """ |  | ||||||
| 
 |  | ||||||
| import py | import py | ||||||
| from py.__.test.dsession.dsession import DSession | from py.__.test.dsession.dsession import DSession | ||||||
| from test_masterslave import EventQueue | from test_masterslave import EventQueue | ||||||
| import os |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| class TestAsyncFunctional: | class TestAsyncFunctional: | ||||||
|     def test_conftest_options(self, testdir): |     def test_conftest_options(self, testdir): | ||||||
|  | @ -80,6 +74,7 @@ class TestAsyncFunctional: | ||||||
| 
 | 
 | ||||||
|     def test_nice_level(self, testdir): |     def test_nice_level(self, testdir): | ||||||
|         """ Tests if nice level behaviour is ok """ |         """ Tests if nice level behaviour is ok """ | ||||||
|  |         import os | ||||||
|         if not hasattr(os, 'nice'): |         if not hasattr(os, 'nice'): | ||||||
|             py.test.skip("no os.nice() available") |             py.test.skip("no os.nice() available") | ||||||
|         testdir.makepyfile(conftest=""" |         testdir.makepyfile(conftest=""" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue