You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2011/04/19 01:16:45 UTC
svn commit: r1094816 -
/subversion/trunk/tools/dev/benchmarks/suite1/benchmark.py
Author: gstein
Date: Mon Apr 18 23:16:44 2011
New Revision: 1094816
URL: http://svn.apache.org/viewvc?rev=1094816&view=rev
Log:
Apply a patch from Alan Wood that helps benchmark.py run on the Windows
platform.
Note: the patch was not completely applied, but inspired this change.
* /tools/dev/benchmarks/suite1/benchmark.py:
(): import stat to use for chmod later
(svn): if an OSError occurs when trying to run the command, return None
for the stdout and stderr. this signals to the caller, that the
command (probably) could not be found.
(rmtree_onerror): helper for the shutil.rmtree() call to fix up a
Windows tree to make files writable, and (thus) deleteable.
(run): switch any backslashes in the repository (file) URL to forward
slashes, as any Proper URL Should Be. rather than using 'which' to
locate svn, just run the --version command (which we want to do
anyways). The operation of that command will signal whether we can
successfully invoke svn for the tests. also: use rmtree_onerror.
Modified:
subversion/trunk/tools/dev/benchmarks/suite1/benchmark.py
Modified: subversion/trunk/tools/dev/benchmarks/suite1/benchmark.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/benchmarks/suite1/benchmark.py?rev=1094816&r1=1094815&r2=1094816&view=diff
==============================================================================
--- subversion/trunk/tools/dev/benchmarks/suite1/benchmark.py (original)
+++ subversion/trunk/tools/dev/benchmarks/suite1/benchmark.py Mon Apr 18 23:16:44 2011
@@ -39,6 +39,7 @@ import random
import shutil
import cPickle
import optparse
+import stat
TOTAL_RUN = 'TOTAL RUN'
@@ -269,6 +270,8 @@ def svn(*args):
stderr=subprocess.PIPE,
shell=False)
stdout,stderr = p.communicate(input=stdin)
+ except OSError:
+ stdout = stderr = None
finally:
timings.toc()
@@ -377,6 +380,24 @@ def propadd_tree(in_dir, fraction):
propadd_tree(path, fraction)
+def rmtree_onerror(func, path, exc_info):
+ """Error handler for ``shutil.rmtree``.
+
+ If the error is due to an access error (read only file)
+ it attempts to add write permission and then retries.
+
+ If the error is for another reason it re-raises the error.
+
+ Usage : ``shutil.rmtree(path, onerror=onerror)``
+ """
+ if not os.access(path, os.W_OK):
+ # Is the error an access error ?
+ os.chmod(path, stat.S_IWUSR)
+ func(path)
+ else:
+ raise
+
+
def run(levels, spread, N):
for i in range(N):
base = tempfile.mkdtemp()
@@ -386,22 +407,23 @@ def run(levels, spread, N):
try:
repos = j(base, 'repos')
+ repos = repos.replace('\\', '/')
wc = j(base, 'wc')
wc2 = j(base, 'wc2')
file_url = 'file://%s' % repos
- so, se = run_cmd(['which', 'svn'])
+ so, se = svn('--version')
if not so:
print "Can't find svn."
exit(1)
+ version = ', '.join([s.strip() for s in so.split('\n')[:2]])
print '\nRunning svn benchmark in', base
print 'dir levels: %s; new files and dirs per leaf: %s; run %d of %d' %(
levels, spread, i + 1, N)
- so, se = svn('--version')
- print ', '.join( so.split('\n')[:2] )
+ print version
started = datetime.datetime.now()
try:
@@ -494,7 +516,7 @@ def run(levels, spread, N):
print timings.summary()
finally:
- shutil.rmtree(base)
+ shutil.rmtree(base, onerror=rmtree_onerror)
def read_from_file(file_path):