Skip to content
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

NSRange: fix init from region RangeExpression in target String #1894

Merged
merged 4 commits into from Feb 14, 2019
Merged

NSRange: fix init from region RangeExpression in target String #1894

merged 4 commits into from Feb 14, 2019

Conversation

ApolloZhu
Copy link
Contributor

Prior to Swift 5, String uses UTF-16 for its Index and encodedOffset. However, this assumption is no longer valid and encodedOffset might be in UTF-8 for native contents in Swift 5.

This change should make the initializer work as expected under either circumstances.

Prior to Swift 5, String uses UTF-16 for its Index and encodedOffset. However, this assumption is no longer valid and encodedOffset might be in UTF-8 for native contents in Swift 5.

This change should make the initializer work as expected under either circumstances.
@spevans
Copy link
Collaborator

spevans commented Feb 11, 2019

@swift-ci test

@ApolloZhu
Copy link
Contributor Author

I don't think there's any existing test for this. I'll write some now.

@ApolloZhu ApolloZhu changed the title NSRange: fix init from region RangeExpression in target String [WIP] NSRange: fix init from region RangeExpression in target String Feb 11, 2019
@ianpartridge
Copy link
Collaborator

@ApolloZhu
Copy link
Contributor Author

@ianpartridge sure. Thanks for pointing it out!

@ApolloZhu ApolloZhu changed the title [WIP] NSRange: fix init from region RangeExpression in target String NSRange: fix init from region RangeExpression in target String Feb 11, 2019
@spevans
Copy link
Collaborator

spevans commented Feb 11, 2019

@swift-ci test

@ApolloZhu
Copy link
Contributor Author

Looks like tests passed but no status reported?

https://ci.swift.org/job/swift-corelibs-foundation-PR-Linux/1903/

@milseman
Copy link
Contributor

You're really going to want to stay up to date with the overlays in swift.

@milseman
Copy link
Contributor

Can you add a LIT test that makes sure they don't diff at the very least?

@ApolloZhu
Copy link
Contributor Author

ApolloZhu commented Feb 12, 2019

Sorry for my inexperience, but could you please explain where I could write the lit test? @milseman

Just my assumption, but I should add a file here?: https://github.com/apple/swift/blob/master/test/stdlib/NSRange.swift

@milseman
Copy link
Contributor

I don't know the testing or build set up for corelibs-foundation, but there could be many approaches.

Is a checkout of the swift source code required to build/test corelibs-foundation? If so, then as a build step corelibs-foundation could copy these overlay files over, that way they are always in sync.

If the build system is not configurable, but corelibs-foundation supports LIT-stye unit tests, then we can at least diff the files and error if there is any difference, similar to how the ABI checker works.

If corelibs-foundation testing is constrained to XCTest only, we should still be able to diff the files, but I don't know XCTest very well.

@ianpartridge or @parkera might know more.

@ApolloZhu
Copy link
Contributor Author

  1. Swift source code had been checked out during CI testing, but didn't seem to be necessary for building/testing in Xcode for me.
  2. I don't see a file named lit.cfg in the swift-corelibs-foundation repository.
  3. https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSRange.swift and https://github.com/apple/swift/blob/master/stdlib/public/Darwin/Foundation/NSRange.swift are not identical. It's right that some parts of them are, but this would also be the case for many other files in this repository. Therefore, (I personally believe) the lit test isn't an essential part of this pull request, but should rather be added through another, solemnly dedicated one to make sure all places where identical implementations are expected.

@parkera
Copy link
Member

parkera commented Feb 13, 2019

We don't use lit for Foundation tests, just XCTest.

@@ -126,4 +128,52 @@ class TestNSRange : XCTestCase {
XCTAssertEqual(NSStringFromRange(range), string)
}
}

private func _assert<S: StringProtocol, R: RangeExpression>(
Copy link
Member

Choose a reason for hiding this comment

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

Can we give this a more specific name to indicate that it is specialized for the below test?

And use more robust implementation
@ApolloZhu
Copy link
Contributor Author

@parkera updated

@spevans
Copy link
Collaborator

spevans commented Feb 13, 2019

@swift-ci test

@millenomi
Copy link
Contributor

@swift-ci please test

@millenomi
Copy link
Contributor

you have to be courteous to robots. :)

@millenomi
Copy link
Contributor

