aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt
diff options
context:
space:
mode:
authorGravatar ajmichael <ajmichael@google.com>2017-06-29 01:29:19 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-06-29 09:33:56 +0200
commit8355237f65842d9df45b51cdfaebda9bb44c3a79 (patch)
tree79d43aa21145a3184ebba3aa4d08d925dfca2d0a /src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt
parentc1e0d7b9f6bfa8df950980f9370c638443d361e1 (diff)
Introduce new android_instrumentation_test rule.
This rule works with the android_instrumentation, android_device_script_fixture and android_host_service_fixture rules to support testing Android applications. None of these rules are installed yet, because the forthcoming Android test runner is not yet open sourced. https://github.com/bazelbuild/bazel/issues/903. RELNOTES: None PiperOrigin-RevId: 160465920
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt b/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt
new file mode 100644
index 0000000000..c4af683ddb
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt
@@ -0,0 +1,88 @@
+#!/bin/bash --posix
+# Copyright 2017 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eux
+
+# Unset TESTBRIDGE_TEST_ONLY environment variable set by Bazel's --test_filter
+# flag so that JUnit3 doesn't filter out the Android test suite class. Instead,
+# forward this variable as a Java flag with the same name.
+if [ -z "${TESTBRIDGE_TEST_ONLY+1}" ]; then
+ ANDROID_TESTBRIDGE_TEST_ONLY=""
+else
+ ANDROID_TESTBRIDGE_TEST_ONLY=${TESTBRIDGE_TEST_ONLY}
+ unset TESTBRIDGE_TEST_ONLY
+fi
+
+function join_paths() {
+ local base_dir=$1
+ local sep=$2
+ shift 2
+ local paths=$@
+
+ local result=""
+ for path in $paths
+ do
+ result=${base_dir}/${path}${sep}${result}
+ done
+ echo ${result}
+}
+
+test_label="%test_label%"
+test_entry_point="%test_entry_point%"
+log_levels="%log_levels%"
+WORKSPACE_DIR="${TEST_SRCDIR}/%workspace%"
+adb="${WORKSPACE_DIR}/%adb%"
+device_script="${WORKSPACE_DIR}/%device_script%"
+
+data_deps="%data_deps%"
+data_deps=$(join_paths ${WORKSPACE_DIR} "," ${data_deps})
+
+device_broker_type="%device_broker_type%"
+test_label="%test_label%"
+
+target_apks="%target_apks%"
+target_apks=$(join_paths ${WORKSPACE_DIR} "," ${target_apks})
+
+instrumentation_apks="%instrumentation_apks%"
+instrumentation_apks=$(join_paths ${WORKSPACE_DIR} "," ${instrumentation_apks})
+
+support_apks="%support_apks%"
+support_apks=$(join_paths ${WORKSPACE_DIR} "," ${support_apks})
+
+apks_to_install="${support_apks}${target_apks}${instrumentation_apks}"
+
+declare -A device_script_fixtures=( %device_script_fixtures% )
+
+host_service_fixture="%host_service_fixture%"
+host_service_fixture_services="%host_service_fixture_services%"
+
+fixture_args="%fixture_args%"
+
+test_suite_property_name='%test_suite_property_name%'
+
+$test_entry_point \
+ --wrapper_script_flag=--jvm_flag=-D$test_suite_property_name=com.google.android.apps.common.testing.suite.AndroidDeviceTestSuite \
+ --adb="${adb}" \
+ --device_broker_type="${device_broker_type}" \
+ --device_script="${device_script}" \
+ --data_deps="${data_deps}" \
+ --test_label="${test_label}" \
+ --apks_to_install="${apks_to_install}" \
+ --fixture_scripts="$(printf "%s," "${!device_script_fixtures[@]}")" \
+ --hermetic_server_script="${host_service_fixture}" \
+ --hermetic_servers="${host_service_fixture_services}" \
+ --data_deps="$(printf "%s," "${!device_script_fixtures[@]}")" \
+ --test_filter="${ANDROID_TESTBRIDGE_TEST_ONLY}" \
+ "$@"