Refactor FindPreludeFiles into InstallPaths (#4268)

From the driver's perspective, `FindPreludeFiles` is closely tied to
`compile`. This makes it difficult to refactor commands without
affecting the test dependencies on `FindPreludeFiles`. `InstallPaths`
seems like a decent home since it is responsible for the install
structure.

I'm switching to an `Error` return to allow callers to choose how to
handle it (e.g., in file tests, we typically don't want the direct error
stream).
This commit is contained in:
Jon Ross-Perkins
2024-09-04 22:22:48 +00:00
committed by GitHub
parent 1412ecd3f4
commit e382e6fd97
12 changed files with 124 additions and 83 deletions
+1 -5
View File
@@ -36,11 +36,7 @@ class ToolchainFileTest : public FileTestBase {
auto Run(const llvm::SmallVector<llvm::StringRef>& test_args,
llvm::vfs::InMemoryFileSystem& fs, llvm::raw_pwrite_stream& stdout,
llvm::raw_pwrite_stream& stderr) -> ErrorOr<RunResult> override {
auto prelude =
Driver::FindPreludeFiles(installation_.core_package(), stderr);
if (prelude.empty()) {
return Error("Could not find prelude");
}
CARBON_ASSIGN_OR_RETURN(auto prelude, installation_.FindPreludeFiles());
for (const auto& file : prelude) {
CARBON_RETURN_IF_ERROR(AddFile(fs, file));
}