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

Implement XCTExpectFailure() #438

Open
turboturnip opened this issue Apr 19, 2023 · 3 comments
Open

Implement XCTExpectFailure() #438

turboturnip opened this issue Apr 19, 2023 · 3 comments

Comments

@turboturnip
Copy link

turboturnip commented Apr 19, 2023

Description
test that calls XCTExpectFailure does not compile on linux

Steps to reproduce
create a simple test such as one showed on documentation:

import XCTest

class XfailTests: XCTestCase {
    func testExpectedFailure() throws {
        let thingThatFails = false
        XCTExpectFailure("Working on a fix for this problem.")
        XCTAssertTrue(thingThatFails, "This is not working right now.")
    }
}

create Package.swift with the test above as test target and run
swift test

Expected behavior
This should compile and run, tested working on macOS 12.5
but on linux (tested on official docker image) this will fail to compile:

root@50ad2ae7e8d5:/usr/src/test# swift --version
Swift version 5.8 (swift-5.8-RELEASE)
Target: x86_64-unknown-linux-gnu
root@50ad2ae7e8d5:/usr/src/test# swift test --vv
debug: /usr/bin/swiftc -print-target-info
debug: /usr/bin/swiftc -print-target-info
debug: /usr/bin/swift-frontend -frontend -print-target-info
debug: /usr/bin/swift-frontend -frontend -print-target-info
debug: /usr/bin/swift-frontend -frontend -emit-supported-features /tmp/TemporaryDirectory.oJfRMR/dummyInput-1.swift
debug: /usr/bin/swiftc -print-target-info
debug: /usr/bin/swift-frontend -frontend -print-target-info
debug: /usr/bin/swift-frontend -frontend -print-target-info
debug: /usr/bin/swift-frontend -frontend -emit-supported-features /tmp/TemporaryDirectory.n23bCG/dummyInput-2.swift
debug: /usr/bin/swift-frontend -frontend -print-target-info
debug: /usr/bin/swift-frontend -frontend -print-target-info
debug: /usr/bin/swift-frontend -frontend -emit-supported-features /tmp/TemporaryDirectory.BIEzQk/dummyInput-3.swift
debug: registering 'repository fetching' with terminator
debug: registering 'registry downloads' with terminator
debug: registering 'binary artifacts downloads' with terminator
debug: registering 'plugin runner' with terminator
debug: registering 'build system' with terminator
Planning build
debug: 'test': loading manifest for 'test' v. unknown from cache
Building for debugging...
/usr/bin/swiftc -module-name ExpectedFailureTest -incremental -emit-dependencies -emit-module -emit-module-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.swiftmodule -output-file-map /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.build/output-file-map.json -parse-as-library -c /usr/src/test/Tests/ExpectedFailureTest/ExpectedFailureTest.swift -I /usr/src/test/.build/x86_64-unknown-linux-gnu/debug -target x86_64-unknown-linux-gnu -swift-version 5 -enable-batch-mode -index-store-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/index/store -Onone -enable-testing -g -j48 -DSWIFT_PACKAGE -DDEBUG -module-cache-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -parseable-output -parse-as-library -color-diagnostics -v
Swift version 5.8 (swift-5.8-RELEASE)
Target: x86_64-unknown-linux-gnu
/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /usr/src/test/Tests/ExpectedFailureTest/ExpectedFailureTest.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -I /usr/src/test/.build/x86_64-unknown-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -enable-anonymous-context-mangled-names -module-name ExpectedFailureTest -emit-module-doc-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.swiftdoc -emit-module-source-info-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.swiftsourceinfo -emit-dependencies-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.build/ExpectedFailureTest.emit-module.d -parse-as-library -o /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.swiftmodule
/usr/bin/swift-frontend -frontend -c -primary-file /usr/src/test/Tests/ExpectedFailureTest/ExpectedFailureTest.swift -emit-dependencies-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.build/ExpectedFailureTest.d -emit-reference-dependencies-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.build/ExpectedFailureTest.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /usr/src/test/.build/x86_64-unknown-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -enable-anonymous-context-mangled-names -module-name ExpectedFailureTest -parse-as-library -o /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/ExpectedFailureTest.build/ExpectedFailureTest.swift.o -index-store-path /usr/src/test/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
/usr/src/test/Tests/ExpectedFailureTest/ExpectedFailureTest.swift:6:9: error: cannot find 'XCTExpectFailure' in scope
        XCTExpectFailure("Working on a fix for this problem.")
        ^~~~~~~~~~~~~~~~
error: fatalError

It compiles and runs fine once you comment out the ExpectedFailure call.

Environment
Latest swift docker:
root@50ad2ae7e8d5:/# swift --version
Swift version 5.8 (swift-5.8-RELEASE)
Target: x86_64-unknown-linux-gnu

@AnthonyLatsis
Copy link

cc @parkera @compnerd (sorry, not sure who to ping about XCTest)

It seems like ExpectedFailure is Darwin-only for some reason.

@compnerd
Copy link
Member

Hmm, I suspect that this is just API divergence and swift-corelibs-xctest has not been updated for the API changes for Xcode 12.5+. We should be able to support this.

@compnerd compnerd transferred this issue from swiftlang/swift Apr 19, 2023
@grynspan grynspan changed the title test that calls XCTExpectFailure does not compile on linux Implement XCTExpectFailure() Sep 5, 2023
@grynspan
Copy link
Contributor

Blocked by #348

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

No branches or pull requests

4 participants