[ScanDependency] Allow continue searching for testable module

When swift dependency scanner first finds a binary module for a testable
import, verify if the module is built for enable-testing or not. If not,
keeps searching in case there is a second testable binary module in the
search path.

Previously, the first binary module will always be accepted by scanner
and rely on the importer to provide a good diagnostics. Now the scanner
will emit a warning before continue searching, so user understands why
the binary in the search path is not taken.
This commit is contained in:
Steven Wu
2024-04-24 12:29:34 -07:00
parent 3fe8b713d4
commit 10b30483dd
3 changed files with 20 additions and 11 deletions

View File

@@ -454,6 +454,12 @@ SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
modulePath.str());
return std::make_error_code(std::errc::no_such_file_or_directory);
}
if (isTestableImport && !loadedModuleFile->isTestable()) {
Ctx.Diags.diagnose(SourceLoc(), diag::skip_module_not_testable,
modulePath.str());
return std::make_error_code(std::errc::no_such_file_or_directory);
}
}
// Some transitive dependencies of binary modules are not required to be