aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/android_instrumentation_test_template.txt
blob: c4af683ddbe6b40236da88a967128c78de3b668a (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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}" \
    "$@"