alexgb / guard-konacha

Automatically run konacha tests through Guard
MIT License
31 stars 17 forks source link

konacha command as string then split and splat #10

Closed bramswenson closed 11 years ago

bramswenson commented 11 years ago

Hey there,

Thanks for this grunt plugin. It didn't seem to work for me and it seems recent versions of ChildProcess require the command args to be separated. Please take a look, seems to work well for me. All the tests pass as expected for me.

Thanks again!

alexgb commented 11 years ago

I don't think this was your issue however. Plugin works as is on chidprocess 0.3.7 for me.

What isn't working? Show me your Gemfile and Guardfile.

bramswenson commented 11 years ago

Gemfile

gem 'rails', '3.2.11'

gem 'sqlite3'
gem 'high_voltage'

group :test, :development do
  gem 'rake'
  gem 'konacha'
  gem 'guard'
  gem 'guard-konacha'
  gem 'guard-livereload'
  gem 'guard-rails'
  gem 'rb-inotify', '~> 0.8.8'
  # sudo aptitude install libqtwebkit-dev
  gem 'capybara-webkit'
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'underscore-rails'
gem 'spine-rails'
gem 'eco'
gem 'd3-rails', git: 'git://github.com/bramswenson/d3-rails.git', ref: 'track_upstream_versions'
gem 'raphael-rails'

# Use unicorn as the app server
gem 'unicorn'

Guardfile

require 'capybara-webkit'

guard 'rails', :port => 3000 do
  watch('Gemfile.lock')
  watch(%r{^(config|lib)/.*})
end

guard :livereload do
  watch(%r{app/views/.+\.(erb|haml|slim)$})
  watch(%r{app/helpers/.+\.rb})
  watch(%r{public/.+\.(css|js|html)})
  watch(%r{config/locales/.+\.yml})
  # Rails Assets Pipeline
  watch(%r{(app|vendor)/assets/\w+/(.+\.(css|js|html)).*})  { "/" }
end

guard :konacha, driver: :webkit do
  watch(%r{^app/assets/javascripts/(.*)\.js(\.coffee)?$}) { |m| "#{m[1]}_spec.js" }
  watch(%r{^spec/javascripts/.+_spec(\.js|\.js\.coffee)$})
end

Error

λ purples ~/Projects/jigdev/jigui @master » bundle exec guard
11:02:18 - INFO - Guard::Konacha Initialized
11:02:18 - INFO - Guard uses NotifySend to send notifications.
11:02:18 - INFO - Guard uses Tmux to send notifications.                                                                                 [29/1933]
11:02:18 - INFO - Guard uses TerminalTitle to send notifications.
11:02:18 - INFO - Guard::Rails will now restart your app on port 3000 using development environment.
11:02:18 - INFO - Starting Rails...

=> Booting WEBrick
=> Rails 3.2.11 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-01-27 11:02:20] INFO  WEBrick 1.3.1
[2013-01-27 11:02:20] INFO  ruby 1.9.3 (2013-01-15) [x86_64-linux]
[2013-01-27 11:02:20] INFO  WEBrick::HTTPServer#start: pid=1277 port=3000
11:02:21 - INFO - Rails started, pid 1277

11:02:21 - INFO - LiveReload 1.6 is waiting for a browser to connect.
11:02:21 - INFO - Starting Konacha
11:02:21 - ERROR - Guard::Konacha failed to achieve its <start>, exception was:
> [#50E439160419] ChildProcess::LaunchError: No such file or directory - bundle exec rake konacha:serve
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/childprocess-0.3.7/lib/childprocess/unix/fork_exec_proces
s.rb:54:in `launch_process'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/childprocess-0.3.7/lib/childprocess/abstract_process.rb:6
8:in `start'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-konacha-0.2.1/lib/guard/konacha/runner.rb:138:in `s
pawn_konacha'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-konacha-0.2.1/lib/guard/konacha/runner.rb:33:in `la
unch_konacha'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-konacha-0.2.1/lib/guard/konacha.rb:17:in `start'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:99:in `block in run_super
vised_task'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:97:in `catch'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:97:in `run_supervised_task'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:54:in `block (2 levels) in run'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:175:in `block (3 levels) in scoped_guards'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:174:in `each'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:174:in `block (2 levels) in scoped_guards'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:173:in `catch'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:173:in `block in scoped_guards'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:172:in `each'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:172:in `scoped_guards'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:53:in `block in run'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/lumberjack-1.0.2/lib/lumberjack.rb:27:in `unit_of_work'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/runner.rb:52:in `run'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard.rb:187:in `block in start'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard.rb:363:in `block in within_preserved_state'
> [#50E439160419] <internal:prelude>:10:in `synchronize'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard.rb:360:in `within_preserved_state'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard.rb:185:in `start'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/lib/guard/cli.rb:110:in `start'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/gems/guard-1.6.1/bin/guard:6:in `<top (required)>'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/bin/guard:23:in `load'
> [#50E439160419] /home/shadowshell/Projects/jigdev/jigui/.bundle/bundle/ruby/1.9.1/bin/guard:23:in `<main>'
11:02:21 - INFO - Guard::Konacha has just been fired
11:02:21 - INFO - Guard is now watching at '/home/shadowshell/Projects/jigdev/jigui'
[1] guard(main)> 11:02:24 - INFO - Browser connected.
[1] guard(main)> 

It claims file not found error. Another thing of note is that I'm using zsh rather than the common bash which has some differences with resolving commands in my experience.

Thanks!

bramswenson commented 11 years ago

Also, switching to the default selenium driver has no effect.

alexgb commented 11 years ago

I assume running 'bundle exec rake konacha:serve' works?

What OS?

bramswenson commented 11 years ago

Correct, the command works fine manually and just ensuring the args into the ChildProcess.build are a splatted array seems to correct this issue.

bramswenson commented 11 years ago

ubuntu quantal 12.10 64bit, in gnome-terminal with zsh inside tmux

bramswenson commented 11 years ago

This is the primary change that mattered for me, pretty sure its zsh being particular:

# before
ChildProcess.build('bundle exec rake konacha:serve')
# after
ChildProcess.build('bundle', 'exec', 'rake', 'konacha:serve')
alexgb commented 11 years ago

It must be a difference in the interface for fork execute vs posix spawn within childprocess. I use zsh and it works fine.

bramswenson commented 11 years ago

Good call on the fork interface, sounds like a good "why" to me :) Thanks for merging.