-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fixes SR-822, support tests directly under Tests directory #162
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
Conversation
class FooTests: XCTestCase { | ||
func testSuccess() { | ||
} | ||
} |
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.
Add Linux support. It should be like
#if os(Linux)
extension FooTests: XCTestCaseProvider {
var allTests: [(String, () throws -> Void)] {
return [
("testSuccess", testSuccess),
]
}
}
#endif
PR-158 is merged now, please update your tests. |
@aciidb0mb3r @kostiakoval Made the changes and rebased. Please check. |
if (rootTestFiles.count > 0) { | ||
let rootTestSource = Sources(paths: rootTestFiles, root: path) | ||
return [TestModule(basename: name, sources: rootTestSource)] | ||
} |
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.
I think this might look better with guard
guard !(testDirectories.count > 0 && rootTestFiles.count > 0) else { throw ModuleError.InvalidLayout(.InvalidLayout) }
if testDirectories.count > 0 {
return try testDirectories.map {
TestModule(basename: $0.basename, sources: try self.sourcify($0))
}
}
if rootTestFiles.count > 0 {
let rootTestSource = Sources(paths: rootTestFiles, root: path)
return [TestModule(basename: name, sources: rootTestSource)]
}
return []
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.
👍 Done
Could someone please trigger CI tests on this PR? |
@swift-ci please test |
Fixed issue that caused build to fail. |
I'm not sure I 100% agree with that implementation. Why can't we support both tests files in root Just by simple adding 1 test file in the root, you can break your project. I think that could be confusing for people. We could simple support both of them by implementing it like that. extension Package {
func testModules() throws -> [TestModule] {
let (directories, files) = walk(path, "Tests", recursively: false).partition{ $0.isDirectory }
let testDirectories = directories.filter{ !excludes.contains($0) }
let rootTestFiles = files.filter {
!$0.hasSuffix("LinuxMain.swift") && isValidSource($0) && !excludes.contains($0)
}
var res: [TestModule] = []
if (testDirectories.count > 0) {
res + try testDirectories.map {
TestModule(basename: $0.basename, sources: try self.sourcify($0))
}
}
if (rootTestFiles.count > 0) {
let rootTestSource = Sources(paths: rootTestFiles, root: path)
res.append(TestModule(basename: name, sources: rootTestSource))
}
return res
}
} What do you think? |
Yes @kostiakoval, I thought about the same. In fact, in
Max Howell, told that he is drafting a proposal that will make folder layouts to be more flexible. That's why I haven't added support for tests directly under So, what do you think? Shall we wait for the proposal to come out? or can we merge this one and refactor once the proposal is out? |
Yes, I've seen the mail, and If I understood Max correctly
we should include all test that are in a Root folder for tests (the |
Of course, we cannot actually test a single module executable, so we should probably address that separately. |
@kostiakoval I'm still waiting for "No More Magic" proposal to come out which should draw the line between supported and unsupported layouts. For now, as you might've already guessed, you can create folder inside |
@kostiakoval Agreed. Raised PR #301 making |
I'm torn between:
So maybe someone else can weigh in. I like 1. as things are then less ambiguous in how our code works and what the user will get when experimenting. But the reality is we already support |
My vote is consistency with Sources, I am surprised when it isn't. |
I'm closing this due to age, I think we are going to probably end up going in the direction of not accepting this to enforce consistency with a more scalable convention (subdirectories). In any case, we should resolve it in a proposal or bug, not decide in this PR. |
…emoval <rdar://problem/30961839> Implement support for stale file removal
Added support for test files directly under
Tests
directory.Sample: