Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow ENV to change make, qmake, and spec options. #267

Closed
wants to merge 2 commits into from

3 participants

@halogenandtoast

Alter the make, qmake, and spec options by changing ENV variables.

For example:

QMAKE=qmake-qt47 gem install capybara-webkit

or:

MAKE=gmake bundle exec rake build

Options that can be changed:

  • MAKE
  • QMAKE
  • SPEC
This was referenced
@chrismcg

I appreciate you don't want to have to keep a list of qmake names maintained but I don't think I can make this work with bundler. We'll need different commands based on whether we're using capybara-webkit locally (OS X) or on the CI server (Linux). I think we'll probably work round the odd name on CentOS with a symlink. I see this as a linux distro problem rather than a capybara-webkit problem :)

@halogenandtoast

You should be able to make it work with the following:

export MAKE=qmake-qt47
bundle install

@halogenandtoast

You also won't need different commands. Most CI servers allow you to setup ENV variables, so it should be a one time setup.

@chrismcg

Gotcha, yeah this should work. I'll try it out sometime later this week.

@biow0lf

+1

@halogenandtoast

Merged into master

@jferris jferris deleted the mm-make branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 10, 2012
  1. @halogenandtoast
Commits on Feb 17, 2012
  1. @biow0lf @halogenandtoast

    Fix capybara_webkit_builder specs

    biow0lf authored halogenandtoast committed
This page is out of date. Refresh to see the latest.
View
25 lib/capybara_webkit_builder.rb
@@ -5,23 +5,32 @@ module CapybaraWebkitBuilder
extend self
def make_bin
- make_binaries = ['gmake', 'make']
- make_binaries.detect { |make| system("which #{make}") }
+ ENV['MAKE'] || 'make'
end
- def makefile
- qmake_binaries = ['qmake', 'qmake-qt4']
- qmake = qmake_binaries.detect { |qmake| system("which #{qmake}") }
+ def qmake_bin
+ ENV['QMAKE'] || 'qmake'
+ end
+
+ def spec
+ ENV['SPEC'] || os_spec
+ end
+
+ def os_spec
case RbConfig::CONFIG['host_os']
when /linux/
- system("#{qmake} -spec linux-g++")
+ "linux-g++"
when /freebsd/
- system("#{qmake} -spec freebsd-g++")
+ "freebsd-g++"
else
- system("#{qmake} -spec macx-g++")
+ "macx-g++"
end
end
+ def makefile
+ system("#{qmake_bin} -spec #{spec}")
+ end
+
def qmake
system("#{make_bin} qmake")
end
View
37 spec/capybara_webkit_builder_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+require 'capybara_webkit_builder'
+
+describe CapybaraWebkitBuilder do
+ let(:builder) { CapybaraWebkitBuilder }
+
+ it "will use the env variable for #make_bin" do
+ with_env_vars("MAKE" => "fake_make") do
+ builder.make_bin.should == "fake_make"
+ end
+ end
+
+ it "will use the env variable for #qmake_bin" do
+ with_env_vars("QMAKE" => "fake_qmake") do
+ builder.qmake_bin.should == "fake_qmake"
+ end
+ end
+
+ it "will use the env variable for #os_spec" do
+ with_env_vars("SPEC" => "fake_os_spec") do
+ builder.spec.should == "fake_os_spec"
+ end
+ end
+
+ it "defaults the #make_bin" do
+ builder.make_bin.should == 'make'
+ end
+
+ it "defaults the #qmake_bin" do
+ builder.qmake_bin.should == 'qmake'
+ end
+
+ it "defaults #spec to the #os_specs" do
+ builder.spec.should == builder.os_spec
+ end
+end
+
View
14 spec/spec_helper.rb
@@ -23,3 +23,17 @@
Capybara.register_driver :reusable_webkit do |app|
Capybara::Driver::Webkit.new(app, :browser => $webkit_browser)
end
+
+def with_env_vars(vars)
+ old_env_variables = {}
+ vars.each do |key, value|
+ old_env_variables[key] = ENV[key]
+ ENV[key] = value
+ end
+
+ yield
+
+ old_env_variables.each do |key, value|
+ ENV[key] = value
+ end
+end
Something went wrong with that request. Please try again.