backticks make my Windows testing service hang on ack

brian_d_foy on 2009-04-13T21:54:29

I've run into an interesting situation in testing CPAN modules on Windows using TeamCity. Testing from the command line, either cygwin or command, works fine, but when the automated tester has a go, it fails. I traced this back to modules that use system() or backticks. The ack distribution has been the one to demonstrate the problem first. I wonder if anyone else has seen a similar problem.

I've been working on a custom internal CPAN for a big company, and their CPAN is actually in subversion. When the subversion repo changes, lots of tests kick off, including tests for individual modules as well as integration tests. These tests run on both unix and Windows using the TeamCity build agents. Some of the Windows tests just hang forever, although they run fine on my workstation.

It appears that the Windows build agents are run as a Windows service, so it's not connected to something that can handle system calls. I don't understand the Windows set-up and architecture enough to say more than that. Once the build agent hits a line of code that wants to shell out somehow, it hangs forever. It only does this in the build agent.

I was working with ack, which has a t/Util.pm for things that most of the tests use. There is a run_ack_with_stderr() subroutine which uses backticks, and that's where the code hangs. Once it runs t/ack-1.t, everything stops.

Paul's IPC::System::Simple::capture() works as a backticks replacement and has already solved many problems we've had with Windows. However, my first try in replacing backticks made all sorts of other tests fail even though it could run the commands now. Nothing hung, but there was something I wasn't capturing correctly or putting in the right place, I figure. I eventually had to cut bait since I'm not getting paid to work on third-party modules.

I'm curious how this works for the Windows CPAN testers. Are you just running the testing script from a command or terminal window? Do you ignore distros that just hang? I didn't see any sort of ack failure that showed the same symptoms.

And, is there some sort of medal or award that Paul can get for IPC::System::Simple? I wasn't keen on depending on it at first, but now that I've experienced a bit of grief trying to make Windows be unix, I really appreciate IPC::System::Simple taking care of all of that.


A medal?

pjf on 2009-04-14T10:54:11

If the tests are failing because IPC::System::Simple is somehow replacing backticks in a fundamentally incompatible way (which is not documented), then a failing test case is better than any medal.

Otherwise, kind words in a blog post are all the thanks I need. ;)

another

mpeters on 2009-04-14T12:02:24

Did you try Capture::Tiny?

Allow service to interact with the desktop

oneiron on 2009-04-14T12:28:19

For the hanging agent/service, you might try: Control Panel -> AdministrativeTools -> Services, choose the offending service, right click (Properties) and check the "Allow service to interact with the desktop" checkbox (this checkbox will probably be in the LogOn tab). No guarantee it will change anything, but it is definitely worth a try, based on the symptoms you describe. Your hangs may be because the Service is not allowed to interact with the desktop and so is not allowed to create a (desktop) console window for stdin/stdout/stderr. If that fixes the problem, you need to alert the folks who wrote the agent/service; they should be able to fix the service so that it doesn't require the "Interact with the desktop" setting (it is generally considered poor style and less secure/robust for a service to interact with the desktop). BTW, which version of Windows is the service running on?

Re:Allow service to interact with the desktop

brian_d_foy on 2009-04-14T14:23:52

I'll have to investigate that a bit more. Not interacting with the Desktop might be a feature. Thanks,