aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/test/shell/bazel/bazel_apple_test.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/shell/bazel/bazel_apple_test.sh b/src/test/shell/bazel/bazel_apple_test.sh
index fa4de04ff8..4f2eeb6d8b 100755
--- a/src/test/shell/bazel/bazel_apple_test.sh
+++ b/src/test/shell/bazel/bazel_apple_test.sh
@@ -419,4 +419,33 @@ EOF
}
+function test_swift_compilation_mode_flags() {
+ rm -rf ios
+ mkdir -p ios
+
+ cat >ios/debug.swift <<EOF
+// A trick to break compilation when DEBUG is not set.
+func foo() {
+ #if DEBUG
+ var x: Int
+ #endif
+ x = 3
+}
+EOF
+
+ cat >ios/BUILD <<EOF
+load("//tools/build_defs/apple:swift.bzl", "swift_library")
+
+swift_library(name = "swift_lib",
+ srcs = ["debug.swift"])
+EOF
+
+ ! bazel build --verbose_failures --ios_sdk_version=$IOS_SDK_VERSION -c opt \
+ //ios:swift_lib >$TEST_log 2>&1 || fail "should not build"
+ expect_log "error: use of unresolved identifier 'x'"
+
+ bazel build --verbose_failures --ios_sdk_version=$IOS_SDK_VERSION -c dbg \
+ //ios:swift_lib >$TEST_log 2>&1 || fail "should build"
+}
+
run_suite "apple_tests"