I wonder if we could add an annotation to the top of LinuxMain.swift - something like:
// swift-package-is-discovery-warning
And when SPM sees that, it’ll know that LinuxMain is just a dummy file for back-compat purposes, and that it should still use test discovery rather than compiling LinuxMain.
Can we at least silence the warning? grpc-swift gets this nasty combination of outcomes:
root@368b93eb7b6d:/code# swift test --enable-test-discovery
warning: '--enable-test-discovery' option is deprecated; tests are automatically discovered on all platforms
root@368b93eb7b6d:/code# swift test
[4/4] Build complete!
grpc_swiftPackageTests/LinuxMain.swift:16: Fatal error: Use --enable-test-discovery to run tests on Linux
If SwiftPM is going to insist to invoke the LinuxMain.swift, then it shouldn't get mad if --enable-test-discovery is passed to circumvent the behaviour. In that mode of operation the flag isn't deprecated: it has a clear, proactive behaviour that users genuinely want.
Remember that on Swift 5.3, today, if you run a Swift project that does not have a LinuxMain.swift file then nonsense like this happens:
root@f755702b5820:/code# swift run micro-function 8080
error: missing LinuxMain.swift file in the Tests directory
This of course is very unpleasant, and there were only two options: either pass --enable-test-discovery (a weird thing to have to pass to run) or add a do-nothing LinuxMain.swift file that told users what to do.
That makes sense, we hadn't thought about this case when designing the behavior. It makes sense to me to omit the warning if there is an existing LinuxMain.swift.