-
Notifications
You must be signed in to change notification settings - Fork 118
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
[Test Fix] Fix test fail on non-English locale (SR-15345) #7
Conversation
@@ -639,13 +639,13 @@ class SemaToRenderNodeTests: XCTestCase { | |||
} | |||
XCTAssertEqual(firstTutorialReference.url, "/tutorials/test-bundle/testtutorial") | |||
XCTAssertFalse(firstTutorialReference.abstract.isEmpty) | |||
XCTAssertEqual(firstTutorialReference.estimatedTime, "20min") | |||
XCTAssertEqual(firstTutorialReference.estimatedTime, translator.contentRenderer.formatEstimatedDuration(minutes: 20)) |
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.
What's the purpose of the test expression?
I just afraid of that if the purpose is to test DocumentationContentRenderer'formatEstimatedDuration(minutes:)
, it seemed the test now is useless, since we call the function again on the expect string.
And what is the best solution for 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.
Yes, part of the purpose here is to test this behavior. I’m assuming you’re seeing a test failure on macOS because DateComponentsFormatter (correctly) localizes the date. Since general support for localization is tracked by SR-15352, I’d suggest we instead use the Linux behavior on all platforms and re-introduce using DateComponentsFormatter as part of that work.
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.
Thanks for opening this, Kyle!
@@ -639,13 +639,13 @@ class SemaToRenderNodeTests: XCTestCase { | |||
} | |||
XCTAssertEqual(firstTutorialReference.url, "/tutorials/test-bundle/testtutorial") | |||
XCTAssertFalse(firstTutorialReference.abstract.isEmpty) | |||
XCTAssertEqual(firstTutorialReference.estimatedTime, "20min") | |||
XCTAssertEqual(firstTutorialReference.estimatedTime, translator.contentRenderer.formatEstimatedDuration(minutes: 20)) |
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, part of the purpose here is to test this behavior. I’m assuming you’re seeing a test failure on macOS because DateComponentsFormatter (correctly) localizes the date. Since general support for localization is tracked by SR-15352, I’d suggest we instead use the Linux behavior on all platforms and re-introduce using DateComponentsFormatter as part of that work.
If I understand you correctly, the suggestion is to pending the PR and the the bug until the Linux implementation of DateComponentsFormatter, right? |
I think we should use your PR here to remove the use of let hours = minutes / 60
let minutes = minutes % 60
return "\(hours > 0 ? "\(hours)hr " : "")\(minutes)min" Then as part of SR-15352, we’ll want to add |
I agree. Updated the PR |
Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift
Outdated
Show resolved
Hide resolved
….swift Co-authored-by: Franklin Schrans <f.schrans@me.com>
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.
@swift-ci please test |
@swift-ci please test Linux |
Thanks @Kyle-Ye ! |
Bug
https://bugs.swift.org/browse/SR-15345
Summary
Fix test fail on non-English locale machine
Testing
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded