python version-specific codepaths in tests

John Arbash Meinel john at arbash-meinel.com
Fri Nov 20 15:17:14 GMT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gordon Tyler wrote:
> John Arbash Meinel wrote:
>> I would make sure it works first. If SIGTERM is built on
>> TerminateProcess, I think it works, but I'd want to make sure it doesn't
>> kill the testing process.
> 
> I've been using it this evening while adding a test for bzr serve. All
> the bzr serve tests seem to work fine on win32. Haven't tested it on
> non-win32 yet.
> 
> There is a wee snag though: the tests which make use of
> finish_bzr_subprocess' signalling capability use SIGINT, to simulate a
> user pressing Ctrl-C I'm guessing. The Win32 implementation of
> Popen.send_signal only allows SIGTERM. I could make it translate SIGINT
> to SIGTERM but that changes bzr's output (no 'bzr: interrupted'). I'm
> wondering if it's important enough to simulate user interruption in
> those cases or if it's acceptable to use SIGTERM in those tests instead.
> 
> The code which uses SIGINT:
> 
> TestActuallyStartBzrSubprocess
> - test_start_and_stop_bzr_subprocess_send_signal
> 
> TestBzrServe
> - assertServerFinishesCleanly (which is used by most of the actual tests
> in TestBzrServe)
> 
> Ciao,
> Gordon
> 

so you can replicate SIGINT, but when I was digging through the win32
api docs, it basically sends a ^C to the console. Which means that either:

1) You interrupt the current process as well as the subprocess
2) You spawn the subprocess into a separate process group/etc in which
case you can no longer send it SIGINT...

Joy, right? </sarcasm>

Anyway, (1) can be handled by trapping KeyboardInterrupt around the
send-signal code.

I'll attach the script I used for testing this a while ago.

We probably could turn this into a 'win32tools.py' helper, and use it as
long as ctypes is present (the code I have is using pywin32, but it is
usually pretty easy to convert into a ctypes helper.)


As for whether SIGINT is *needed*... It is nice to see that things clean
up cleanly and quietly. It isn't a strict requirement.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksGsvoACgkQJdeBCYSNAAPUzQCgxks1Tg0qSRw/4pAmfdUXphcY
CDkAnRxkGIauiW8B80bv8Js1erAyqEJ3
=bMhC
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: start_serv.py
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20091120/b72c5a2c/attachment.diff 


More information about the bazaar mailing list