summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Smiley <keithbsmiley@gmail.com>2023-08-21 14:22:58 -0700
committerGitHub <noreply@github.com>2023-08-21 21:22:58 +0000
commit48a8ff8fea94a5057409bdf5be537945c241f361 (patch)
tree909e8faa9e0085dface25c9b1564a3615fd31933
parent400ce51ddb5541aecd153a3093ffbeba41b44d44 (diff)
downloadbazelbuild-apple_support-48a8ff8fea94a5057409bdf5be537945c241f361.tar.gz
Move shell test to cc_test (#245)
This verifies the build and also verifies it actually works which is a bit nicer
-rw-r--r--test/BUILD21
-rw-r--r--test/cc_test_with_objc_deps.cc14
-rw-r--r--test/objc_lib.h3
-rw-r--r--test/objc_lib.m5
-rwxr-xr-xtest/shell/objc_test.sh37
-rw-r--r--test/underlying_lib.h1
6 files changed, 44 insertions, 37 deletions
diff --git a/test/BUILD b/test/BUILD
index 0438b05..fb17576 100644
--- a/test/BUILD
+++ b/test/BUILD
@@ -103,3 +103,24 @@ starlark_apple_binary(
platform_type = "macos",
deps = ["main_objc"],
)
+
+cc_library(
+ name = "underlying_lib",
+ hdrs = ["underlying_lib.h"],
+ tags = ["manual"],
+)
+
+objc_library(
+ name = "objc_lib",
+ srcs = ["objc_lib.m"],
+ hdrs = ["objc_lib.h"],
+ tags = ["manual"],
+ deps = [":underlying_lib"],
+ alwayslink = True,
+)
+
+cc_test(
+ name = "cc_test_with_objc_deps",
+ srcs = ["cc_test_with_objc_deps.cc"],
+ deps = [":objc_lib"],
+)
diff --git a/test/cc_test_with_objc_deps.cc b/test/cc_test_with_objc_deps.cc
new file mode 100644
index 0000000..f89e27e
--- /dev/null
+++ b/test/cc_test_with_objc_deps.cc
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "test/objc_lib.h"
+
+int main() {
+ if (from_objc_library() == 10) {
+ printf("SUCCESS: from_objc_library() = %d\n", from_objc_library());
+ return EXIT_SUCCESS;
+ } else {
+ printf("FAILED: from_objc_library() = %d, expected 10\n", from_objc_library());
+ return EXIT_FAILURE;
+ }
+}
diff --git a/test/objc_lib.h b/test/objc_lib.h
new file mode 100644
index 0000000..d1969cd
--- /dev/null
+++ b/test/objc_lib.h
@@ -0,0 +1,3 @@
+extern "C" {
+ int from_objc_library();
+}
diff --git a/test/objc_lib.m b/test/objc_lib.m
new file mode 100644
index 0000000..22d0dc8
--- /dev/null
+++ b/test/objc_lib.m
@@ -0,0 +1,5 @@
+#include "test/underlying_lib.h"
+
+int from_objc_library() {
+ return from_cc_library + 5;
+}
diff --git a/test/shell/objc_test.sh b/test/shell/objc_test.sh
index fddf490..ba95dec 100755
--- a/test/shell/objc_test.sh
+++ b/test/shell/objc_test.sh
@@ -138,41 +138,4 @@ EOF
|| fail "should fail to find symbol addOne"
}
-function test_cc_test_depending_on_objc() {
- setup_objc_test_support
-
- rm -rf foo
- mkdir -p foo
-
- cat >foo/a.cc <<EOF
-#include <iostream>
-int main(int argc, char** argv) {
- std::cout << "Hello! I'm a test!\n";
- return 0;
-}
-EOF
-
- cat >foo/BUILD <<EOF
-cc_library(
- name = "a",
- srcs = ["a.cc"],
-)
-
-objc_library(
- name = "b",
- deps = [
- ":a",
- ],
-)
-
-cc_test(
- name = "d",
- deps = [":b"],
-)
-EOF
-
- bazel test --verbose_failures \
- //foo:d>"$TEST_log" 2>&1 || fail "should pass"
-}
-
run_suite "objc/ios test suite"
diff --git a/test/underlying_lib.h b/test/underlying_lib.h
new file mode 100644
index 0000000..cedf546
--- /dev/null
+++ b/test/underlying_lib.h
@@ -0,0 +1 @@
+int from_cc_library = 5;