Permalink
Browse files

* Allow running only selected activity tests

* Improved matrix_tests.sh
* Prepare for dx.jar update.
  • Loading branch information...
1 parent 4eaa1b3 commit 7a0dc62cd2ffd42bc1538a4d1367e48d77d7854c @donv donv committed Nov 14, 2012
Showing with 121 additions and 23 deletions.
  1. +10 −3 lib/DexClient.java
  2. +4 −1 lib/ruboto/util/update.rb
  3. +82 −10 matrix_tests.sh
  4. +15 −7 test/app_test_methods.rb
  5. +10 −2 test_jruby.sh
View
@@ -4,6 +4,8 @@
import java.io.OutputStreamWriter;
import com.android.dx.cf.iface.ParseException;
+// import com.android.dx.dex.DexFormat;
+// import com.android.dx.dex.DexOptions;
import com.android.dx.dex.cf.CfOptions;
import com.android.dx.dex.cf.CfTranslator;
import com.android.dx.dex.code.PositionList;
@@ -13,11 +15,15 @@
public class DexClient {
/** {@code non-null;} output file in-progress */
private static DexFile outputDex;
-
+ // private static DexOptions dexOptions = new DexOptions();
+ // static {
+ // dexOptions.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
+ // }
private final CfOptions cfOptions;
public DexClient() {
outputDex = new DexFile();
+ // outputDex = new DexFile(dexOptions);
cfOptions = new CfOptions();
cfOptions.positionInfo = PositionList.LINES;
@@ -51,8 +57,9 @@ public DexClient() {
*/
private boolean processClass(String name, byte[] bytes) {
try {
- ClassDefItem clazz =
- CfTranslator.translate(name, bytes, cfOptions);
+ ClassDefItem clazz;
+ clazz = CfTranslator.translate(name, bytes, cfOptions);
+ // clazz = CfTranslator.translate(name, bytes, cfOptions, dexOptions);
outputDex.add(clazz);
return true;
} catch (ParseException ex) {
@@ -172,7 +172,10 @@ def update_jruby(force=nil, explicit = false)
# FIXME(uwe): Try keeping the class count low to enable installation on Android 2.3 devices
# unless new_jruby_version =~ /^1.7.0/ && verify_target_sdk < 15
- log_action("Copying dx.jar to libs") { copier.copy 'libs' }
+ log_action("Copying dx.jar to libs") do
+ copier.copy 'libs'
+ # File.open('project.properties', 'a'){|f| f << "dex.force.jumbo=true\n"}
+ end
# end
reconfigure_jruby_libs(new_jruby_version)
View
@@ -1,26 +1,94 @@
#!/bin/bash -e
+PLATFORM_MODES="STANDALONE FROM_GEM CURRENT"
+PLATFORM_MODES="STANDALONE FROM_GEM"
MASTER=1.7.1.dev
+STANDALONE_JRUBY_VERSIONS="$MASTER 1.7.0 1.6.8 1.6.7.2"
+STANDALONE_JRUBY_VERSIONS="$MASTER"
export ANDROID_TARGET ANDROID_OS JRUBY_JARS_VERSION RUBOTO_PLATFORM
export SKIP_RUBOTO_UPDATE_TEST=1
+EMULATOR_CMD=emulator64-arm
+
for ANDROID_TARGET in 10 15 ; do
ANDROID_OS=$ANDROID_TARGET
+ while :; do
set +e
- killall emulator64-arm
- sleep 5
- killall -9 emulator64-arm
- sleep 1
- set -e
+ killall -0 $EMULATOR_CMD 2> /dev/null
+ if [ "$?" == "0" ] ; then
+ killall $EMULATOR_CMD
+ sleep 2
+ for i in 1 2 3 4 5 6 7 8 9 10 ; do
+ killall -0 $EMULATOR_CMD 2> /dev/null
+ if [ "$?" != "0" ] ; then
+ break
+ fi
+ echo "Waiting for emulator to die"
+ sleep 1
+ done
+ killall -0 $EMULATOR_CMD 2> /dev/null
+ if [ "$?" == "0" ] ; then
+ echo "Emulator still running."
+ killall -9 $EMULATOR_CMD
+ sleep 1
+ fi
+ fi
+
if [ "$ANDROID_TARGET" == "15" ] ; then
avd="Android_4.0.3"
elif [ "$ANDROID_TARGET" == "10" ] ; then
avd="Android_2.3.3"
fi
- emulator -avd $avd &
- adb wait-for-device
+ set -e
+ echo Start emulator
+ emulator -avd $avd &
+
+ set +e
+ for i in 1 2 3 ; do
+ sleep 1
+ killall -0 $EMULATOR_CMD 2> /dev/null
+ if [ "$?" == "0" ] ; then
+ break
+ fi
+ echo "Waiting for emulator"
+ done
+
+ killall -0 $EMULATOR_CMD 2> /dev/null
+ if [ "$?" != "0" ] ; then
+ echo "Unable to start the emulator. Retrying without loading snapshot."
+ set -e
+ emulator -no-snapshot-load -avd $avd &
+ set +e
+ for i in 1 2 3 4 5 6 7 8 9 10 ; do
+ sleep 1
+ killall -0 $EMULATOR_CMD 2> /dev/null
+ if [ "$?" == "0" ] ; then
+ break
+ fi
+ echo "Waiting for emulator"
+ done
+ fi
+
+ killall -0 $EMULATOR_CMD 2> /dev/null
+ if [ "$?" == "0" ] ; then
+ echo "Emulator started."
+ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 ; do
+ sleep 1
+ if [ `adb get-state` == "device" ] ; then
+ break
+ fi
+ echo Waiting for device: $i
+ done
+ if [ `adb get-state` == "device" ] ; then
+ break
+ fi
+ fi
+ echo "Unable to start the emulator."
+ done
+ set -e
+
adb logcat > adb_logcat.log &
(
@@ -31,6 +99,8 @@ for ANDROID_TARGET in 10 15 ; do
if [ "$?" == "0" ] ; then
echo "Unlocked screen"
set -e
+ adb shell input keyevent 82 >/dev/null 2>&1
+ adb shell input keyevent 4 >/dev/null 2>&1
exit 0
fi
done
@@ -39,9 +109,9 @@ for ANDROID_TARGET in 10 15 ; do
exit 1
) &
- for RUBOTO_PLATFORM in CURRENT FROM_GEM STANDALONE ; do
+ for RUBOTO_PLATFORM in $PLATFORM_MODES ; do
if [ "$RUBOTO_PLATFORM" == "STANDALONE" ] ; then
- jruby_versions="$MASTER 1.6.8 1.6.7.2"
+ jruby_versions=$STANDALONE_JRUBY_VERSIONS
elif [ "$RUBOTO_PLATFORM" == "FROM_GEM" ] ; then
jruby_versions="$MASTER"
elif [ "$RUBOTO_PLATFORM" == "CURRENT" ] ; then
@@ -50,6 +120,8 @@ for ANDROID_TARGET in 10 15 ; do
for JRUBY_JARS_VERSION in $jruby_versions ; do
if [ $RUBOTO_PLATFORM == "CURRENT" ] ; then
unset JRUBY_JARS_VERSION
+ elif [ $RUBOTO_PLATFORM == "FROM_GEM" ] ; then
+ rake platform:clean
fi
echo ""
echo "********************************************************************************"
@@ -61,7 +133,7 @@ for ANDROID_TARGET in 10 15 ; do
./run_tests.sh
# ruby test/minimal_app_test.rb
# ruby test/ruboto_gen_test.rb -n test_new_apk_size_is_within_limits
- # ruby test/ruboto_gen_test.rb -n test_activity_tests
+ # ACTIVITY_TEST_PATTERN=subclass ruby test/ruboto_gen_test.rb -n test_activity_tests
# ruby test/ruboto_gen_test.rb -n test_handle_activity_tests
# ruby test/ruboto_gen_test.rb -n test_activity_with_first_letter_lower_case_in_name
done
View
@@ -4,11 +4,18 @@ module AppTestMethods
include RubotoTest
def test_activity_tests
- assert_code 'Base64Loads', "require 'base64'"
- assert_code 'YamlLoads', "require 'ruboto/util/stack' ; with_large_stack{require 'yaml'}"
- assert_code 'ReadSourceFile', 'File.read(__FILE__)'
- assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
- assert_code 'RepeatRubotoImportWidget', 'ruboto_import_widget :TextView ; ruboto_import_widget :TextView'
+ if ENV['ACTIVITY_TEST_PATTERN']
+ Dir.chdir APP_DIR do
+ FileUtils.rm "src/ruboto_test_app_activity.rb"
+ FileUtils.rm "test/src/ruboto_test_app_activity_test.rb"
+ end
+ else
+ assert_code 'Base64Loads', "require 'base64'"
+ assert_code 'YamlLoads', "require 'ruboto/util/stack' ; with_large_stack{require 'yaml'}"
+ assert_code 'ReadSourceFile', 'File.read(__FILE__)'
+ assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
+ assert_code 'RepeatRubotoImportWidget', 'ruboto_import_widget :TextView ; ruboto_import_widget :TextView'
+ end
run_activity_tests('activity')
end
@@ -28,7 +35,7 @@ def test_handle_activity_tests
def assert_code(activity_name, code)
snake_name = activity_name.scan(/[A-Z]+[a-z0-9]+/).map { |s| s.downcase }.join('_')
- filename = "src/#{snake_name}_activity.rb"
+ filename = "src/#{snake_name}_activity.rb"
Dir.chdir APP_DIR do
system "#{RUBOTO_CMD} gen class Activity --name #{activity_name}Activity"
s = File.read(filename)
@@ -39,7 +46,8 @@ def assert_code(activity_name, code)
def run_activity_tests(activity_dir)
Dir[File.expand_path("#{activity_dir}/*_test.rb", File.dirname(__FILE__))].each do |test_src|
- snake_name = test_src.chomp('_test.rb')
+ snake_name = test_src.chomp('_test.rb')
+ next unless snake_name =~ /#{ENV['ACTIVITY_TEST_PATTERN']}/
# FIXME(uwe): Remove when we stop testing JRuby < 1.7.0.rc1
next if snake_name =~ /subclass/ && (RUBOTO_PLATFORM == 'CURRENT' || JRUBY_JARS_VERSION < Gem::Version.new('1.7.0.rc1'))
View
@@ -1,6 +1,6 @@
#!/bin/bash
-# This script can be run with "git bisect run" to determine which JRuby commit broke the tests
+# This script can be run with "git bisect run" to determine which JRuby commit broke the tests.
# Change the test run at the bottom to narrow down the test and make it faster.
# cd ../jruby
# git bisect start
@@ -22,6 +22,8 @@ if [ ! -e "LICENSE.RUBY" ] ; then
exit 1
fi
+echo Remaining suspects: `git bisect view | grep "Date:" | wc -l`
+
ant clean-all dist-gem
build_status=$?
@@ -61,15 +63,21 @@ rm -rf tmp/Ruboto*
set +e
+./matrix_tests.sh
+# ./run_tests.sh
# ruby test/broadcast_receiver_test.rb -n test_generated_broadcast_receiver
-ruby test/ruboto_gen_test.rb -n test_activity_tests
+# ACTIVITY_TEST_PATTERN=subclass ruby test/ruboto_gen_test.rb -n test_activity_tests
# ruby test/ruboto_gen_test.rb -n test_block_def_activity_tests
test_status=$?
+echo
+echo "********************************************************************************"
if [ $test_status -eq 0 ] ; then
echo Bisect GOOD.
else
echo Bisect BAD.
fi
+echo "********************************************************************************"
+echo
exit $test_status

0 comments on commit 7a0dc62

Please sign in to comment.