test/test_helper.rb in ruboto-1.1.2 vs test/test_helper.rb in ruboto-1.2.0

- old
+ new

@@ -14,17 +14,20 @@ include Ruboto::Util::Update PROJECT_DIR = File.expand_path('..', File.dirname(__FILE__)) $LOAD_PATH << PROJECT_DIR - GEM_PATH = File.join PROJECT_DIR, 'tmp', 'gems' - FileUtils.mkdir_p GEM_PATH - ENV['GEM_HOME'] = GEM_PATH - ENV['GEM_PATH'] = GEM_PATH - ENV['PATH'] = "#{GEM_PATH}/bin:#{ENV['PATH']}" - Gem.paths = GEM_PATH - Gem.refresh + unless File.writable?(ENV['GEM_HOME']) + GEM_PATH = File.join PROJECT_DIR, 'tmp', 'gems' + FileUtils.mkdir_p GEM_PATH + ENV['GEM_HOME'] = GEM_PATH + ENV['GEM_PATH'] = GEM_PATH + ENV['PATH'] = "#{GEM_PATH}/bin:#{ENV['PATH']}" + Gem.paths = GEM_PATH + Gem.refresh + end + `gem query -i -n bundler` system 'gem install bundler --no-ri --no-rdoc' unless $? == 0 `bundle check` system 'bundle --system' unless $? == 0 lib_path = File.expand_path('lib', File.dirname(File.dirname(__FILE__))) @@ -34,12 +37,19 @@ PACKAGE = 'org.ruboto.test_app' APP_NAME = 'RubotoTestApp' TMP_DIR = File.join PROJECT_DIR, 'tmp' APP_DIR = File.join TMP_DIR, APP_NAME - ANDROID_TARGET = (ENV['ANDROID_TARGET'] && ENV['ANDROID_TARGET'].slice(/\d+/).to_i) || MINIMUM_SUPPORTED_SDK_LEVEL + # FIXME(uwe): Remove special case when Android L has been released. + if (ENV['ANDROID_TARGET'] && ENV['ANDROID_TARGET'] =~ /(?:android-)?L/) + ANDROID_TARGET = 'L' + else + ANDROID_TARGET = (ENV['ANDROID_TARGET'] && ENV['ANDROID_TARGET'].slice(/\d+/).to_i) || MINIMUM_SUPPORTED_SDK_LEVEL + end + # EMXIF + def self.version_from_device puts 'Reading OS version from device/emulator' system 'adb wait-for-device' IO.popen('adb bugreport').each_line do |line| if line =~ /sdk-eng (.*?) .*? .*? test-keys/ @@ -78,10 +88,15 @@ end puts RUBY_DESCRIPTION ANDROID_OS = (ENV['ANDROID_OS'] || version_from_device).slice(/\d+/).to_i + + # FIXME(uwe): Remove when Android L has been released + ANDROID_OS = 21 if ANDROID_OS == 0 + # EMXIF + puts "ANDROID_OS: #{ANDROID_OS}" puts "ANDROID_TARGET: #{ANDROID_TARGET}" RUBOTO_CMD = "ruby -rubygems -I #{PROJECT_DIR}/lib #{PROJECT_DIR}/bin/ruboto" @@ -227,20 +242,23 @@ Dir.chdir APP_DIR do File.write('AndroidManifest.xml', File.read('AndroidManifest.xml').sub(%r{</manifest>}, " <uses-permission android:name='android.permission.INTERNET'/>\n</manifest>")) + File.write('res/layout/dummy_layout.xml', <<-EOF) +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/my_text" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="This is a dummy layout to generate layout and id constants." /> + EOF if update update_app end if update || !example - system 'rake patch_dex' # Ensure dx heap space is sufficient. + system 'rake --trace debug' # Ensure dx heap space is sufficient. assert_equal 0, $? - Dir.chdir 'test' do - system 'ant instrument' # This will also build the main project. - assert_equal 0, $? - end end end puts "Storing app as template #{template_dir}" FileUtils.cp_r APP_DIR, template_dir, :preserve => true end @@ -257,18 +275,18 @@ def run_app_tests check_platform_installation test_completed = false Thread.start do - loop do - sleep 60 + 4.times do + sleep 600 break if test_completed - print '-' + puts '...' end end Dir.chdir APP_DIR do - system 'rake test:quick' + system 'rake --trace test:quick' assert_equal 0, $?, "tests failed with return code #$?" end test_completed = true end @@ -288,13 +306,13 @@ end end def write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version) yml = YAML.dump({'included_stdlibs' => included_stdlibs, - 'excluded_stdlibs' => excluded_stdlibs, - # 'ruby_version' => ruby_version, - 'heap_alloc' => heap_alloc, - }) + 'excluded_stdlibs' => excluded_stdlibs, + # 'ruby_version' => ruby_version, + 'heap_alloc' => heap_alloc, + }) puts "Adding ruboto.yml:\n#{yml}" File.open('ruboto.yml', 'w') { |f| f << yml } end def write_gemfile(bundle)