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

Linux support missing from cross-platform? #17

Closed
idcrook opened this issue Nov 22, 2016 · 8 comments
Closed

Linux support missing from cross-platform? #17

idcrook opened this issue Nov 22, 2016 · 8 comments

Comments

@idcrook
Copy link
Contributor

idcrook commented Nov 22, 2016

Noticed that Swift libraries that are to be run on Linux have one slight variation in the testing that is missing from SwiftPlate.

Swift Package Manager (swift package init --type library) does additionally the following:

In Tests/{PROJECT}Tests/{PROJECT}Tests.swift it adds:

    func testExample() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
        XCTAssertEqual({PROJECT}().text, "Hello, World!")
    }
    static var allTests : [(String, ({PROJECT}Tests) -> () throws -> Void)] {
        return [
            ("testExample", testExample),
        ]
    }

the example assert is related to boilerplate code in the Sources/ implementation, but the allTests is more interesting, as that is the convention for the slightly different testing flow for Swift encountered under Linux.

For Linux it adds another, related file Tests/LinuxMain.swift. Its contents:

import XCTest
@testable import {PROJECT}Tests

XCTMain([
     testCase({PROJECT}Tests.allTests),
])

Could the "cross-platformness" of SwiftPlate be updated to include libraries on Linux?

@JohnSundell
Copy link
Owner

@idcrook Thanks for the very detailed issue! Super awesome 🚀 I'd love for SwiftPlate to support Linux as well! 👍

One thing is that not all libraries can support Linux (for example, if you're building a framework that depends on UIKit or some other Apple platforms-only API). So we should probably ask if the user wants to support Linux when running SwiftPlate - and if so perform the changes you listed above to the project. What do you think?

@idcrook
Copy link
Contributor Author

idcrook commented Nov 22, 2016

I think that makes a lot of sense. 👍 I hadn't tried all the SwiftPM init types (current 3.0.1 bundled swift package has (type: empty|library|executable|system-module)), but it already has a command line switch/option to guard it. I think being prompted about it makes sense. 🎉

@JohnSundell
Copy link
Owner

Alright, so let's go with that! 👍 Let me know if you want to do the implementation as well 😉

@idcrook
Copy link
Contributor Author

idcrook commented Nov 22, 2016

I'll look into it in a day or two if I can.

@JohnSundell
Copy link
Owner

@idcrook Awesome, no preasure - just post here if you start working on it - otherwise I (or someone else) might pick it up - would be a great feature to have 😄

@idcrook
Copy link
Contributor Author

idcrook commented Nov 25, 2016

I created PR #20 that add the Linux library testing support. However, there a a few caveats outlined in the PR.

@JohnSundell
Copy link
Owner

@idcrook Can we close this now that #20 has been merged? 🙂

@idcrook
Copy link
Contributor Author

idcrook commented Nov 26, 2016

Closing, with PR #20

@idcrook idcrook closed this as completed Nov 26, 2016
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

2 participants