Skip to content

Commit

Permalink
[Tests] Don't use invalid module to satisfy canImport check (swiftl…
Browse files Browse the repository at this point in the history
…ang#7647)

Stop using a fake invalid module to satisfy `canImport` check for
testing as swift compiler will start to evaluate such checks to false in
the future.

Instead, using a valid swift interfacefile to satisify the external
module import dependency.
  • Loading branch information
cachemeifyoucan authored Jun 7, 2024
1 parent ee9d0b2 commit 3b9dd49
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Tests/SPMBuildCoreTests/PluginInvocationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,14 @@ final class PluginInvocationTests: XCTestCase {
}
""")

// Create something that looks like another module that can be detected via `canImport()`.
// Create a valid swift interface file that can be detected via `canImport()`.
let fakeExtraModulesDir = tmpPath.appending("ExtraModules")
try localFileSystem.createDirectory(fakeExtraModulesDir, recursive: true)
let fakeExtraModuleFile = fakeExtraModulesDir.appending("ModuleFoundViaExtraSearchPaths.swiftmodule")
try localFileSystem.writeFileContents(fakeExtraModuleFile, string: "")
let fakeExtraModuleFile = fakeExtraModulesDir.appending("ModuleFoundViaExtraSearchPaths.swiftinterface")
try localFileSystem.writeFileContents(fakeExtraModuleFile, string: """
// swift-interface-format-version: 1.0
// swift-module-flags: -module-name ModuleFoundViaExtraSearchPaths
""")

/////////
// Load a workspace from the package.
Expand Down

0 comments on commit 3b9dd49

Please sign in to comment.