Skip to content
Browse files

Support compiling on windows.

  • Loading branch information...
1 parent 39be2c8 commit f09ba1563793845db4b725ba36700bca70f78dbf @morenocarullo morenocarullo committed with halogenandtoast Oct 6, 2011
Showing with 34 additions and 6 deletions.
  1. +3 −1 .gitignore
  2. +2 −1 Gemfile.lock
  3. +9 −1 lib/capybara/driver/webkit/browser.rb
  4. +12 −1 lib/capybara_webkit_builder.rb
  5. +2 −1 spec/browser_spec.rb
  6. +6 −1 spec/spec_helper.rb
View
4 .gitignore
@@ -1,5 +1,5 @@
*.swp
-bin/webkit_server
+bin/webkit_server*
*.swo
*~
*.o
@@ -12,6 +12,8 @@ moc_*.cpp
.bundle
pkg
src/webkit_server
+src/webkit_server.exe
.DS_Store
tmp
.rvmrc
+src/debug
View
3 Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- capybara-webkit (0.10.1)
+ capybara-webkit (0.11.0)
capybara (>= 1.0.0, < 1.2)
json
@@ -56,6 +56,7 @@ GEM
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
appraisal (~> 0.4.0)
View
10 lib/capybara/driver/webkit/browser.rb
@@ -147,11 +147,19 @@ def fork_server
pipe
end
+ def kill_process(pid)
+ if RUBY_PLATFORM =~ /mingw32/
+ Process.kill(9, pid)
+ else
+ Process.kill("INT", pid)
+ end
+ end
+
def register_shutdown_hook
@owner_pid = Process.pid
at_exit do
if Process.pid == @owner_pid
- Process.kill("INT", @pid)
+ kill_process(@pid)
end
end
end
View
13 lib/capybara_webkit_builder.rb
@@ -22,6 +22,8 @@ def os_spec
"linux-g++"
when /freebsd/
"freebsd-g++"
+ when /mingw32/
+ "win32-g++"
else
"macx-g++"
end
@@ -35,11 +37,20 @@ def qmake
system("LANG='en_US.UTF-8' #{make_bin} qmake")
end
+ def path_to_binary
+ case RUBY_PLATFORM
+ when /mingw32/
+ "src/debug/webkit_server.exe"
+ else
+ "src/webkit_server"
+ end
+ end
+
def build
system(make_bin) or return false
FileUtils.mkdir("bin") unless File.directory?("bin")
- FileUtils.cp("src/webkit_server", "bin", :preserve => true)
+ FileUtils.cp(path_to_binary, "bin", :preserve => true)
end
def build_all
View
3 spec/browser_spec.rb
@@ -81,7 +81,8 @@
browser_ignore_ssl_err.visit "https://#{@host}:#{@port}/"
end
end
- describe "forking" do
+
+ describe "forking", :skip_on_windows => true do
it "only shuts down the server from the main process" do
browser.reset!
pid = fork {}
View
7 spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rspec'
require 'rspec/autorun'
+require 'rbconfig'
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
@@ -15,7 +16,11 @@
end
end
-require File.join(spec_dir,"spec_helper")
+RSpec.configure do |c|
+ c.filter_run_excluding :skip_on_windows => !(RbConfig::CONFIG['host_os'] =~ /mingw32/).nil?
+end
+
+require File.join(spec_dir, "spec_helper")
require 'capybara/driver/webkit/browser'
$webkit_browser = Capybara::Driver::Webkit::Browser.new(:socket_class => TCPSocket, :stdout => nil)

0 comments on commit f09ba15

Please sign in to comment.
Something went wrong with that request. Please try again.