test/test_helper.rb in ruboto-0.14.0 vs test/test_helper.rb in ruboto-0.15.0

- old
+ new

@@ -4,14 +4,16 @@ require 'rubygems' require 'fileutils' require 'yaml' require 'ruboto/sdk_versions' require 'ruboto/sdk_locations' +require 'ruboto/util/update' module RubotoTest include Ruboto::SdkVersions include Ruboto::SdkLocations + include Ruboto::Util::Update PROJECT_DIR = File.expand_path('..', File.dirname(__FILE__)) $LOAD_PATH << PROJECT_DIR GEM_PATH = File.join PROJECT_DIR, 'tmp', 'gems' @@ -51,44 +53,23 @@ end end raise 'Unable to read device/emulator apilevel' end - def self.install_jruby_jars_gem - jars_version_from_env = ENV['JRUBY_JARS_VERSION'] unless RUBOTO_PLATFORM == 'CURRENT' - version_requirement = " -v #{jars_version_from_env}" if jars_version_from_env - `gem query -i -n jruby-jars#{version_requirement}` - unless $? == 0 - local_gem_file = "jruby-jars-#{jars_version_from_env}.gem" - if File.exists?(local_gem_file) - system "gem install -l #{local_gem_file} --no-ri --no-rdoc" - else - Dir.chdir('tmp') do - system "gem install -r jruby-jars#{version_requirement} --no-ri --no-rdoc" - end - end - end - raise "install of jruby-jars failed with return code #$?" unless $? == 0 - if jars_version_from_env - exclusion_clause = %Q{-v "!=#{jars_version_from_env}"} - `gem query -i -n jruby-jars #{exclusion_clause}` - if $? == 0 - system %Q{gem uninstall jruby-jars --all #{exclusion_clause}} - raise "Uninstall of jruby-jars failed with return code #$?" unless $? == 0 - end - end - Gem.refresh + def uninstall_jruby_jars_gem + uninstall_ruboto_gem + uninstall_gem('jruby-jars') end - def install_jruby_jars_gem - RubotoTest::install_jruby_jars_gem + def uninstall_ruboto_gem + uninstall_gem('ruboto') end - def uninstall_jruby_jars_gem - `gem query --no-installed -n jruby-jars` - system 'gem uninstall jruby-jars --all' if $? != 0 - assert_equal 0, $?, "uninstall of jruby-jars failed with return code #$?" + def uninstall_gem(name) + `gem query --no-installed -n #{name}` + system "gem uninstall -x --all #{name}" if $? != 0 + assert_equal 0, $?, "uninstall of #{name} failed with return code #$?" end def install_ruboto_gem(version) version_requirement = "-v #{version}" `gem query -i -n ^ruboto$ #{version_requirement}` @@ -108,14 +89,14 @@ puts "ANDROID_SDK_TOOLS_REVISION: #{ANDROID_TOOLS_REVISION}" RUBOTO_PLATFORM = ENV['RUBOTO_PLATFORM'] || 'CURRENT' puts "RUBOTO_PLATFORM: #{RUBOTO_PLATFORM}" - install_jruby_jars_gem unless RUBOTO_PLATFORM == 'CURRENT' - if RUBOTO_PLATFORM == 'CURRENT' - JRUBY_JARS_VERSION = Gem::Version.new('1.7.3') + JRUBY_JARS_VERSION = Gem::Version.new('1.7.4') + elsif ENV['JRUBY_JARS_VERSION'] + JRUBY_JARS_VERSION = Gem::Version.new(ENV['JRUBY_JARS_VERSION']) else # FIXME(uwe): Simplify when we stop supporting rubygems < 1.8.0 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0') gem_spec = Gem::Specification.find_by_path 'jruby-jars' else @@ -126,10 +107,12 @@ raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec JRUBY_JARS_VERSION = gem_spec.version end puts "JRUBY_JARS_VERSION: #{JRUBY_JARS_VERSION}" + ENV['JRUBY_JARS_VERSION'] = JRUBY_JARS_VERSION.to_s + ENV['LOCAL_GEM_DIR'] = Dir.getwd end class Test::Unit::TestCase include RubotoTest extend RubotoTest @@ -186,12 +169,10 @@ template_dir << "_with_#{included_stdlibs.map { |ed| ed.gsub(/[.\/]/, '_') }.join('_')}" if included_stdlibs if File.exists?(template_dir) puts "Copying app from template #{template_dir}" FileUtils.cp_r template_dir, APP_DIR, :preserve => true else - install_jruby_jars_gem - if example Dir.chdir TMP_DIR do system "tar xzf #{PROJECT_DIR}/examples/#{APP_NAME}_#{example}.tgz" end Dir.chdir APP_DIR do @@ -199,17 +180,22 @@ File.open('test/local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" } if standalone exclude_stdlibs(excluded_stdlibs) if excluded_stdlibs FileUtils.touch 'libs/jruby-core-x.x.x.jar' FileUtils.touch 'libs/jruby-stdlib-x.x.x.jar' + install_jruby_jars_gem else FileUtils.rm(Dir['libs/{jruby-*.jar,dx.jar}']) end update_app if update end else - uninstall_jruby_jars_gem unless standalone + if standalone + install_jruby_jars_gem + else + uninstall_jruby_jars_gem + end puts "Generating app #{APP_DIR}" system "#{RUBOTO_CMD} gen app --package #{package} --path #{APP_DIR} --name #{APP_NAME} --target android-#{ANDROID_TARGET}" if $? != 0 FileUtils.rm_rf APP_DIR raise "gen app failed with return code #$?" @@ -295,10 +281,10 @@ def write_gemfile(bundle) gems = [*bundle] puts "Adding Gemfile.apk: #{gems.join(' ')}" File.open('Gemfile.apk', 'w') do |f| - f << "source 'https://rubygems.org/'\n\n" + f << "source 'http://rubygems.org/'\n\n" gems.each{|g| f << "gem '#{g}'\n"} end end end