[Dependency Scanning] Keep track of which direct dependencies are '@testable' for a Source dependency

This commit is contained in:
Artem Chikin
2023-04-17 13:37:08 -07:00
parent e0eeb6339b
commit 10fb324d1f
3 changed files with 36 additions and 1 deletions

View File

@@ -85,6 +85,18 @@ ModuleDependencyInfo::getAsPlaceholderDependencyModule() const {
return dyn_cast<SwiftPlaceholderModuleDependencyStorage>(storage.get());
}
void ModuleDependencyInfo::addTestableImport(ImportPath::Module module) {
assert(getAsSwiftSourceModule() && "Expected source module for addTestableImport.");
dyn_cast<SwiftSourceModuleDependenciesStorage>(storage.get())->addTestableImport(module);
}
bool ModuleDependencyInfo::isTestableImport(StringRef moduleName) const {
if (auto swiftSourceDepStorage = getAsSwiftSourceModule())
return swiftSourceDepStorage->testableImports.contains(moduleName);
else
return false;
}
void ModuleDependencyInfo::addModuleDependency(ModuleDependencyID dependencyID) {
storage->resolvedModuleDependencies.push_back(dependencyID);
}
@@ -114,6 +126,10 @@ void ModuleDependencyInfo::addModuleImport(
ImportPath::Builder scratch;
auto realPath = importDecl->getRealModulePath(scratch);
addModuleImport(realPath, &alreadyAddedModules);
if (getKind() == swift::ModuleDependencyKind::SwiftSource &&
importDecl->isTestable())
addTestableImport(realPath);
}
auto fileName = sf.getFilename();