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

Compiling on Windows #188

Closed
wants to merge 12 commits into from
Closed

Compiling on Windows #188

wants to merge 12 commits into from

Conversation

morenocarullo
Copy link
Contributor

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.

rack (1.3.2)
rack-test (0.6.1)
rack (>= 1.0)
rake (0.9.2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you downgrade rake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Conflicts:
	lib/capybara/driver/webkit/browser.rb
end
end
end

def kill_process(pid)
if RUBY_PLATFORM =~ /mingw32/
Process.kill(9, pid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment below

@morenocarullo
Copy link
Contributor Author

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
Copy link
Contributor

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

Does this work? Do the tests pass?

@morenocarullo
Copy link
Contributor Author

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 <top (required)>'

  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 <top (required)>'

  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 <top (required)>'

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
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link

mtjhax commented Jan 17, 2012

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor

@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
Copy link

mtjhax commented Jan 27, 2012

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
Copy link

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
Copy link
Contributor Author

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
Copy link

@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
Copy link

@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
Copy link
Contributor Author

@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
Copy link

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

@morenocarullo
Copy link
Contributor Author

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

@morenocarullo
Copy link
Contributor Author

ping?

@jferris
Copy link
Contributor

jferris commented Mar 9, 2012

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 Mar 9, 2012
@morenocarullo
Copy link
Contributor Author

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
Copy link
Contributor

jferris commented Mar 9, 2012

@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 Mar 9, 2012
@morenocarullo
Copy link
Contributor Author

@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
Copy link

"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
Copy link
Contributor Author

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

@halogenandtoast
Copy link
Contributor

@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
Copy link
Contributor

@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
Copy link
Contributor Author

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants