-
Notifications
You must be signed in to change notification settings - Fork 185
Use the package
access level instead of @testable
imports
#1215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please test |
559c06b
to
b9a6d4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One overall comment: I just want to make sure that in all scenarios (building as a package, being built as part of the toolchain etc.) that making these package
will not allow any client to start using them (unless they're doing some @_silgen_name
shenanigans) since we don't actually install the package swift interface file anywhere, right?
@@ -30,7 +30,7 @@ extension AttributedString { | |||
typealias _AttributeStorage = AttributedString._AttributeStorage | |||
|
|||
var version: Version | |||
var string: BigString | |||
package var string: BigString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is only used from one place: NumberFormatStyleTests
which could easily do String(self.characters)
instead of String(self._guts.string)
which would save us from needing to mark this and the imports above as package
.
For cases like this, would you rather we update them in a separate change and keep this as just a @testable
--> package
change, or would you want to incorporate that into this to reduce the number of things that we import as package
like the collections modules above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d prefer if this is just a mechanical @testable
-> package
change. It’s fairly big already and I don’t want to hide any other functionality change in it.
So, if you could make those changes up-front, that would be great.
@@ -38,7 +38,7 @@ extension Date { | |||
timeIntervalSinceReferenceDate / 86400 + Self.julianDayAtDateReference | |||
} | |||
|
|||
func julianDay() throws (GregorianCalendarError) -> Int { | |||
package func julianDay() throws (GregorianCalendarError) -> Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see uses of this, the initializer below, or the error type from our tests, was this an accidental addition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s used here:
_ = d.julianDay |
That being said, the test should probably call julianDay
instead of just getting a function reference to it 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah that's probably why I missed it in my search since it didn't actually call the function - ok thanks for the explanation
@@ -35,7 +35,7 @@ public protocol FileManagerDelegate : AnyObject, Sendable { | |||
} | |||
|
|||
// Default implementations for String-based requirements | |||
extension FileManagerDelegate { | |||
package extension FileManagerDelegate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should actually be public instead of just package visibility, since we want clients to get these default implementations too (I guess this goes to show how uncommon it is for people to use this delegate on Linux/Windows)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here, do you want to make a separate PR for that so we don’t hide functionality change in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can put this in another PR
@@ -15,9 +15,9 @@ import TestSupport | |||
#endif | |||
|
|||
#if FOUNDATION_FRAMEWORK | |||
@testable import Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since TestSupport
has an @_exported import Foundation
, we can just remove these few lines entirely. The only reason they're spelled out here is because @_exported
doesn't "re-export" the @testable
-ness of the import. Same goes for any files that have changes like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed all imports to Foundation(Essentials|Internationalization|)
when TestSupport
is imported here: a23e682
#endif | ||
|
||
final class ICUPatternGeneratorTests: XCTestCase { | ||
|
||
typealias DateFieldCollection = Date.FormatStyle.DateFieldCollection | ||
package typealias DateFieldCollection = Date.FormatStyle.DateFieldCollection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? The test module isn't a dependency of any other module, so it shouldn't need anything more permissive than internal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I changed this by mistake
`@testable` imports have a number of build-time drawbacks, including: - Building the package in `release` configuration and then running tests requires the entire package to be rebuilt because SwiftPM needs to pass `--enable-testing` to the compiler invocations. - The usage of `@testable` means that swift-foundation cannot be included in the unified (aka. multiroot) build of all the other packages in Swift CI, which means that it needs to re-build swift-syntax, unnecessarily increasing CI time. To fix this, make all `@testable` imports normal imports and mark the declarations that were previously accessed through `@testable` as `package`. a
…TestSupport` is imported TestSupport has `@_exported` imports for those modules.
a23e682
to
0ffac98
Compare
I am pretty sure that we don’t install |
Looks like the package symbols are being successfully stripped. I checked the Linux build:
Grepping both Windows also only contains |
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is extremely unfortunate to lose the meaning of what internal vs. package means, even for the benefit of improved CI times. This will also make all of these exported symbols on Darwin. Let's look for another solution.
@testable
imports have a number of build-time drawbacks, including:release
configuration and then running tests requires the entire package to be rebuilt because SwiftPM needs to pass--enable-testing
to the compiler invocations.@testable
means that swift-foundation cannot be included in the unified (aka. multiroot) build of all the other packages in Swift CI, which means that it needs to re-build swift-syntax, unnecessarily increasing CI time.To fix this, make all
@testable
imports normal imports and mark the declarations that were previously accessed through@testable
aspackage
.