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

- old
+ new

@@ -1,9 +1,10 @@ lib = File.dirname(File.dirname(__FILE__)) + '/lib' $:.unshift(lib) unless $:.include?(lib) -require 'test/unit' require 'rubygems' +gem "minitest" +require 'minitest/autorun' require 'fileutils' require 'yaml' require 'ruboto/sdk_versions' require 'ruboto/sdk_locations' require 'ruboto/util/update' @@ -105,11 +106,11 @@ RUBOTO_PLATFORM = ENV['RUBOTO_PLATFORM'] || 'CURRENT' puts "RUBOTO_PLATFORM: #{RUBOTO_PLATFORM}" if RUBOTO_PLATFORM == 'CURRENT' - JRUBY_JARS_VERSION = Gem::Version.new('1.7.12') + JRUBY_JARS_VERSION = Gem::Version.new('1.7.18') 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') @@ -126,20 +127,21 @@ 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 +class Minitest::Test include RubotoTest extend RubotoTest alias old_run run def run(*args, &block) - mark_test_start("#{self.class.name}\##{respond_to?(:method_name) ? method_name : __name__}") - old_run(*args, &block) - mark_test_end("#{self.class.name}\##{respond_to?(:method_name) ? method_name : __name__}") + mark_test_start("#{self.class.name}\##{name}") + result = old_run(*args, &block) + mark_test_end("#{self.class.name}\##{name}") + result end def mark_test_start(test_name) @start_time = Time.now log @@ -172,11 +174,11 @@ heap_alloc = options.delete(:heap_alloc) included_stdlibs = options.delete(:included_stdlibs) package = options.delete(:package) || PACKAGE standalone = options.delete(:standalone) || !!included_stdlibs || !!excluded_stdlibs || ENV['RUBOTO_PLATFORM'] == 'STANDALONE' update = options.delete(:update) || false - ruby_version = options.delete(:ruby_version) || (JRUBY_JARS_VERSION.to_s[0..0] == '9' ? 2.1 : 1.9) + ruby_version = options.delete(:ruby_version) || (JRUBY_JARS_VERSION.to_s[0..0] == '9' ? '2.2' : '1.9') raise "Unknown options: #{options.inspect}" unless options.empty? raise 'Inclusion/exclusion of libs requires standalone mode.' if (included_stdlibs || excluded_stdlibs) && !standalone Dir.mkdir TMP_DIR unless File.exists? TMP_DIR @@ -185,11 +187,11 @@ template_dir = "#{APP_DIR}_template_#{$$}" template_dir << "_package_#{package}" if package != PACKAGE template_dir << "_heap_alloc_#{heap_alloc}" if heap_alloc # template_dir << "_ruby_version_#{ruby_version.to_s.gsub('.', '_')}" if ruby_version template_dir << "_example_#{example}" if example - template_dir << "_bundle_#{[*bundle].join('_')}" if bundle + template_dir << "_bundle_#{[*bundle].map(&:to_s).join('_').gsub(/[{}\[\]'",:=~<>\/ ]+/, '_')}" if bundle template_dir << '_updated' if update template_dir << '_standalone' if standalone template_dir << "_without_#{excluded_stdlibs.map { |ed| ed.gsub(/[.\/]/, '_') }.join('_')}" if excluded_stdlibs template_dir << "_with_#{included_stdlibs.map { |ed| ed.gsub(/[.\/]/, '_') }.join('_')}" if included_stdlibs if File.exists?(template_dir) @@ -197,16 +199,17 @@ FileUtils.cp_r template_dir, APP_DIR, :preserve => true else if example Dir.chdir TMP_DIR do system "tar xzf #{PROJECT_DIR}/examples/#{APP_NAME}_#{example}.tgz" + Dir.chdir(APP_NAME) { system '../../bin/ruboto setup -y' } end Dir.chdir APP_DIR do File.open('local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" } File.open('test/local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" } if standalone - if included_stdlibs || excluded_stdlibs || heap_alloc || ruby_version + if included_stdlibs || excluded_stdlibs || heap_alloc write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version) end FileUtils.touch 'libs/jruby-core-x.x.x.jar' FileUtils.touch 'libs/jruby-stdlib-x.x.x.jar' install_jruby_jars_gem @@ -226,11 +229,11 @@ FileUtils.rm_rf APP_DIR raise "gen app failed with return code #$?" end Dir.chdir APP_DIR do write_gemfile(bundle) if bundle - if included_stdlibs || excluded_stdlibs || heap_alloc || ruby_version + if included_stdlibs || excluded_stdlibs || heap_alloc sleep 1 write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version) system 'rake build_xml jruby_adapter' end if standalone @@ -263,11 +266,11 @@ FileUtils.cp_r APP_DIR, template_dir, :preserve => true end end def update_app - system "#{RUBOTO_CMD} update app" + system "#{RUBOTO_CMD} update app #{"--with-jruby #{JRUBY_JARS_VERSION}" if RUBOTO_PLATFORM == 'STANDALONE'}" assert_equal 0, $?, "update app failed with return code #$?" end def cleanup_app # FileUtils.rm_rf APP_DIR if File.exists? APP_DIR @@ -305,24 +308,25 @@ fail 'Error (un)installing RubotoCore' 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, - }) + options = {} + options['included_stdlibs'] = included_stdlibs if included_stdlibs + options['excluded_stdlibs'] = excluded_stdlibs if excluded_stdlibs + options['ruby_version'] = ruby_version if ruby_version + options['heap_alloc'] = heap_alloc if heap_alloc + yml = YAML.dump(options) puts "Adding ruboto.yml:\n#{yml}" File.open('ruboto.yml', 'w') { |f| f << yml } end def write_gemfile(bundle) - gems = [*bundle] + gems = [*bundle].map{|g| g.is_a?(Symbol) ? g.to_s : g} puts "Adding Gemfile.apk: #{gems.join(' ')}" File.open('Gemfile.apk', 'w') do |f| f << "source 'http://rubygems.org/'\n\n" - gems.each { |g| f << "gem #{[*g].map { |gp| "'#{gp}'" }.join(', ')}\n" } + gems.each { |g| f << "gem #{[*g].map { |gp| (gp.is_a?(Symbol) ? gp.to_s : gp).inspect }.join(', ')}\n" } end end end