This has been talked about but I said I'd put it into a proper pitch to get the ball finally rolling.
Swift 5.1 introduced Test Discovery on Linux adding an
--enable-test-discovery flag you could pass to
swift test so it would automatically pick up tests on Linux to run, without having to manually specifying them, which is prone to problems.
Since this has been in use for several months now without major issues, I propose we enable the flag by default. This simplifies testing on Linux, stops build errors when building on Linux without a
LinuxMain.swift present and no flag, and generally makes life a bit easier, especially for newcomers.
For macOS users there should be little to no difference. I do propose, however, that all platforms use the same discovery methods when running
swift test. This reduces differences between the OSes which could cause bugs and test failures to slip through.
For other platform users, this means that you no longer need to pass
--enable-test-discovery through to the
test commands for your tests to run or compile.
There are edge cases where you may need to specify the tests you want to run due to subtle behaviour differences with test discovery. IIRC SwiftWasm has run into this. So I propose we add a new
--use-test-manifest flag that will look for the equivalent of
LinuxMain.swift and load tests from there. However, this won't be enabled by default and won't be included in the template provided by
swift package init. (It should of course be documented though!) This allows those who need it to specify their tests.
This new manifest file should also be renamed away from
LinuxMain.swift to reflect Swift's new cross-platform support, including Windows I propose naming it