Support compiling on windows.

This commit is contained in:
Moreno Carullo 2011-10-06 17:07:20 +02:00 committed by Matthew Mongeau
parent 39be2c8474
commit f09ba15637
6 changed files with 34 additions and 6 deletions

4
.gitignore vendored
View File

@ -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 File

@ -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 File

@ -147,11 +147,19 @@ class Capybara::Driver::Webkit
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 File

@ -22,6 +22,8 @@ module CapybaraWebkitBuilder
"linux-g++"
when /freebsd/
"freebsd-g++"
when /mingw32/
"win32-g++"
else
"macx-g++"
end
@ -35,11 +37,20 @@ module CapybaraWebkitBuilder
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 File

@ -81,7 +81,8 @@ describe Capybara::Driver::Webkit::Browser do
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 File

@ -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 @@ $:.detect do |dir|
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)