Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Compiling on Windows #188

Closed
wants to merge 12 commits into from

7 participants

@morenocarullo

It now compiles on Windows using its QT SDK:
http://qt.nokia.com/downloads/windows-cpp
There are 7 failing specs due to ImageMagick on Windows, and I'm looking into solving them.

Gemfile.lock
((11 lines not shown))
rack (1.3.2)
rack-test (0.6.1)
rack (>= 1.0)
- rake (0.9.2)
@jferris Owner
jferris added a note

Why did you downgrade rake?

Oh well, I had the Rake::DSL not found problem on my machine with 0.9.2.
I then forgot to fix that before commit, now I restored 0.9.2 and merged with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@morenocarullo morenocarullo Merge remote-tracking branch 'upstream/master'
Conflicts:
	lib/capybara/driver/webkit/browser.rb
4be10dc
lib/capybara/driver/webkit/browser.rb
((6 lines not shown))
end
end
end
+ def kill_process(pid)
+ if RUBY_PLATFORM =~ /mingw32/
+ Process.kill(9, pid)
@mike-burns Owner

Just for our edification, why 9 for mingw32 instead of the 2 (INT) we use elsewhere?

see comment below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@morenocarullo

If I try Process.kill(2, pid) on Windows (Vista) it says:

Invalid argument (Errno::EINVAL)

just as the string version of the signal.

@mike-burns
Owner

It'd be nice if we could get some input from another Windows user here.

Does this work? Do the tests pass?

@morenocarullo

The first commits had all green specs. With the additions of some specs, these 3 now fail:

Failures:

1) Capybara::Driver::Webkit::Browser forking only shuts down the server from the main process
Failure/Error: pid = fork {}
NotImplementedError:
fork() function is unimplemented on this machine
# ./spec/browser_spec.rb:87:in fork'
# ./spec/browser_spec.rb:87:in
block (3 levels) in '

2) Capybara::Driver::Webkit::Browser#set_proxy uses the proxies' response
Failure/Error: @proxy_requests.size.should == 2
expected: 2
got: 1 (using ==)
# ./spec/browser_spec.rb:138:in `block (3 levels) in '

3) Capybara::Driver::Webkit::Browser#set_proxy is possible to disable proxy again
Failure/Error: @proxy_requests.size.should == 2
expected: 2
got: 1 (using ==)
# ./spec/browser_spec.rb:138:in `block (3 levels) in '

for the first one, it is impossibile to get it work on Windows since it doesn't have fork. For the other two, I can hack on and see what's going wrong.

I think that if the Windows compilation compatibility gets into mainstream, the chance to have feedback from other Windows users will be higher.

@morenocarullo

An update on the set_proxy specs. It appears to be a race condition, in fact if I add a sleep(5) after line 140, all specs pass.

@halogenandtoast

I'd like to get his merged if possible. In order to do so I'll need a couple of things to happen. The forking test should be disabled using rspec metadata via checking the host os instead of wrapping it with the conditional, that way any additional tests that will need to be disabled can be. Also the race condition will need a better solution than sleep(5) :D.

@morenocarullo

Ok for rspec metadata I'll check how that works (I am not a rspec expert, using Test-unit most of the times).

For the race condition: I think the problem is not windows-related, and is certainly a test-related issue and not production-code-related issue. I was not able to really 'solve' the problem without reinventing the way the test is layed out.

@mtjhax

Moving this discussion from Issue #148 where it was somewhat off-topic.

I could not compile with the latest QT 4.8.0 libraries (also ruby 1.9.3p0 (2011-10-30) [i386-mingw32], and the latest DevKit 4.5.2-20111229-1559). I backed down Qt to version 4.7.4 per Moreno's instructions and it compiled with no problems.

For your info, the 4.8.0 error was as follows:

WebPage.cpp: In member function 'void WebPage::ignoreSslErrors(QNetworkReply*, const QList&)':
WebPage.cpp:199: error: no matching function for call to 'QNetworkReply::ignoreSslErrors(const QList&)'
../../../bin/Qt/4.8.0/include/QtNetwork/../../src/network/access/qnetworkreply.h:145: note: candidates are: virtual void QNetworkReply::ignoreSslErrors()

@morenocarullo

Thanks @mtjhax for your report. I didn't tried QT 4.8.0, and in fact I don't know if this is really Windows-specific. Otherwise we could update capybara-webkit's wiki to suggest the 4.7.x version for now.

@morenocarullo

Ok, now we can skip any kind of test with the :skip_on_windows => true metadata (@halogenandtoast, did you meant something different?).

The race condition I was noticing on Windows with Ruby 1.9.2 is no longer there with 1.9.3.p0: tried many many times -- beforewards it appeared almost every run.

@halogenandtoast

@morenocarullo Yeah that's what I meant with the meta data. If possible I'd like a few other windows users to chime in on this and confirm it compiles and passes the tests.

