mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:41:04 +01:00
Make INCLUDE-FILE less sensitive to path changes (#5159)
It's helpful for stability to not have the path in the repo reflected in test files, something I'm separately running into. So to reduce this, align INCLUDE-FILE with other split behavior: - Use the filename (with a "include_files/" subdir to disambiguate), rather than the full path. - Note if we eventually want to support splits in these, the same approach could be extended. - Only provide as an arg if the user requests files as args. Factoring AddFile back because it's hard to share; I'm also advocating to remove the prelude manifest, which would mean the remaining call could be removed.
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
#include "testing/file_test/file_system.h"
|
||||
#include "testing/file_test/file_test_base.h"
|
||||
#include "toolchain/driver/driver.h"
|
||||
|
||||
@@ -98,6 +97,21 @@ auto ToolchainFileTest::GetArgReplacements() const
|
||||
return {{"core_package_dir", installation_.core_package()}};
|
||||
}
|
||||
|
||||
// Adds a file to the fs.
|
||||
static auto AddFile(llvm::vfs::InMemoryFileSystem& fs, llvm::StringRef path)
|
||||
-> ErrorOr<Success> {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> file =
|
||||
llvm::MemoryBuffer::getFile(path);
|
||||
if (file.getError()) {
|
||||
return ErrorBuilder() << "Getting `" << path
|
||||
<< "`: " << file.getError().message();
|
||||
}
|
||||
if (!fs.addFile(path, /*ModificationTime=*/0, std::move(*file))) {
|
||||
return ErrorBuilder() << "Duplicate file: `" << path << "`";
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
auto ToolchainFileTest::Run(
|
||||
const llvm::SmallVector<llvm::StringRef>& test_args,
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>& fs,
|
||||
|
||||
Reference in New Issue
Block a user