parse_tree_file_test.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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(llvm::StringRef path) : FileTestBase(path) {}
  16. auto RunOverFile(llvm::raw_ostream& stdout, llvm::raw_ostream& stderr)
  17. -> bool override {
  18. Driver driver(stdout, stderr);
  19. return driver.RunFullCommand({"dump", "parse-tree", path()});
  20. }
  21. };
  22. } // namespace
  23. auto RegisterFileTests(const std::vector<llvm::StringRef>& paths) -> void {
  24. ParserFileTest::RegisterTests(
  25. "ParserFileTest", paths,
  26. [](llvm::StringRef path) { return new ParserFileTest(path); });
  27. }
  28. } // namespace Carbon::Testing