-
Notifications
You must be signed in to change notification settings - Fork 87
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
#expect is causing mismatch behavior on Linux + release configuration build #398
Comments
I'm trying to upgrade to 0.8.0 to see if the issue still exists. Update: Yes, the issue still exist for DemoKit + swift-testing 0.8.0
|
let firstOffset = PointerOffset<Base, Int>.offset { .of(&$0.first) }
let secondOffset = PointerOffset<Base, Int>.offset { .of(&$0.second) } The
I'm not using any pointer operation after "MARK". But adding struct PointerOffsetTests {
@Test
func demo() {
var tuple = Tuple(first: 1, second: 2)
typealias Base = Tuple<Int, Int>
let firstOffset = PointerOffset<Base, Int>.offset { .of(&$0.first) }
let secondOffset = PointerOffset<Base, Int>.offset { .of(&$0.second) }
withUnsafePointer(to: tuple) { pointer in
#expect(pointer[offset: firstOffset] == 1)
#expect(pointer[offset: secondOffset] == 2)
}
withUnsafeMutablePointer(to: &tuple) { pointer in
#expect(pointer[offset: firstOffset] == 1)
#expect(pointer[offset: secondOffset] == 2)
pointer[offset: firstOffset] = 3
pointer[offset: secondOffset] = 4
#expect(pointer[offset: firstOffset] == 3)
#expect(pointer[offset: secondOffset] == 4)
}
withUnsafePointer(to: &tuple) { pointer in
#expect(pointer[offset: firstOffset] == 3)
#expect(pointer[offset: secondOffset] == 4)
}
#if !canImport(Darwin) && !DEBUG
// MARK
print(tuple) // Tuple<Int, Int>(first: 1, second: 2)
withKnownIssue {
print(tuple) // Tuple<Int, Int>(first: 3, second: 4)
}
print(tuple) // Tuple<Int, Int>(first: 3, second: 4)
#else
print(tuple) // Tuple<Int, Int>(first: 3, second: 4)
#endif
}
} |
Then it's a variable we need to eliminate in order to narrow down the root cause of the issue. Looking at the code you shared in the zip file: public static func of(_ member: inout Member) -> PointerOffset {
withUnsafePointer(to: &member) { memberPointer in
let offset = UnsafeRawPointer(memberPointer) - UnsafeRawPointer(invalidScenePointer())
return PointerOffset(byteOffset: offset)
}
} This code is invalid. As I suggested earlier, use |
Change to use |
Description
I notice some test case is failing on Linux platform + release configuration.
Issue 1:
#expect
issueDigging into it, I found if I comment all
#expect
code or change to the oldXCTAssertTrue
fromXCTest
, the test case will pass normally.Issue 2:
withKnownIssue
issueAlso I can't record the such known issue with
withKnownIssue
. If I use it the failing case will magically pass again.Expected behavior
Test case works normal
Actual behavior
Test case is failing
Steps to reproduce
Unzip the following DemoKit.zip on Ubuntu 22.04 + Swift 5.10 env.
Run
swift test -c release
DemoKit.zip
swift-testing version/commit hash
0.6.0
Swift & OS version (output of
swift --version ; uname -a
)Swift 5.10 release + Ubuntu 22.04 + Arm64
Other info
My opinion is that the root cause of this issue is most likely not within swift-testing. It is rather caused by some optimization in the swift compiler, but the direct cause currently seems to be related to swift-testing.
Also reproducible with the following conditions
The text was updated successfully, but these errors were encountered: