diff --git a/test/BUILD b/test/BUILD index adb5f80de..cad3602b8 100644 --- a/test/BUILD +++ b/test/BUILD @@ -18,6 +18,7 @@ load(":output_file_map_tests.bzl", "output_file_map_test_suite") load(":pch_output_dir_tests.bzl", "pch_output_dir_test_suite") load(":private_deps_tests.bzl", "private_deps_test_suite") load(":private_swiftinterface_tests.bzl", "private_swiftinterface_test_suite") +load(":runtime_deps_tests.bzl", "runtime_deps_test_suite") load(":split_derived_files_tests.bzl", "split_derived_files_test_suite") load(":swift_binary_linking_tests.bzl", "swift_binary_linking_test_suite") load(":swift_through_non_swift_tests.bzl", "swift_through_non_swift_test_suite") @@ -75,6 +76,8 @@ utils_test_suite(name = "utils") xctest_runner_test_suite(name = "xctest_runner") +runtime_deps_test_suite(name = "runtime_deps") + test_suite( name = "all_tests", ) diff --git a/test/fixtures/runtime_deps/BUILD b/test/fixtures/runtime_deps/BUILD new file mode 100644 index 000000000..10a5234eb --- /dev/null +++ b/test/fixtures/runtime_deps/BUILD @@ -0,0 +1,31 @@ +load("//swift:swift_binary.bzl", "swift_binary") +load("//swift:swift_library.bzl", "swift_library") +load("//test/fixtures:common.bzl", "FIXTURE_TAGS") + +package( + default_visibility = ["//test:__subpackages__"], +) + +exports_files(["transitive_data.txt"]) + +swift_library( + name = "transitive_library", + srcs = ["transitive_library.swift"], + data = [":transitive_data.txt"], + tags = FIXTURE_TAGS, +) + +swift_library( + name = "direct_library", + srcs = ["direct_library.swift"], + tags = FIXTURE_TAGS, + deps = [":transitive_library"], +) + +swift_binary( + name = "runtime_deps", + srcs = ["main.swift"], + module_name = "binary", + tags = FIXTURE_TAGS, + deps = [":direct_library"], +) diff --git a/test/fixtures/runtime_deps/direct_library.swift b/test/fixtures/runtime_deps/direct_library.swift new file mode 100644 index 000000000..00c7568f8 --- /dev/null +++ b/test/fixtures/runtime_deps/direct_library.swift @@ -0,0 +1,3 @@ +public func foo() -> String { + return "foo" +} diff --git a/test/fixtures/runtime_deps/main.swift b/test/fixtures/runtime_deps/main.swift new file mode 100644 index 000000000..b80e3222a --- /dev/null +++ b/test/fixtures/runtime_deps/main.swift @@ -0,0 +1 @@ +print("hi") diff --git a/test/fixtures/runtime_deps/transitive_data.txt b/test/fixtures/runtime_deps/transitive_data.txt new file mode 100644 index 000000000..312b673e3 --- /dev/null +++ b/test/fixtures/runtime_deps/transitive_data.txt @@ -0,0 +1 @@ +Its some data diff --git a/test/fixtures/runtime_deps/transitive_library.swift b/test/fixtures/runtime_deps/transitive_library.swift new file mode 100644 index 000000000..00c7568f8 --- /dev/null +++ b/test/fixtures/runtime_deps/transitive_library.swift @@ -0,0 +1,3 @@ +public func foo() -> String { + return "foo" +} diff --git a/test/runtime_deps_tests.bzl b/test/runtime_deps_tests.bzl new file mode 100644 index 000000000..45116f031 --- /dev/null +++ b/test/runtime_deps_tests.bzl @@ -0,0 +1,46 @@ +# Copyright 2020 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. + +"""Tests for `swift_library.generated_header`.""" + +load( + "//test/rules:provider_test.bzl", + "provider_test", +) + +def runtime_deps_test_suite(name, tags = []): + """Test suite for `swift_binary` runtime deps. + + Args: + name: The base name to be used in targets created by this macro. + tags: Additional tags to apply to each test. + """ + all_tags = [name] + tags + + provider_test( + name = "{}_swift_binary_runtime_deps".format(name), + expected_files = [ + "test/fixtures/runtime_deps/transitive_data.txt", + "*", + ], + field = "default_runfiles.files", + provider = "DefaultInfo", + tags = all_tags, + target_under_test = "//test/fixtures/runtime_deps", + ) + + native.test_suite( + name = name, + tags = all_tags, + )