parse_tree_file_test.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include <gmock/gmock.h>
  5. #include <gtest/gtest.h>
  6. #include <vector>
  7. #include "llvm/ADT/StringRef.h"
  8. #include "llvm/Support/raw_ostream.h"
  9. #include "testing/file_test/file_test_base.h"
  10. #include "toolchain/driver/driver.h"
  11. namespace Carbon::Testing {
  12. namespace {
  13. class ParserFileTest : public FileTestBase {
  14. public:
  15. explicit ParserFileTest(const std::filesystem::path& path)
  16. : FileTestBase(path) {}
  17. auto RunWithFiles(const llvm::SmallVector<std::string>& test_files,
  18. llvm::raw_ostream& stdout, llvm::raw_ostream& stderr)
  19. -> bool override {
  20. llvm::SmallVector<llvm::StringRef> args({"dump", "parse-tree"});
  21. for (const auto& file : test_files) {
  22. args.push_back(file);
  23. }
  24. Driver driver(stdout, stderr);
  25. return driver.RunFullCommand(args);
  26. }
  27. };
  28. } // namespace
  29. auto RegisterFileTests(const llvm::SmallVector<std::filesystem::path>& paths)
  30. -> void {
  31. ParserFileTest::RegisterTests("ParserFileTest", paths,
  32. [](const std::filesystem::path& path) {
  33. return new ParserFileTest(path);
  34. });
  35. }
  36. } // namespace Carbon::Testing