CUTEn
Revision | 6423ad8a3b929dc250ab3e3a7774e61be2fe4286 (tree) |
---|---|
Time | 2013-01-10 13:54:14 |
Author | eagletmt <eagletmt@gmai...> |
Commiter | eagletmt |
Skip apk check if dexdump is not available
@@ -45,6 +45,9 @@ class Apk < ActiveRecord::Base | ||
45 | 45 | end |
46 | 46 | return if not apk_updated_at_changed? |
47 | 47 | |
48 | + # Skip apk check if dexdump is not available | |
49 | + return unless Rails.configuration.dexdump_path | |
50 | + | |
48 | 51 | path = apk.queued_for_write[:original].instance_variable_get(:@tempfile).to_path |
49 | 52 | buf = '' |
50 | 53 | status = Open4.popen4(Rails.configuration.dexdump_path.to_s, '-lxml', path) do |pid, stdin, stdout, stderr| |
@@ -10,5 +10,11 @@ ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | ||
10 | 10 | end |
11 | 11 | |
12 | 12 | CutenServer::Application.configure do |
13 | - config.dexdump_path = Pathname.new(ENV['ANDROID_HOME']).join('platform-tools', 'dexdump') | |
13 | + config.dexdump_path = | |
14 | + if ENV['ANDROID_HOME'] | |
15 | + path = Pathname.new(ENV['ANDROID_HOME']).join('platform-tools', 'dexdump') | |
16 | + if path.file? and path.executable? | |
17 | + path | |
18 | + end | |
19 | + end | |
14 | 20 | end |
@@ -7,12 +7,18 @@ class ApkTest < ActiveSupport::TestCase | ||
7 | 7 | end |
8 | 8 | |
9 | 9 | test 'reject wrong class name' do |
10 | + if not Rails.configuration.dexdump_path | |
11 | + skip 'dexdump is not available' | |
12 | + end | |
10 | 13 | apk = FactoryGirl.build :apk, :name => 'does.not.exist' |
11 | 14 | assert !apk.save |
12 | 15 | assert_not_empty apk.errors[:apk] |
13 | 16 | end |
14 | 17 | |
15 | 18 | test 'reject invalid apk file' do |
19 | + if not Rails.configuration.dexdump_path | |
20 | + skip 'dexdump is not available' | |
21 | + end | |
16 | 22 | file = fixture_file_upload 'dummy.apk' |
17 | 23 | apk = FactoryGirl.build :apk, :apk => file |
18 | 24 | assert !apk.save |