aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar Adam Michael <ajmichael@google.com>2017-01-05 19:13:49 +0000
committerGravatar John Cater <jcater@google.com>2017-01-05 21:10:28 +0000
commit078cd1953c7823707140b2f177d83c034b1738f5 (patch)
tree3e61346e3dd139b7c8d18cf7146f4c0ab40214c3 /src/test/shell
parentd7e1571a19daf79f762ca819fb5ad2a97e8c4c25 (diff)
Make path attribute optional for android_sdk_repository and android_ndk_repository.
Read from ANDROID_{NDK_}HOME if not set. Note that the repository is NOT invalidated if ANDROID_{NDK_}HOME is changed. Once https://bazel.build/designs/2016/10/18/repository-invalidation.htm is implemented, that will no longer be the case. This is one piece of https://github.com/bazelbuild/bazel/issues/2284. RELNOTES: android_sdk_repository and android_ndk_repository now read $ANDROID_HOME and $ANDROID_NDK_HOME if the path attribute is not set. -- PiperOrigin-RevId: 143686964 MOS_MIGRATED_REVID=143686964
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/android/android_integration_test.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/shell/bazel/android/android_integration_test.sh b/src/test/shell/bazel/android/android_integration_test.sh
index a8086aa8b7..8cb626eecb 100755
--- a/src/test/shell/bazel/android/android_integration_test.sh
+++ b/src/test/shell/bazel/android/android_integration_test.sh
@@ -312,6 +312,62 @@ EOF
assert_contains "build_tools_version = \"25.0.1\"" output
}
+function test_android_sdk_repository_path_from_environment() {
+ create_new_workspace
+ setup_android_support
+ # Overwrite WORKSPACE that was created by setup_android_support with one that
+ # does not set the path attribute of android_sdk_repository.
+ cat > WORKSPACE <<EOF
+android_sdk_repository(
+ name = "androidsdk",
+ api_level = 25,
+)
+EOF
+ ANDROID_HOME=$ANDROID_SDK bazel build @androidsdk//:files || fail \
+ "android_sdk_repository failed to build with \$ANDROID_HOME instead of " \
+ "path"
+}
+
+function test_android_ndk_repository_path_from_environment() {
+ create_new_workspace
+ setup_android_support
+ cat > WORKSPACE <<EOF
+android_ndk_repository(
+ name = "androidndk",
+ api_level = 25,
+)
+EOF
+ ANDROID_NDK_HOME=$ANDROID_NDK bazel build @androidndk//:files || fail \
+ "android_ndk_repository failed to build with \$ANDROID_NDK_HOME instead " \
+ "of path"
+}
+
+function test_android_sdk_repository_no_path_or_android_home() {
+ create_new_workspace
+ setup_android_support
+ cat > WORKSPACE <<EOF
+android_sdk_repository(
+ name = "androidsdk",
+ api_level = 25,
+)
+EOF
+ bazel build @androidsdk//:files >& $TEST_log && fail "Should have failed"
+ expect_log "Either the path attribute of android_sdk_repository"
+}
+
+function test_android_ndk_repository_no_path_or_android_ndk_home() {
+ create_new_workspace
+ setup_android_support
+ cat > WORKSPACE <<EOF
+android_ndk_repository(
+ name = "androidndk",
+ api_level = 25,
+)
+EOF
+ bazel build @androidndk//:files >& $TEST_log && fail "Should have failed"
+ expect_log "Either the path attribute of android_ndk_repository"
+}
+
# ndk r10 and earlier
if [[ ! -r "${TEST_SRCDIR}/androidndk/ndk/RELEASE.TXT" ]]; then
# ndk r11 and later