swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.74k stars 1.34k forks source link

Linux test discovery failure with .interoperabilityMode(.Cxx) #6661

Open johnfairh opened 1 year ago

johnfairh commented 1 year ago

Description

If I set .interoperabilityMode(.Cxx) on a testTarget then the build fails with something like

/Users/johnf/project/TestCpp2/.build/x86_64-unknown-linux-gnu/debug/TestCpp2PackageDiscoveredTests.derived/TestCpp2Tests.swift:2:18:
error: module 'TestCpp2Tests' was built with C++ interoperability enabled, but current compilation does
not enable C++ interoperability
@testable import TestCpp2Tests
                 ^

It looks like the interoperabilityMode is not being propagated to the compilation of SPM's test-autodiscovery generated code: even though there is no C++ in here, the Swift 5.9 C++ interop flag is viral -- the only reason I have to set it for my testTarget is because of the thing I'm trying to test.

(workaround is swift test -Xswiftc -cxx-interoperability-mode=default)

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

swift-5.9-DEVELOPMENT-SNAPSHOT-2023-06-17-a

Swift version 5.9-dev (LLVM e2b11c251e5ef2b, Swift f4b2843236a710a) Target: x86_64-unknown-linux-gnu Linux 97536d5bd55a 5.15.49-linuxkit #1 SMP Tue Sep 13 07:51:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

MaxDesiatov commented 1 year ago

cc @egorzhdan