lexer_file_test.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 LexerFileTest : public FileTestBase {
  14. public:
  15. explicit LexerFileTest(const std::filesystem::path& path)
  16. : FileTestBase(path) {}
  17. auto RunOverFile(llvm::raw_ostream& stdout, llvm::raw_ostream& stderr)
  18. -> bool override {
  19. Driver driver(stdout, stderr);
  20. return driver.RunFullCommand(
  21. {"dump", "tokens", path().filename().string()});
  22. }
  23. };
  24. } // namespace
  25. auto RegisterFileTests(const std::vector<std::filesystem::path>& paths)
  26. -> void {
  27. LexerFileTest::RegisterTests("LexerFileTest", paths,
  28. [](const std::filesystem::path& path) {
  29. return new LexerFileTest(path);
  30. });
  31. }
  32. } // namespace Carbon::Testing