Add support for splitting a test file. (#2876)

I'm looking at this as I start thinking about handling `import`. Syntax is based on llvm's `split-file` tool.

The `std::vector` -> `llvm::SmallVector` switch is minor, I'm doing it here because I had to touch everything anyways and I think for tests I'll lean slightly more towards the toolchain's way of doing things versus explorer's.
This commit is contained in:
Jon Ross-Perkins
2023-06-07 08:56:20 -07:00
committed by GitHub
parent 97de96eac6
commit 6586179c8d
12 changed files with 190 additions and 59 deletions
+8 -4
View File
@@ -20,17 +20,21 @@ class ParserFileTest : public FileTestBase {
explicit ParserFileTest(const std::filesystem::path& path)
: FileTestBase(path) {}
auto RunOverFile(llvm::raw_ostream& stdout, llvm::raw_ostream& stderr)
auto RunWithFiles(const llvm::SmallVector<std::string>& test_files,
llvm::raw_ostream& stdout, llvm::raw_ostream& stderr)
-> bool override {
llvm::SmallVector<llvm::StringRef> args({"dump", "parse-tree"});
for (const auto& file : test_files) {
args.push_back(file);
}
Driver driver(stdout, stderr);
return driver.RunFullCommand(
{"dump", "parse-tree", path().filename().string()});
return driver.RunFullCommand(args);
}
};
} // namespace
auto RegisterFileTests(const std::vector<std::filesystem::path>& paths)
auto RegisterFileTests(const llvm::SmallVector<std::filesystem::path>& paths)
-> void {
ParserFileTest::RegisterTests("ParserFileTest", paths,
[](const std::filesystem::path& path) {