[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Python tests fail on filenames with $ signs on non-windows platforms

From: Peter Samuelson <peter_at_p12n.org>
Date: 2006-06-11 17:30:41 CEST

[Lieven Govaerts]
> I see in svntest/main.py that all command-line arguments for svn are wrapped
> in double quotes, like this:
> CMD: svn.exe "add" "svn-test-work\working_copies\trans_tests-1\id_exp
> with_$_sign" "--config-dir"
> "C:\devel\subversion\trunk\Debug\subversion\tests\cmdline\svn-test-work\loca
> l_tmp\config"

IMO, a simpler and better approach would be to let os.popen3() handle
the quoting instead of trying to do it by hand. I have no idea how
intelligent os.popen3 is on the various platforms - would the following
be sufficiently portable? It's untested.

Index: subversion/tests/cmdline/svntest/main.py
===================================================================
--- subversion/tests/cmdline/svntest/main.py (revisione 20040)
+++ subversion/tests/cmdline/svntest/main.py (copia locale)
@@ -16,7 +16,7 @@
 ######################################################################
 
 import sys # for argv[]
-import os # for popen2()
+import os # for popen3()
 import shutil # for rmtree()
 import re
 import stat # for ST_MODE
@@ -251,16 +251,16 @@
   Return stdout, stderr as lists of lines.
   If ERROR_EXPECTED is None, any stderr also will be printed."""
 
- args = ''
- for arg in varargs: # build the command string
+ varargs_verbose = ''
+ for arg in varargs: # build the verbose output
     arg = str(arg)
     if os.name != 'nt':
       arg = arg.replace('$', '\$')
- args = args + ' "' + arg + '"'
+ varargs_verbose = varargs_verbose + ' "' + arg + '"'
 
   # Log the command line
   if verbose_mode:
- print 'CMD:', os.path.basename(command) + args,
+ print 'CMD:', os.path.basename(command) + varargs_verbose
 
   if binary_mode:
     mode = 'b'
@@ -268,7 +268,7 @@
     mode = 't'
 
   start = time.time()
- infile, outfile, errfile = os.popen3(command + args, mode)
+ infile, outfile, errfile = os.popen3([command] + varargs, mode)
 
   if stdin_lines:
     map(infile.write, stdin_lines)
@@ -451,17 +451,20 @@
   # require access to the BDB tools, and this doesn't. Print a fake
   # pipe command so that the displayed CMDs can be run by hand
   create_repos(dst_path)
- dump_args = ' dump "' + src_path + '"'
- load_args = ' load "' + dst_path + '"'
+ dump_args = ['dump', src_path]
+ load_args = ['load', dst_path]
+ dump_args_verbose = ' dump "' + src_path + '"'
+ load_args_verbose = ' load "' + dst_path + '"'
 
   if ignore_uuid:
- load_args = load_args + " --ignore-uuid"
+ load_args.append('--ignore-uuid')
+ load_args_verbose = load_args_verbose + " --ignore-uuid"
   if verbose_mode:
- print 'CMD:', os.path.basename(svnadmin_binary) + dump_args, \
- '|', os.path.basename(svnadmin_binary) + load_args,
+ print 'CMD:', os.path.basename(svnadmin_binary) + dump_args_verbose
+ '|', os.path.basename(svnadmin_binary) + load_args_verbose,
   start = time.time()
- dump_in, dump_out, dump_err = os.popen3(svnadmin_binary + dump_args, 'b')
- load_in, load_out, load_err = os.popen3(svnadmin_binary + load_args, 'b')
+ dump_in, dump_out, dump_err = os.popen3([svnadmin_binary] + dump_args, 'b')
+ load_in, load_out, load_err = os.popen3([svnadmin_binary] + load_args, 'b')
   stop = time.time()
   if verbose_mode:
     print '<TIME = %.6f>' % (stop - start)

Received on Sun Jun 11 17:30:54 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.