Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slimer.exit() should be able to set exit status #50

Closed
jcoglan opened this issue Jun 28, 2013 · 11 comments
Closed

slimer.exit() should be able to set exit status #50

jcoglan opened this issue Jun 28, 2013 · 11 comments

Comments

@jcoglan
Copy link

jcoglan commented Jun 28, 2013

Currently (version 0.7) calling slimer.exit(1) makes the process exit with status 0. This makes Slimer unsuitable for use as a testing platform since CI servers cannot tell whether the tests failed without relying on a special output format like TAP or XML.

It should be possible to write test scripts with Slimer and use the exit status to indicate failure.

@laurentj
Copy link
Owner

This is a known issue. As indicated in API_COMPAT, there is no way in the mozilla platform to set the exit status. So the exit() parameter is ignored for the moment.

@laurentj
Copy link
Owner

A workaround for your script is to display (console.log) an error message and a rule in the CI server could check if the output contains this message or not.

@jcoglan
Copy link
Author

jcoglan commented Jun 28, 2013

I don't know a lot about how this stuff works, but the SpiderMonkey shell supports quit(1) which exits with 1. Can you explain a bit more so I understand why you can't do a similar thing?

For now, I can make my test tools emit TAP and pipe into something that knows what that means, so this isn't a show-stopper.

@laurentj
Copy link
Owner

I don't use the spidermonkey shell. SpiderMonkey is only a javascript engine. It does not contain a rendering engine, it does not provide a DOM API, an API to manipulate files, an API to do networking etc. SpiderMonkey is only a tiny part of a browser, a tiny part of Gecko. SlimerJS is built on top the Mozilla platform (Gecko/XulRunner), like Firefox.

In future version, probably SlimerJS will embed directly the Mozilla platform, so we could patch it to provide missing features.

@laurentj
Copy link
Owner

Possible solution for a patch on gecko for a future version of SlimerJS:

  1. add a property to set an exit code, into the interface nsIAppStartup
  2. implement this property into nsAppStartup
  3. returns this property from XREMain::XRE_mainRun

It should be enough.

@laurentj
Copy link
Owner

laurentj commented May 5, 2014

A WIP patch does exist https://bugzilla.mozilla.org/show_bug.cgi?id=894697

@abozhilov
Copy link
Contributor

I think it could be achieve it without changes in the Gecko. Since slimerjs is launched via shell script, you can use nsIEnvironment https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEnvironment to set var for the current process in the phantom/slimer.exit() and then exit from the shell with the value of that var.

The above solution will not work, because the xulrunner is run in its own shell.

For now the solution which would work is to write status file in the profile dir and get the exit status from that file after xulrunner has finished.

@laurentj
Copy link
Owner

laurentj commented Dec 2, 2014

@abozhilov yes I thought about a solution like that, but I found it is was an ugly hack.

However, since we can't wait after Mozilla and many projects depends on it, I'm ok to implement this solution.

@abozhilov
Copy link
Contributor

#278

laurentj added a commit that referenced this issue Feb 18, 2015
@laurentj laurentj modified the milestones: SlimerJS 0.10, SlimerJS 1.0 Feb 18, 2015
@laurentj
Copy link
Owner

So now we have a workaround for the exit code, thanks to @abozhilov .

@nathanboktae
Copy link

Can we close this issue now that #278 has been merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants