Skip to content

Commit ab939a4

Browse files
committed
[Serialization] Add 2 scenarios to the test for transitive testable dependencies
* A multi-file scenario where one file has a normal import and the other a testable import. In this case we still load the extra dependencies and show diagnostics only of the testable import. * A scenario where module A @testable imports module B, which @_exported imports module C. In this case, non-public imports of B are loaded, but not those of C. This is a limitation of the current implementation and could be improved upon in the future.
1 parent 9e18563 commit ab939a4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/Serialization/access-level-import-dependencies.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,43 @@ import PrivateDep
112112
// RUN: %target-swift-frontend -typecheck %t/TestableClientOfNonPublic.swift -I %t \
113113
// RUN: -Rmodule-loading 2>&1 | %FileCheck -check-prefix=VISIBLE-DEP %s
114114

115+
/// In the case of a testable of a module reexporting another Swift module,
116+
/// only non-public transitive dependencies from the first module are required.
117+
/// Non-public imports from the reexported modules are not loaded, we could
118+
/// revisit this if desired.
119+
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift -o %t -I %t \
120+
// RUN: -enable-library-evolution -enable-testing \
121+
// RUN: -enable-experimental-feature AccessLevelOnImport
122+
// RUN: %target-swift-frontend -typecheck %t/ExporterClient.swift -I %t \
123+
// RUN: -Rmodule-loading 2>&1 | %FileCheck -check-prefixes=CHECK-EXPORTER,HIDDEN-DEP %s
124+
// CHECK-EXPORTER: 'InternalDep' has an ignored transitive dependency on 'HiddenDep'
125+
126+
//--- Exporter.swift
127+
@_exported import InternalDep
128+
129+
//--- ExporterClient.swift
130+
@testable import Exporter
131+
115132
/// Fail if the transitive dependency is missing.
116133
// RUN: rm %t/HiddenDep.swiftmodule
117134
// RUN: %target-swift-frontend -typecheck %t/TestableClientOfNonPublic.swift -I %t \
118135
// RUN: -verify -show-diagnostics-after-fatal
136+
137+
/// In a multi-file scenario, we try and fail to load the transitive dependency
138+
/// only for @testable imports, not regular imports.
139+
// RUN: %target-swift-frontend -typecheck -I %t \
140+
// RUN: %t/TestableClientOfNonPublic_FileA.swift \
141+
// RUN: %t/TestableClientOfNonPublic_FileB.swift \
142+
// RUN: -verify -show-diagnostics-after-fatal
143+
// RUN: %target-swift-frontend -typecheck -wmo -I %t \
144+
// RUN: %t/TestableClientOfNonPublic_FileA.swift \
145+
// RUN: %t/TestableClientOfNonPublic_FileB.swift \
146+
// RUN: -verify -show-diagnostics-after-fatal
147+
148+
//--- TestableClientOfNonPublic_FileA.swift
149+
import InternalDep
150+
@testable import FileprivateDep // expected-error {{missing required module 'HiddenDep'}}
151+
152+
//--- TestableClientOfNonPublic_FileB.swift
153+
@testable import InternalDep // expected-error {{missing required module 'HiddenDep'}}
154+
import FileprivateDep

0 commit comments

Comments
 (0)