Skip to content

Additional Swift 3 API naming updates #88

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

Merged
merged 3 commits into from
Apr 6, 2016

Conversation

briancroom
Copy link
Contributor

#82 got us started with updating our own APIs to match the Swift 3 guidelines, but there are a number of other changes required for us to be fully compatible. Here, I've adjusted a few public methods to match how they are imported into Swift from Apple XCTest with the Swift 3 toolchain. I have also made a handful of changes to internal APIs to bring them in line with the Swift 3 naming guidelines. See the commit messages for more specifics!

@@ -189,7 +189,7 @@ extension XCTestCase {
/// between these environments. To ensure compatibility of tests between
/// swift-corelibs-xctest and Apple XCTest, it is not recommended to pass
/// explicit values for `file` and `line`.
public func expectationWithDescription(description: String, file: StaticString = #file, line: UInt = #line) -> XCTestExpectation {
public func expectation(withDescription description: String, file: StaticString = #file, line: UInt = #line) -> XCTestExpectation {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"With" is usually a vacuous preposition that does not carry any semantics. I think this is one of those cases. (Other cases in XCTest may also be like that.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. However this is the method name as generated by the importer with the March 24 toolchain from XCTest.framework. Do you expect additional changes to the importer which would automatically remove "with"? Or is this a situation where the Objective-C header should be annotated with the swift_name attribute?

(Interestingly, it appears that https://github.com/apple/swift-3-api-guidelines-review doesn't include XCTest.framework)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should match exactly what the importer does, which is leaving the with in place (and this is very much an intentional choice).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parkera is there any additional discussion around this particular choice you could point me to? I'm curious about the context on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a discussion we had in our Swift 3 naming 'working group'.

The summary is that we felt that the importer could not automatically make the right decision about if a 'with' was important or not in an API. It is used to mean different things in different APIs. Therefore we decided to stick with a default of leaving it in place for imported API.

We can of course change our minds about the names, but then we're talking about changing it for all clients on all platforms. Since this version of XCTest is attempting to keep the same API, and there isn't a plan to change the Darwin version of this method, we should keep the name the same for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's exactly the info I was looking for.

@modocache
Copy link
Contributor

Looks good to me! @parkera or @mike-ferris-apple, could you kick off the tests?

Also, I'm curious: what's the best way to see the Swift headers generated for Apple XCTest? I use "Jump to Definition" in Xcode (with my desired toolchain selected) to see the Swift headers. Is there a better way, perhaps something I can invoke from the command line?

@mike-ferris
Copy link

@swift-ci please test

@modocache
Copy link
Contributor

Ruh-roh, build failure. @briancroom, looks like you missed a spot:

Sources/XCTest/XCTestCase.swift:265:21: error: value of type 'XCTestExpectation' has no member 'fulfilled'
                if !expectation.fulfilled {
                    ^~~~~~~~~~~ ~~~~~~~~~

@parkera
Copy link
Contributor

parkera commented Apr 4, 2016

One trick I've been using is to start up the swift REPL after building the whole stack from scratch. You can tab-complete in there to get a list of API on a type.

@modocache
Copy link
Contributor

utils/swift-api-dump.py seems like what I need, although it doesn't cover XCTest--see SR-1153. Maybe I'll send a pull request... 😉

@parkera
Copy link
Contributor

parkera commented Apr 4, 2016

Nice, I didn't know about that script. Thanks @modocache.

@briancroom briancroom force-pushed the swift-3-api-updates branch 2 times, most recently from 31afda4 to 4d70c0c Compare April 4, 2016 17:11
@briancroom
Copy link
Contributor Author

Oh man, thanks CI for pointing out my incomplete commit 😳 I've fixed that now, rebased, and added one additional Swift 3 import change I had previously missed - default nil values for optional handler params.

Also thanks for the swift-api-dump.py tip - so far I've been viewing the Generated Interface from within Xcode to see these things.

@modocache
Copy link
Contributor

Ping @mike-ferris-apple for another test kickoff -- how about "@swift-ci please test and merge"? 😁

@modocache
Copy link
Contributor

It turns out swift-api-dump.py can generate XCTest headers as well, you just need to know which arguments to pass. I uploaded the current set of headers here, along with the command: https://github.com/modocache/XCTest.swift

@mike-ferris
Copy link

@swift-ci please test

@briancroom
Copy link
Contributor Author

Ah, looks like CI failed because #90 was merged which contains code that needs updating. Hang tight...

- Lowercased enum cases
- Boolean properties prefixed with `is`
This is to match another Swift 3 API importer change.
@briancroom briancroom force-pushed the swift-3-api-updates branch from 4d70c0c to 1ad6f7e Compare April 6, 2016 16:44
@briancroom
Copy link
Contributor Author

Rebased and fixed up now. @mike-ferris-apple could I bother you for another CI test request?

@mike-ferris
Copy link

@swift-ci please test

@mike-ferris
Copy link

Ah, oops. Didn't see Harlan's request there.

@harlanhaskins
Copy link

Nah, I'm not on the CI list quite yet 👍

@modocache
Copy link
Contributor

One day swiftlang/swift#2036 will be merged and the Swift Test OS X Platform check will succeed. Today is not that day 😂

In the meantime, looks like Linux passed, so I'm merging this. Thanks as always, @briancroom! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants