Giter Club home page Giter Club logo

Comments (9)

carlpett avatar carlpett commented on July 24, 2024

Thanks for reporting! I will have a look - my assumption was that this was handled by the base class from the TeamCity API I extended, but I may have misread the documentation.

from xunit-teamcity.

carlpett avatar carlpett commented on July 24, 2024

@taliesins I've made a fix for this now, available in version 1.1.3. Could you give it a try?

from xunit-teamcity.

taliesins avatar taliesins commented on July 24, 2024

I clicked stop in TeamCity. The xUnit runner was killed, but child processes stayed alive. I was hoping it would also kill all child processes.

So in the specflow scenario I landed up with 1 chromedriver.exe and 4 chrome.exe instances. I have hooked into the app domain unload event as well as creating a critical finalizer in the hope I can kill off the processes, but they stayed alive.

from xunit-teamcity.

carlpett avatar carlpett commented on July 24, 2024

@taliesins Hm, that turns out to be a bit tricky, it seems... Java does not support signalling or killing child processes, as far as I can see, due to it being hard to do in a cross platform manner. There are a few posts with hacks involving WMI around the net, but nothing that seems particularly robust (in your case we probably have multiple levels of subprocesses, for instance).
I'm a bit surprised that xUnit would not handle this more gracefully, I'll do some reading and see if there's kinder ways than Process.destroy() to stop.

from xunit-teamcity.

taliesins avatar taliesins commented on July 24, 2024

Can you send ctrl+c twice sleep a bit then call process.destroy() as this would allow xunit to cancel itself gracefully and allow me to hook into subdomain unload.

from xunit-teamcity.

taliesins avatar taliesins commented on July 24, 2024

https://github.com/xunit/xunit/blob/master/src/xunit.console/Program.cs

Send ctrl + c, sleep, send ctrl + c, sleep, process.destroy()

from xunit-teamcity.

carlpett avatar carlpett commented on July 24, 2024

Yes, part of the problem is that ctrl+c isn't really a character that can be sent to an input stream, it is a keystroke which is interpreted by the shell when you are running it interactively.

From what I've gathered, I'll need to get into JNA and send a Windows message to the application. I'm looking into exactly what I need to do for that (I'm don't do any Java development outside of this plugin, so it's a bit slow, I'm afraid)

from xunit-teamcity.

taliesins avatar taliesins commented on July 24, 2024

I think I may have an easy solution for you.

http://www.latenighthacking.com/projects/2003/sendSignal/
https://github.com/walware/statet/tree/master/de.walware.statet.r.console.core/win32

So pass the process id to sendsignal.exe and it will send ctrl+c to the process.

from xunit-teamcity.

carlpett avatar carlpett commented on July 24, 2024

@taliesins First, thanks for taking an active part in resolving this :)

I looked into sendsignal a bit, and I think there might be a few issues with that approach sadly. The Java Process class' many shortcomings include not exposing the PID. That could of course be solved by enumerating all processes and looking for the test runner. However, quite a few deployments of TeamCity (including some of those I work with, despite my protests) run several agents on the same machines. When this happens, it will not be possible to know which process should be targeted.

As a temporary workaround, in case you do run multiple agents as described above, would it work for you to add an extra build step at the end of your build with the "Run always, even if build stop command was issued" execution policy which calls sendsignal (or something similar)?

from xunit-teamcity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.