2014/1/9 Sunil <
sdars...@gmail.com>:
As Kevin pointed out, stopping execution if a critical test fails is
easiest accomplished with `--ExitOnFailure` option.
If you want to do it based on some other criteria, using a listener
like you have been planning might be a good idea but unfortunately I
don't think there are any generic and safe way to do it.
On Python and outside Windows you should be able to use
`os.kill(os.getpid(), signal.SIGINT)` to send same signal that Ctrl-C
sends to stop execution gracefully. If that's not enough, you can use
Robot's internal signal handler directly:
from robot.running.signalhandler import STOP_SIGNAL_MONITOR
import signal
def end_keyword(<args>):
if <condition>:
STOP_SIGNAL_MONITOR(signal.SIGINT, None)
The above solution (after filling the blanks and making sure you only
send the signal once) ought to work regardless the operating system
and Python interpreter. The problem with it is that
STOP_SIGNAL_MONITOR is not part of the public API and thus subject to
change at least in major versions. How you need to use it in this
particulate case is also pretty ugly.
Having a cleaner way to stop execution via the listener interface and
also by libraries (they can already now use fatal exceptions, though)
would be nice. Please submit an enhancement request to Robot's tracker
if you think it would be useful. There are some changes needed to
signal handling anyway in 2.8.4 [1] so perhaps we could do a bit
larger rewrite then.
[1]
http://code.google.com/p/robotframework/issues/detail?id=1617
Cheers,
.peke
--
Agile Tester/Developer/Consultant ::
http://eliga.fi
Lead Developer of Robot Framework ::
http://robotframework.org