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

Re: [PATCH] Use subprocess.Popen for executing commands in cmdline tests

From: Daniel Shahaf <d.s_at_daniel.shahaf.co.il>
Date: Sat, 26 Apr 2008 13:34:12 +0300 (Jerusalem Daylight Time)

jeremy hinds wrote on Fri, 25 Apr 2008 at 22:58 -0600:
> 2008/4/19 Daniel Shahaf <d.s_at_daniel.shahaf.co.il>:
> > jeremy hinds wrote on Fri, 18 Apr 2008 at 19:01 -0600:
> >
> > > I started working on getting a Windows dev environment set up so I can
> > > at least make sure things can be expected to work before asking for
> > > anybody else's time to test it. But I'm not quite there yet. In the
> > > meantime, if someone else happens to get a chance to look at it, that
> > > would be great.
> > >
> >
> > I'm getting this error with your patch on Windows (ra_svn fsfs
> > VC9Express):
> >
> > START: changelist_tests.py
> > CMD: svnadmin.exe create svn-test-work\local_tmp\repos --bdb-txn-nosync --fs-type=fsfs
> > Traceback (most recent call last):
...
> > File "E:\Python\lib\subprocess.py", line 551, in __init__
> > raise ValueError("close_fds is not supported on Windows "
> > ValueError: close_fds is not supported on Windows platforms
> > END: changelist_tests.py
> >
> > (The error repeats for every *_tests.py file.)
> >
> > Python docs agree: (http://docs.python.org/lib/node528.html)
> >
> > "If close_fds is true, all file descriptors except 0, 1 and 2 will
> > be closed before the child process is executed. (Unix only)"
> > ^^^^^^^^^^^
> >
> > Daniel
>
>
> Thanks for giving it a try, Daniel. I saw that "Unix only" thing in
> the documentation, but it seemed unclear what the behavior would be on
> non-Unix.

Agreed, it's unclear. In Python trunk the paragraph reads:
(http://svn.python.org/view/python/trunk/Doc/library/subprocess.rst?rev=62427&view=auto):

   If *close_fds* is true, all file descriptors except :const:`0`, :const:`1` and
   :const:`2` will be closed before the child process is executed. (Unix only).
   Or, on Windows, if *close_fds* is true then no handles will be inherited by the
   child process. Note that on Windows, you cannot set *close_fds* to true and
   also redirect the standard handles by setting *stdin*, *stdout* or *stderr*.

but doesn't mention throwing exceptions in older versions.

> I was rather hoping for "silently ignored." My plan was to
> get a Windows build working to test this before submitting the updated
> patch, but I think I'm going to have to throw in the towel on that for
> now. I did at least extract the Popen functionality into a separate
> script and ran that on Windows (I should have done this before). The
> pertinent lines in the patch are
>
> + close_fds=False
> + if is_posix_os():
> + close_fds=True
> + # (use universal newlines for text mode)
> + kid = Popen(command, shell=False, bufsize=-1,
> + universal_newlines=(not binary_mode),
> + stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=close_fds)
> + return kid.stdin, kid.stdout, kid.stderr, (kid, command)
>
> The only other difference between this and the previous iteration is
> the removal of another comment in svntest/main.py.
>

Yes, the tests run now against the latest svn binary I have, and pass
(except for some failures unrelated to your patch). I'll try and test the
patch against HEAD this week, if no one beats me to it.

Daniel

> [[[
> In cmdline tests, use subprocess.Popen for executing commands to allow
> support for exit-code checks on both Windows and posix systems. This makes
> the test suite require Python version >= 2.4.
>
> * subversion/tests/cmdline/svntest/main.py
> (global): Import subprocess instead of popen2. Remove variable
> "platform_with_popen3_class".
> (_quote_arg): Removed, since commands + args to open_pipe are now lists.
> (open_pipe): Replace "mode" character parameter with a "binary_mode" boolean
> value. Use subprocess.Popen for spawning the child process.
> (wait_on_pipe): Interpret the return value of wait() according to
> subprocess.Popen semantics.
> (spawn_process, copy_repos): When calling open_pipe, pass the command as
> a list and binary_mode as a boolean.
> (run_svn2): New, like run_svn but with a "binary_mode" boolean param.
> (TestSpawningThread.run_one): Remove the caveat comment stating that
> result (exit-code) is None on Windows.
>
> * subversion/tests/cmdline/svntest/actions.py
> (run_and_verify_svnlook, run_and_verify_svnlook2, run_and_verify_svnadmin,
> run_and_verify_svnadmin2, run_and_verify_svnversion,
> run_and_verify_svnversion2,
> run_and_verify_svn_match_any, run_and_verify_svn_match_any2):
> Remove the caveat comment stating that exit-code checks are skipped
> for some platforms.
> (run_and_verify_svn): Remove the caveat comment stating that exit-code
> checks are skipped for some platforms. Pass binary_mode=0 to
> run_and_verify_svn2.
> (run_and_verify_svn2): Remove the caveat comment stating that exit-code
> checks are skipped for some platforms. Add a binary_mode boolean
> parameter. Replace call to run_svn with run_svn2.
>
> * subversion/tests/cmdline/import_tests.py
> (import_eol_style): Call run_and_verify_svn2 with binary_mode=1.
>
> * subversion/tests/cmdline/cat_tests.py,
> subversion/tests/cmdline/lock_tests.py,
> subversion/tests/cmdline/stat_tests.py:
> Pass binary_mode parameter to run_and_verify_svn2.
>
> ]]]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-04-26 12:34:32 CEST

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