Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Support compiling on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
morenocarullo authored and halogenandtoast committed Mar 16, 2012
1 parent 39be2c8 commit f09ba15
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,5 +1,5 @@
*.swp
bin/webkit_server
bin/webkit_server*
*.swo
*~
*.o
Expand All @@ -12,6 +12,8 @@ moc_*.cpp
.bundle
pkg
src/webkit_server
src/webkit_server.exe
.DS_Store
tmp
.rvmrc
src/debug
3 changes: 2 additions & 1 deletion 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

Expand Down Expand Up @@ -56,6 +56,7 @@ GEM

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
appraisal (~> 0.4.0)
Expand Down
10 changes: 9 additions & 1 deletion lib/capybara/driver/webkit/browser.rb
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion lib/capybara_webkit_builder.rb
Expand Up @@ -22,6 +22,8 @@ def os_spec
"linux-g++"
when /freebsd/
"freebsd-g++"
when /mingw32/
"win32-g++"
else
"macx-g++"
end
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/browser_spec.rb
Expand Up @@ -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 {}
Expand Down
7 changes: 6 additions & 1 deletion 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

Expand All @@ -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)
Expand Down

0 comments on commit f09ba15

Please sign in to comment.