To add to the discussion here: I absolutely would love to unify the overlay and s-c-f code where it’s redundant, but it is really not in the cards for this 5.x cycle.

@ApolloZhu
Copy link
Contributor Author

ApolloZhu commented Feb 14, 2019

Looks like the test has failed due to s-c-xctest:

02:14:10 Actual: "/home/buildnode/jenkins/workspace/swift-corelibs-foundation-PR-Linux/swift-corelibs-xctest/Tests/Functional/Asynchronous/Expectations/main.swift:356: error: ExpectationsTestCase.test_outerWaiterTimesOut_InnerWaitersAreInterrupted : Asynchronous waiter <XCTWaiter expectations: 'inner-1'> failed - Interrupted by timeout of containing waiter <XCTWaiter expectations: 'outer'>\n"
02:14:10 Expected: '.*/Tests/Functional/Asynchronous/Expectations/main.swift:366: error: ExpectationsTestCase.test_outerWaiterTimesOut_InnerWaitersAreInterrupted : Asynchronous wait failed - Exceeded timeout of 0.1 seconds, with unfulfilled expectations: outer'

from this code:

// CHECK: Test Case 'ExpectationsTestCase.test_outerWaiterTimesOut_InnerWaitersAreInterrupted' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
// CHECK: .*/Tests/Functional/Asynchronous/Expectations/main.swift:[[@LINE+22]]: error: ExpectationsTestCase.test_outerWaiterTimesOut_InnerWaitersAreInterrupted : Asynchronous wait failed - Exceeded timeout of 0.1 seconds, with unfulfilled expectations: outer
// CHECK: .*/Tests/Functional/Asynchronous/Expectations/main.swift:[[@LINE+11]]: error: ExpectationsTestCase.test_outerWaiterTimesOut_InnerWaitersAreInterrupted : Asynchronous waiter <XCTWaiter expectations: 'inner-1'> failed - Interrupted by timeout of containing waiter <XCTWaiter expectations: 'outer'>
// CHECK: .*/Tests/Functional/Asynchronous/Expectations/main.swift:[[@LINE+15]]: error: ExpectationsTestCase.test_outerWaiterTimesOut_InnerWaitersAreInterrupted : Asynchronous waiter <XCTWaiter expectations: 'inner-2'> failed - Interrupted by timeout of containing waiter <XCTWaiter expectations: 'outer'>
// CHECK: Test Case 'ExpectationsTestCase.test_outerWaiterTimesOut_InnerWaitersAreInterrupted' failed \(\d+\.\d+ seconds\)
    func test_outerWaiterTimesOut_InnerWaitersAreInterrupted() {

I'll look into what's causing this, but I'm confident that it has nothing to do with this pull request, since Build #1922 failed for the same reason

@spevans
Copy link
Collaborator

spevans commented Feb 14, 2019

@swift-ci test

@millenomi millenomi merged commit 5894e8a into apple:master Feb 14, 2019
@jckarter
Copy link
Member

Is there a chance this is related to this bot failure on Ubuntu 18.04? It looks possibly range-in-string-related:

https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-18_04-long-test/1231/console

11:42:46 Test Case 'TestProcess.test_passthrough_environment' started at 2019-02-14 19:44:05.374
11:42:46 
/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/swift-corelibs-foundation/TestFoundation/TestProcess.swift:257: error: TestProcess.test_passthrough_environment : failed - Test failed: InvalidEnvironmentVariable("swi")

@ApolloZhu
Copy link
Contributor Author

@jckarter your link and output segment seems to be unrelated, so I’ll address both:

  1. The linked build failed because
<unknown>:0: warning: missing submodule 'CDispatch'
/home/buildnode/jenkins/workspace/oss-swift-incremental-RA-linux-ubuntu-18_04-long-test/swift-corelibs-libdispatch/src/swift/Block.swift:13:8: error: no such module 'CDispatch'
import CDispatch
  1. test_passthrough_environment should be addressed by Workaround SR-9930 to prevent CI failures in test_passthrough_environment #1915

@jckarter
Copy link
Member

Oops, sorry for pasting the wrong link. #1915 should address this, thanks!

@ApolloZhu
Copy link
Contributor Author

Sorry for brining this up again, but should this fix actually go into the swift-5.0-branch instead/also?

@ianpartridge
Copy link
Collaborator

Yes, please open a PR against that branch.

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.

None yet

7 participants