test/test_helper.rb in ruboto-0.8.1 vs test/test_helper.rb in ruboto-0.9.0.rc.0
- old
+ new
@@ -1,6 +1,7 @@
-$:.unshift('lib') unless $:.include?('lib')
+lib = File.dirname(File.dirname(__FILE__)) + '/lib'
+$:.unshift(lib) unless $:.include?(lib)
require 'test/unit'
require 'rubygems'
require 'fileutils'
require 'yaml'
require 'ruboto/sdk_versions'
@@ -57,14 +58,21 @@
end
raise "Unable to read device/emulator apilevel"
end
def self.install_jruby_jars_gem
- jars_version_from_env = ENV['JRUBY_JARS_VERSION']
- version_requirement = "-v #{jars_version_from_env}" if jars_version_from_env
- `gem query -i -n jruby-jars #{version_requirement}`
- system "gem install #{jars_version_from_env.nil? || !File.exists?("jruby-jars-#{jars_version_from_env}.gem") ? '-r' : '-l'} jruby-jars #{version_requirement} --no-ri --no-rdoc" unless $? == 0
+ 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
+ system "gem install -r jruby-jars#{version_requirement} --no-ri --no-rdoc"
+ 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
@@ -101,26 +109,31 @@
RUBOTO_CMD = "ruby -rubygems -I #{PROJECT_DIR}/lib #{PROJECT_DIR}/bin/ruboto"
puts "ANDROID_HOME: #{ANDROID_HOME}"
puts "ANDROID_SDK_TOOLS_REVISION: #{ANDROID_TOOLS_REVISION}"
+ RUBOTO_PLATFORM = ENV['RUBOTO_PLATFORM'] || 'CURRENT'
+ puts "RUBOTO_PLATFORM: #{RUBOTO_PLATFORM}"
+
install_jruby_jars_gem
- # 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'
+ if RUBOTO_PLATFORM == 'CURRENT'
+ JRUBY_JARS_VERSION = Gem::Version.new('1.7.0.dev')
else
- gem_spec = Gem.searcher.find('jruby-jars')
+ # 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
+ gem_spec = Gem.searcher.find('jruby-jars')
+ end
+ # EMXIF
+
+ raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
+ JRUBY_JARS_VERSION = gem_spec.version
end
- # EMXIF
- raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
- JRUBY_JARS_VERSION = gem_spec.version
puts "JRUBY_JARS_VERSION: #{JRUBY_JARS_VERSION}"
-
- RUBOTO_PLATFORM = ENV['RUBOTO_PLATFORM'] || 'CURRENT'
- puts "RUBOTO_PLATFORM: #{RUBOTO_PLATFORM}"
end
class Test::Unit::TestCase
include RubotoTest
extend RubotoTest
@@ -185,11 +198,11 @@
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'
else
- FileUtils.rm(Dir['libs/{jruby-*.jar,dexmaker*.jar}'])
+ FileUtils.rm(Dir['libs/{jruby-*.jar,dx.jar}'])
end
update_app if update
end
else
uninstall_jruby_jars_gem unless standalone
@@ -207,16 +220,16 @@
raise "update jruby failed with return code #$?" if $? != 0
end
end
end
- # FIXME(uwe): Installation with dexmaker fails on Android < 4.0.3 due to complex interface structure
+ # FIXME(uwe): Installation with dx.jar fails on Android < 4.0.3 due to complex interface structure
# Fixme(uwe): Remove when solved
#if standalone && ANDROID_OS < 15
# Dir.chdir APP_DIR do
- # puts "Removing dexmaker jar for android-#{ANDROID_OS}"
- # FileUtils.rm(Dir['libs/dexmaker*.jar'])
+ # puts "Removing dx.jar for android-#{ANDROID_OS}"
+ # FileUtils.rm(Dir['libs/dx.jar'])
# end
#end
# EMXIF
unless example && !update
@@ -242,11 +255,11 @@
def run_app_tests
if [7, 8].include? ANDROID_OS
puts "Skipping instrumentation tests on #{ANDROID_OS} since they don't work."
return
end
- check_platform_installation(Dir['libs/jruby-core-*.jar'].any?)
+ check_platform_installation
Dir.chdir APP_DIR do
# FIXME(uwe): Simplify when we stop supporting JRuby < 1.7.0 which causes the ArrayIndexOutOfBoundsException
# FIXME(uwe): Simplify if we find a cause for the system crashes.
# system 'rake test:quick' # This line should replace all those below.
@@ -272,18 +285,18 @@
assert_equal 0, $?, "tests failed with return code #$?"
end
end
- def check_platform_installation(standalone)
- if standalone
+ def check_platform_installation
+ if RUBOTO_PLATFORM == 'STANDALONE'
system 'rake platform:uninstall'
+ elsif RUBOTO_PLATFORM == 'CURRENT'
+ system "rake platform:current platform:install"
+ elsif RUBOTO_PLATFORM == 'FROM_GEM'
+ system "rake platform:debug platform:install"
else
- if RUBOTO_PLATFORM == 'CURRENT'
- system "rake platform:current platform:install"
- elsif RUBOTO_PLATFORM == 'FROM_GEM'
- system "rake platform:debug platform:install"
- end
+ fail "Unknown Ruboto platform: #{RUBOTO_PLATFORM.inspect}"
end
if $? != 0
FileUtils.rm_rf 'tmp/RubotoCore'
fail 'Error (un)installing RubotoCore'
end