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

[SR-11250] Different behavior during testing between Xcode and SPM #53651

Open
swift-ci opened this issue Aug 2, 2019 · 7 comments
Open

[SR-11250] Different behavior during testing between Xcode and SPM #53651

swift-ci opened this issue Aug 2, 2019 · 7 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. regression standard library Area: Standard library umbrella swift 5.1

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Aug 2, 2019

Previous ID SR-11250
Radar rdar://problem/53865954
Original Reporter DanielM (JIRA User)
Type Bug

Attachment: Download

Environment

macOS 10.14.6

Xcode 11 beta5

Swift version 5.1-dev (LLVM af1f73e9e9, Swift 76e4d7f5ab)

Swift Package Manager - Swift 5.1.0 (1e376cb3)

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, 5.1Regression
Assignee @rxwei
Priority Medium

md5: 9977c576b3fd79f56fb4d8df664cb128

Issue Description:

I have a test for an angle calculation, in Xcode the test is successful, but if I use SPM to run the test, the calculation returns "nan" and the test fails. I've added a small project to show the strange behavior of SPM.

SPM

[7/7] Linking testswiftPackageTests
Test Suite 'All tests' started at 2019-08-02 13:11:01.065
Test Suite 'testswiftPackageTests.xctest' started at 2019-08-02 13:11:01.065
Test Suite 'testswiftTests' started at 2019-08-02 13:11:01.065
Test Case '-[testswiftTests.testswiftTests testExample]' started.
/Users/daniel/testswift/Tests/testswiftTests/testswiftTests.swift:37: error: [testswiftTests.testswiftTests testExample] : XCTAssertEqualWithAccuracy failed: ("nan") is not equal to ("55.53491470050634") +/ ("0.01")
Test Case '-[testswiftTests.testswiftTests testExample]' failed (0.133 seconds).
Test Suite 'testswiftTests' failed at 2019-08-02 13:11:01.198.
Executed 1 test, with 1 failure (0 unexpected) in 0.133 (0.133) seconds
Test Suite 'testswiftPackageTests.xctest' failed at 2019-08-02 13:11:01.198.
Executed 1 test, with 1 failure (0 unexpected) in 0.133 (0.134) seconds
Test Suite 'All tests' failed at 2019-08-02 13:11:01.198.
Executed 1 test, with 1 failure (0 unexpected) in 0.133 (0.134) seconds

Xcode

Test Suite 'All tests' started at 2019-08-02 13:23:12.967
Test Suite 'testswiftTests.xctest' started at 2019-08-02 13:23:12.967
Test Suite 'testswiftTests' started at 2019-08-02 13:23:12.968
Test Case '-[testswiftTests.testswiftTests testExample]' started.
Test Case '-[testswiftTests.testswiftTests testExample]' passed (0.081 seconds).
Test Suite 'testswiftTests' passed at 2019-08-02 13:23:13.049.
Executed 1 test, with 0 failures (0 unexpected) in 0.081 (0.082) seconds
Test Suite 'testswiftTests.xctest' passed at 2019-08-02 13:23:13.051.
Executed 1 test, with 0 failures (0 unexpected) in 0.081 (0.083) seconds
Test Suite 'All tests' passed at 2019-08-02 13:23:13.051.
Executed 1 test, with 0 failures (0 unexpected) in 0.081 (0.084) seconds

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 2, 2019

Comment by Daniel Müllenborn (JIRA)

I found out that the following code cannot be compiled correctly with SPM.

import Foundation
 
precedencegroup ExponentiationPrecedence {
  associativity: right
  higherThan: MultiplicationPrecedence
}
 
infix operator **: ExponentiationPrecedence
infix operator **=: AssignmentPrecedence
 
extension Double {
  static func ** (lhs: Double, rhs: Double) -> Double {
    return pow(lhs, rhs)
  }
 
  static func **= (lhs: inout Double, rhs: Double) {
    lhs = lhs ** rhs
  }
}
let az: Double = 2.737712023738262
let el: Double = 0.4587429800191673
let beta: Double = 0
let sfaz: Double = 0
 
let theta: Double = (cos(az - sfaz) / abs(cos(az - sfaz)) * 180
  / .pi * acos(sqrt(1 - (cos(el - beta) - cos(beta) * cos(el)
    * (1 - cos(az - sfaz))) ** 2)))
 
print(theta) // prints "nan" only when build with SPM

@belkadan
Copy link
Contributor

belkadan commented Aug 2, 2019

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Aug 2, 2019

Hm, I'm not seeing this with a non-dev build. DanielM (JIRA User), did you get your 5.1 from a downloadable toolchain, or did you build it yourself?

@belkadan
Copy link
Contributor

belkadan commented Aug 2, 2019

And with master I get failures both in Xcode and in SwiftPM. So I'm going to assume that Xcode wasn't actually using your toolchain for whatever reason and hand this over to the stdlib folks. @stephentyrone?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 2, 2019

Comment by Daniel Müllenborn (JIRA)

I also installed the Swift for TensorFlow Toolchain 0.4RC4, maybe this is the reason.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 2, 2019

Comment by Daniel Müllenborn (JIRA)

I checked the SPM version again, and noticed that I accidentally used the TensorFlow toolchain.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Aug 2, 2019

Comment by Daniel Müllenborn (JIRA)

I think this bug should be fixed by your team.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. regression standard library Area: Standard library umbrella swift 5.1
Projects
None yet
Development

No branches or pull requests

3 participants