Run Android shell integration tests on Windows
Starting off with aapt_integration_test.
Closes #9119.
Change-Id: I1a103923c932a3e1ba0f9499c1bccca00d16abd8
PiperOrigin-RevId: 262646257
diff --git a/src/BUILD b/src/BUILD
index 500c9cd..28e3cc7 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -514,6 +514,7 @@
"//src/test/py/bazel:all_windows_tests",
"//src/test/res:all_windows_tests",
"//src/test/shell:all_windows_tests",
+ "//src/test/shell/bazel/android:all_windows_tests",
"//src/tools/launcher:all_windows_tests",
"//src/tools/singlejar:all_windows_tests",
"//third_party/def_parser:all_windows_tests",
diff --git a/src/test/shell/bazel/android/BUILD b/src/test/shell/bazel/android/BUILD
index f3fd313..d87feb8 100644
--- a/src/test/shell/bazel/android/BUILD
+++ b/src/test/shell/bazel/android/BUILD
@@ -20,7 +20,10 @@
sh_library(
name = "android_helper",
srcs = ["android_helper.sh"],
- data = ["sample.aar"],
+ data = [
+ "sample.aar",
+ "@bazel_tools//tools/bash/runfiles",
+ ],
)
sh_test(
@@ -33,7 +36,10 @@
"//src/test/shell/bazel:test-deps",
],
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -60,7 +66,10 @@
"//src/test/shell/bazel:test-deps",
],
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -73,7 +82,10 @@
"//src/test/shell/bazel:test-deps",
],
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -87,7 +99,10 @@
],
shard_count = 3,
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -103,7 +118,10 @@
],
shard_count = 6,
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -116,7 +134,10 @@
"//src/test/shell/bazel:test-deps",
],
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -129,7 +150,10 @@
"//src/test/shell/bazel:test-deps",
],
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -143,7 +167,10 @@
],
shard_count = 4,
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
)
sh_test(
@@ -157,5 +184,16 @@
"//src/test/shell/bazel:test-deps",
],
# See https://github.com/bazelbuild/bazel/issues/8235
- tags = ["no-remote"],
+ tags = [
+ "no-remote",
+ "no-windows",
+ ],
+)
+
+test_suite(
+ name = "all_windows_tests",
+ tags = [
+ "-no-windows",
+ ],
+ visibility = ["//src/test/shell:__pkg__"],
)
diff --git a/src/test/shell/bazel/android/aapt_integration_test.sh b/src/test/shell/bazel/android/aapt_integration_test.sh
index 159f7a0..16a24c3 100755
--- a/src/test/shell/bazel/android/aapt_integration_test.sh
+++ b/src/test/shell/bazel/android/aapt_integration_test.sh
@@ -23,16 +23,29 @@
# Note that if the environment is not set up as above android_integration_test
# will silently be ignored and will be shown as passing.
-# Load the test setup defined in the parent directory
-CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# --- begin runfiles.bash initialization v2 ---
+# Copy-pasted from the Bazel Bash runfiles library v2.
+set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
+source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
+ source "$0.runfiles/$f" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
+# --- end runfiles.bash initialization v2 ---
-source "${CURRENT_DIR}/android_helper.sh" \
+source "$(rlocation io_bazel/src/test/shell/bazel/android/android_helper.sh)" \
|| { echo "android_helper.sh not found!" >&2; exit 1; }
fail_if_no_android_sdk
-source "${CURRENT_DIR}/../../integration_test_setup.sh" \
+source "$(rlocation io_bazel/src/test/shell/integration_test_setup.sh)" \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
+# TODO(#8169): Make this test compatible with Python toolchains. Blocked on the
+# fact that there's no PY3 environment on our Mac workers
+# (bazelbuild/continuous-integration#578).
+add_to_bazelrc "build --incompatible_use_python_toolchains=false"
+
function test_build_with_aapt() {
create_new_workspace
setup_android_sdk_support
diff --git a/src/test/shell/bazel/android/android_helper.sh b/src/test/shell/bazel/android/android_helper.sh
index c2a9ba1..6b8e745 100755
--- a/src/test/shell/bazel/android/android_helper.sh
+++ b/src/test/shell/bazel/android/android_helper.sh
@@ -14,8 +14,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# --- begin runfiles.bash initialization v2 ---
+# Copy-pasted from the Bazel Bash runfiles library v2.
+set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
+source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
+ source "$0.runfiles/$f" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
+# --- end runfiles.bash initialization v2 ---
+
function fail_if_no_android_sdk() {
- if [[ ! -d "${TEST_SRCDIR}/androidsdk" ]]; then
+ # Required for runfiles library on Windows, since $(rlocation) lookups
+ # can't do directories. We use android-28's android.jar as the anchor
+ # for the androidsdk location.
+ android_sdk_anchor=$(rlocation androidsdk/platforms/android-28/android.jar)
+ if [[ ! -r "$android_sdk_anchor" ]]; then
echo "Not running Android tests due to lack of an Android SDK."
exit 1
fi
@@ -53,7 +68,7 @@
)
EOF
- cp "${TEST_SRCDIR}/io_bazel/src/test/shell/bazel/android/sample.aar" \
+ cp "$(rlocation io_bazel/src/test/shell/bazel/android/sample.aar)" \
java/bazel/sample.aar
cat > java/bazel/AndroidManifest.xml <<EOF
<manifest package="bazel.android" />
diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh
index 27ca2d9..29a7ae4 100755
--- a/src/test/shell/testenv.sh
+++ b/src/test/shell/testenv.sh
@@ -307,12 +307,13 @@
}
function setup_android_sdk_support() {
- ANDROID_SDK=$PWD/android_sdk
- SDK_SRCDIR=$TEST_SRCDIR/androidsdk
- mkdir -p $ANDROID_SDK
- for i in $SDK_SRCDIR/*; do
- ln -s "$i" "$ANDROID_SDK/$(basename $i)"
- done
+ # Required for runfiles library on Windows, since $(rlocation) lookups
+ # can't do directories. We use android-28's android.jar as the anchor
+ # for the androidsdk location.
+ local android_jar=$(rlocation androidsdk/platforms/android-28/android.jar)
+ local android=$(dirname $android_jar)
+ local platforms=$(dirname $android)
+ ANDROID_SDK=$(dirname $platforms)
cat >> WORKSPACE <<EOF
android_sdk_repository(
name = "androidsdk",