@mtjhax

Just confirming, I was able to compile on Windows with Qt 4.7.4 (and actually, capybara-webkit's wiki already says to use Qt 4.7.x -- I missed that when I was rushing headlong to try this out). One problem though -- I can compile but I can't seem to get the gem to install. We could cycle on what stupid thing I am doing, but it might be faster if someone could post a brief set of compile and install steps (assuming Qt is already installed).

@elestrade

Here is some feedback.
I have Windows XP, ruby 1.9.2, rails 3.1.3. I succeeded installing capybara-webkit and building my first test requiring javascript execution, this way :

  • in my gemfile: gem 'capybara-webkit', :git => 'git://github.com/morenocarullo/capybara-webkit.git' (on January, the 22th)
  • installing QT 4.7.4
  • As QT installation did not like (warning issued) the migwn version available in my RailsInstaller, I installed QT SDK and used included migwn.
  • With the QT default installation paths, I had to add to my PATH : C:\Qt\4.7.4\bin and C:\QtSDK\mingw\bin

Hope it helps.

@morenocarullo

Oh perfect @elestrade.

In my machine I use Windows Vista Professional, Ruby 1.9.3-p0 from RubyInstaller and QT 4.7.4. QT bin path is in PATH. Using the devkit from RubyInstaller the only thing to do manually before rake install is to launch the devkitvars.bat from devkit's root path.

@mewdriller

@morenocarullo: Thanks for creating your fork, I was able to get capybara-webkit installed properly using it.

For any windows users who happen upon this and keep getting an error like:

mingw32-make.exe: Interrupt/Exception caught (code = 0xc0000005, addr = 0x41f96e)

Check your path for anything being used in the build (ruby, msysgit, qt, mingw) and be sure NONE of them are installed in directories that have any parentheses in the directory. For whatever reason, that causes mingw32-make.exe to fail with that super helpful error message.

@mewdriller

@morenocarullo: Perhaps I spoke too soon. I'm new to capybara-webkit, so I have no idea if this is something specific to your fork or the gem in general... anyway, switching things over to run using the :webkit driver (following the steps here), it hangs after the first test in my suite. The following lines are in the console in RubyMine:

QSslSocket: cannot call unresolved function SSLv3_client_method
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error

If I switch back to the :selenium driver all the tests run properly, so it seems reasonably likely it's something with the :webkit driver setup.

@morenocarullo

@mewdriller, which version of QT did you install? Did you add the QT bin directory to system PATH? And, moreover, which Windows version and arch (32/64 bit) are you using?

@mewdriller

@morenocarullo, I have Qt 4.7.4 installed and on my PATH. I'm on Windows 7 64bit.

@morenocarullo

@mewdriller, I'm sorry but I don't have a 64bit Windows 7 to try the thing. However, maybe you can create here on github a minimal app & test project that hangs on your machine so we can see if it is something capybara-webkit related or windows7@64-bit specific.

@jferris
Owner

I'm going to close this pull request, since it's been a long time since the code has been updated and the build script has changed significantly. If there are general questions or discussion of compiler issues, please raise them on the mailing list: https://groups.google.com/forum/?fromgroups#!forum/capybara-webkit

@jferris jferris closed this
@morenocarullo

Dear @jferris, the problem is not about compilation. As you can see in the code, the problem is also related to os-specific functionalities.

I'm a little disappointed, and maybe all the other users working on Windows.

@jferris
Owner

@morenocarullo Based on the comments, it seems like it's still not functioning on Windows with this pull request. Is that not the case?

@jferris jferris reopened this
@morenocarullo

@jferris, as you can see, the thing is functioning correctly at least on Windows 32bit.
The comments are on this pull request and on #148.

@elestrade

"I'm a little disappointed, and maybe all the other users working on Windows."

Indeed.
If I understand well, we have three positive feedbacks (morenocarullo, mtjhax and I) and one negative (mewdriller). The problem of mewdriller is suspected to be linked to Windows 64bit.

Even if it is not perfect, it seems better that the situation of the master branch which can not be used at all on Windows (unless I missed a point?).

[all this beeing an humble remark as I am new to capyraba-webkit and also new to github]

@morenocarullo

yes, exactly @elestrade. If needed, I can sync my branch with capybara-webkit's master, with little effort.

@halogenandtoast

@morenocarullo I've merged this in. I squashed your commits and removed some of the whitespace changed you made in order to make the diff more clear as to what was happening. I've also added a note about window support in the README stating that only 32bit Windows is currently supported.

@halogenandtoast

@morenocarullo, @elestrade, @mtjhax: Could you let me know if master works correctly for you so when I release the next version of the gem I can have some additional confidence in the Windows changes - especially since I needed to alter some of the binary checking to match what we're currently doing.

@morenocarullo

See #300 for a small fix, thanks!
In the while I added an entry to the wiki for proper installation of QT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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
@@ -21,11 +21,13 @@ GEM
ffi (~> 1.0.6)
diff-lcs (1.1.2)
ffi (1.0.9)
+ ffi (1.0.9-x86-mingw32)
json_pure (1.6.1)
mime-types (1.16)
mini_magick (3.2.1)
subexec (~> 0.0.4)
nokogiri (1.5.0)
+ nokogiri (1.5.0-x86-mingw32)
rack (1.3.2)
rack-test (0.6.1)
rack (>= 1.0)
@@ -54,6 +56,7 @@ GEM
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
appraisal (~> 0.4.0)
View
29 lib/capybara/driver/webkit/browser.rb
@@ -2,6 +2,7 @@
require 'thread'
require 'capybara/util/timeout'
require 'json'
+require 'rbconfig'
class Capybara::Driver::Webkit
class Browser
@@ -9,9 +10,9 @@ class Browser
def initialize(options = {})
@socket_class = options[:socket_class] || TCPSocket
- @stdout = options.has_key?(:stdout) ?
- options[:stdout] :
- $stdout
+ @stdout = options.has_key?(:stdout) ?
+ options[:stdout] :
+ $stdout
@ignore_ssl_errors = options[:ignore_ssl_errors]
start_server
connect
@@ -113,7 +114,7 @@ def clear_cookies
end
def get_cookies
- command("GetCookies").lines.map{ |line| line.strip }.select{ |line| !line.empty? }
+ command("GetCookies").lines.map { |line| line.strip }.select { |line| !line.empty? }
end
def set_proxy(options = {})
@@ -147,11 +148,19 @@ 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
+ def kill_process(pid)
+ if RbConfig::CONFIG['host_os'] =~ /mingw32/
+ Process.kill(9, pid)
+ else
+ Process.kill("INT", pid)
+ end
+ end
+
def server_pipe_and_pid(server_path)
cmdline = [server_path]
cmdline << "--ignore-ssl-errors" if @ignore_ssl_errors
@@ -207,7 +216,7 @@ def check
if result.nil?
raise WebkitNoResponseError, "No response received from the server."
- elsif result != 'ok'
+ elsif result != 'ok'
raise WebkitInvalidResponseError, read_response
end
@@ -223,10 +232,10 @@ def read_response
def default_proxy_options
{
- :host => "localhost",
- :port => "0",
- :user => "",
- :pass => ""
+ :host => "localhost",
+ :port => "0",
+ :user => "",
+ :pass => ""
}
end
end
View
43 lib/capybara_webkit_builder.rb
@@ -4,21 +4,35 @@
module CapybaraWebkitBuilder
extend self
+ def has_binary?(binary)
+ case RbConfig::CONFIG['host_os']
+ when /mingw32/
+ system("#{binary} --version")
+ else
+ system("which #{make}")
+ end
+ end
+
def make_bin
make_binaries = ['gmake', 'make']
- make_binaries.detect { |make| system("which #{make}") }
+ make_binaries.detect { |make| has_binary?(make) }
end
- def makefile
+ def qmake_bin
qmake_binaries = ['qmake', 'qmake-qt4']
- qmake = qmake_binaries.detect { |qmake| system("which #{qmake}") }
+ qmake_binaries.detect { |qmake| has_binary?(qmake) }
+ end
+
+ def makefile
case RbConfig::CONFIG['host_os']
when /linux/
- system("#{qmake} -spec linux-g++")
+ system("#{qmake_bin} -spec linux-g++")
when /freebsd/
- system("#{qmake} -spec freebsd-g++")
+ system("#{qmake_bin} -spec freebsd-g++")
+ when /mingw32/
+ system("#{qmake_bin} -spec win32-g++")
else
- system("#{qmake} -spec macx-g++")
+ system("#{qmake_bin} -spec macx-g++")
end
end
@@ -26,16 +40,25 @@ def qmake
system("#{make_bin} qmake")
end
+ def path_to_binary
+ case RbConfig::CONFIG['host_os']
+ 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.mkdir("bin") unless File.directory?("bin")
+ FileUtils.cp(path_to_binary, "bin", :preserve => true)
end
def build_all
makefile &&
- qmake &&
- build
+ qmake &&
+ build
end
end
View
5 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 {}
@@ -95,7 +96,7 @@
@host = '127.0.0.1'
@user = 'user'
@pass = 'secret'
- @url = "http://example.org/"
+ @url = "http://example.org/"
@server = TCPServer.new(@host, 0)
@port = @server.addr[1]
View
11 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
@@ -10,12 +11,16 @@
spec_dir = nil
$:.detect do |dir|
if File.exists? File.join(dir, "capybara.rb")
- spec_dir = File.expand_path(File.join(dir,"..","spec"))
- $:.unshift( spec_dir )
+ spec_dir = File.expand_path(File.join(dir, "..", "spec"))
+ $:.unshift(spec_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)
Something went wrong with that request. Please try again.