Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

Prevent multiple calls to phantom.exit#183

Merged
searls merged 2 commits intotestdouble:masterfrom
shamus:master
Feb 17, 2016
Merged

Prevent multiple calls to phantom.exit#183
searls merged 2 commits intotestdouble:masterfrom
shamus:master

Conversation

@shamus
Copy link

@shamus shamus commented Feb 6, 2016

Currently, using jasmine-rails with phantomjs 2.1.1 causes phantomjs to
segfault. It appears that the onInitialized handler registered in
libe/assets/javascripts/jasmine-runner.js:48 is being executed multiple
times. Each call registers a window.onLoad listener which eventually
calls phantom.exit. It is unclear why page.onInitialized is called more
than once.

This commit introduces an initialized flag which prevents the
page.onInitialized callback from registering more than one window.onLoad
callback.

Not an ideal fix. It would be better to figure out what causes
page.onInitialized to be executed multiple times.

@searls
Copy link
Member

searls commented Feb 9, 2016

Thanks for this. I'd like to see someone replicate the issue and a green build before merging. It looks like the build has incidentally broken again so I'm testing it here: https://travis-ci.org/searls/jasmine-rails/builds/108023254

Jeremy Morony added 2 commits February 9, 2016 08:15
The test suite for rails 4.0 using jasmine 2 was failing. This suite
tests that jasmine-rails was successfully mounted under /specs by
asserting that the stats banner is shown.

In the current version of jasmine 2, the class names that this banner is
found under have changed to .jasmine-bar.jasmine-passed (presumeably
from .bar.passed)
Currently, using jasmine-rails with phantomjs 2.1.1 causes phantomjs to
segfault. It appears that the onInitialized handler registered in
libe/assets/javascripts/jasmine-runner.js:48 is being executed multiple
times. Each call registers a window.onLoad listener which eventually
calls phantom.exit. It is unclear why page.onInitialized is called more
than once.

This commit introduces an initialized flag which prevents the
page.onInitialized callback from registering more than one window.onLoad
callback.

Not an ideal fix. It would be better to figure out what causes
page.onInitialized to be executed multiple times.
@shamus
Copy link
Author

shamus commented Feb 9, 2016

Fair enough. The failing specs on this branch (and also here: #181) are due to a change in the markup for the jasmine report page. The status banner classes changed to .jasmine-bar.jasmine-passed.

This branch contains a fix for that now.

As for reproducting, two things:

Here's the full output from my mac

Running `"/Users/shamus/.phantomjs/2.1.1/darwin/bin/phantomjs" "" "/Users/shamus/.rvm/gems/ruby-2.1.5/gems/jasmine-rails-0.12.2/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///Users/shamus/projects/me/jasmine_rails_test/tmp/jasmine/runner.html?spec="`
Running: file:///Users/shamus/projects/me/jasmine_rails_test/tmp/jasmine/runner.html?spec=
Starting...

Finished
-----------------
0 specs, 0 failures in 0.002s.

ConsoleReporter finished
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
rake aborted!
Error executing command: "/Users/shamus/.phantomjs/2.1.1/darwin/bin/phantomjs" "" "/Users/shamus/.rvm/gems/ruby-2.1.5/gems/jasmine-rails-0.12.2/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///Users/shamus/projects/me/jasmine_rails_test/tmp/jasmine/runner.html?spec="
/Users/shamus/.rvm/gems/ruby-2.1.5/gems/jasmine-rails-0.12.2/lib/jasmine_rails/runner.rb:73:in `run_cmd'
/Users/shamus/.rvm/gems/ruby-2.1.5/gems/jasmine-rails-0.12.2/lib/jasmine_rails/runner.rb:23:in `block in run'
/Users/shamus/.rvm/gems/ruby-2.1.5/gems/jasmine-rails-0.12.2/lib/jasmine_rails/runner.rb:50:in `override_rails_config'
/Users/shamus/.rvm/gems/ruby-2.1.5/gems/jasmine-rails-0.12.2/lib/jasmine_rails/runner.rb:9:in `run'
/Users/shamus/.rvm/gems/ruby-2.1.5/gems/jasmine-rails-0.12.2/lib/tasks/jasmine-rails_tasks.rake:9:in `block (2 levels) in <top (required)>'
Tasks: TOP => spec:javascript
(See full trace by running task with --trace)

And here's the full output from Travis

Running `"/home/travis/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs" "" "/home/travis/build/searls/jasmine-rails/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///home/travis/build/searls/jasmine-rails/spec/testbeds/rails-3.2/tmp/jasmine/runner.html?spec="`
Running: file:///home/travis/build/searls/jasmine-rails/spec/testbeds/rails-3.2/tmp/jasmine/runner.html?spec=
Starting...
Finished
-----------------
5 specs, 0 failures in 0.017s.
ConsoleReporter finished
Killed
rake aborted!
Error executing command: "/home/travis/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs" "" "/home/travis/build/searls/jasmine-rails/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///home/travis/build/searls/jasmine-rails/spec/testbeds/rails-3.2/tmp/jasmine/runner.html?spec="
/home/travis/build/searls/jasmine-rails/lib/jasmine_rails/runner.rb:73:in `run_cmd'
/home/travis/build/searls/jasmine-rails/lib/jasmine_rails/runner.rb:23:in `block in run'
/home/travis/build/searls/jasmine-rails/lib/jasmine_rails/runner.rb:50:in `override_rails_config'
/home/travis/build/searls/jasmine-rails/lib/jasmine_rails/runner.rb:9:in `run'
/home/travis/build/searls/jasmine-rails/lib/tasks/jasmine-rails_tasks.rake:9:in `block (2 levels) in <top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `eval'
/home/travis/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => testbed:current:spec:javascript
(See full trace by running task with --trace)
rake aborted!
specs failed
/home/travis/build/searls/jasmine-rails/Rakefile:23:in `block (2 levels) in <top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `eval'
/home/travis/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => testbed:current:all => testbed:rails-3.2:run_jasmine_rake_in_dummy
(See full trace by running task with --trace)

@johncalvinyoung
Copy link

This would be really good to get merged. We're using PhantomJS 2.1.1 for our Rails test stack, and it's a real pain having to downgrade to 1.9.8 for jasmine. Getting pressure from others on my team to use something other than Jasmine over it.

@searls
Copy link
Member

searls commented Feb 17, 2016

Green is better than not green. LGTM.

searls added a commit that referenced this pull request Feb 17, 2016
Prevent multiple calls to phantom.exit
@searls searls merged commit f141c1c into testdouble:master Feb 17, 2016
@searls
Copy link
Member

searls commented Feb 17, 2016

Landed in 0.12.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants