Open
Description
Description
On Linux platforms the test discovery mechanism does not discover all tests. Specifically, it does not discover tests which are declared in a parent class.
As an example:
import XCTest
class BaseTests: XCTestCase {
var shouldPass: Bool { true }
func testItShouldPass() throws {
XCTAssertTrue(self.shouldPass)
}
}
class InerhitedTests: BaseTests {
override var shouldPass: Bool { false }
}
Should include two tests: BaseTests.testItShouldPass
and InheritestTests.testItShouldPass
.
On Linux only BestTests.testItShouldPass
is discovered:
$ swift test --list-tests
Building for debugging...
Build complete! (0.27s)
MissingTestsTests.BaseTests/testItShouldPass
On macOS all tests are discovered:
$ swift test --list-tests
Building for debugging...
Build complete! (0.64s)
MissingTestsTests.BaseTests/testItShouldPass
MissingTestsTests.InerhitedTests/testItShouldPass
As expected, the same is true when running the tests: 2 tests are run on macOS and only 1 on Linux.
Expected behavior
I would expect the output of swift test --list-tests
to be the same on macOS and Linux.
Actual behavior
Tests which run on macOS are silently not run on Linux when using test discovery.
Steps to reproduce
See example in description.
Swift Package Manager version/commit hash
No response
Swift & OS version (output of swift --version && uname -a
)
Swift version 5.8-dev (LLVM 278d67f38c6a910, Swift ee312bc1e20eb01)
Target: aarch64-unknown-linux-gnu
Linux 2b30d1439f50 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
This also reproduces with older Linux toolchains.